#define geek – what qualifies a person to be a geek?

I notice the term GEEK is used a lot these days, every man and his dogs flea refers to themselves as a geek. I’m talking computer geek here today, no other kind 🙂

15 years ago  it was a different story completely. In my book and having talked to several other people online, a geek is somebody who is into technology and understands it and is doing stuff beyond the average user.

But to clarify, can you please leave your thoughts and opinions in the comments. What is a GEEK and what is not a GEEK?

My thoughts are that you need at least one or two of the following criteria (not all!)

  • You can program in more at least one language, probably 2 or 3 (html/css NOT included)
  • You can use a command line easily without having to google commands in at least one of the following Windows, Linux, or OS X
  • You know the difference between a Domain Registrar, Domain Name Server, and types of DNS records.
  • You know what Linux is, have installed it, and used it regularly (using a friends/boyfriends/family PC not counted, and done without help)
  • You can name all the following parts of a PC, AND what they do. CPU, RAM, HDD, BUS, PSU.
  • You can create a full network, including DHCP, DNS, Gateway/firewall and know what IP ranges are reserved for private networks
  • Do all of the above WITHOUT having to google!

You are NOT a geek if you ONLY do

  • You are on Helpdesk
  • you helped somebody fix their email
  • You use IRC, Twitter, Forums, Other chat forums
  • You Game lots (Some gamers are geek, but most are not)

Note: if you do the “you are not a geek if” and still qualify the above ones you are still a geek.

PHP Code

– code as if whoever maintains your code is a violent psychopath who knows where you live
– code in paragraphs, i.e. group related chunks and separate them by a new line
– indent style uses the K & R style
– columns 100 max, unless workaround (i.e. HTML) is needed
– The use of <?php ?> to delimit PHP code is encouraged, especially for core packages
– Using <? ?> is OK for main PHP files

File Format:
– use the UNIX file format, that is a LF character for end of lines
– make sure there is no whitespace after the last non whitespace character for every line

– avoid // for comments in PHP
– comments should start with #
– /* */ style in PHP is OK for multiple lines
– when commenting out code lines add the comment character at the start of the line,
makes it easier to separate form normal comments,

– tab indent size should be set to 4
– tabs should be used for identing only NOT for alignment
– a tab character can only be used at the start of the before any non-whitespace character
– checkout the Smart Tabs vim plugin

function do_something() {
<TAB>$long_variable = foo($baz);
<TAB>$short = foo($bar);

– abbreviations should be avoided, ie $session->initialise() not $session->init()
– common abbreviations are acceptable as long as they are used the same way throughout the project.

– hungarian notation is to be avoided for scripting languages
– use all lower case letters separated with underscores, i.e. $first_name
– space on each sides of equal for assignment, i.e. $first_name = ‘John’;

Hashes & Associative Arrays:
– in Perl both $hash{key} and $hash{‘key’} are OK
– in PHP both $array[key] and $array[‘key’] are OK

– all uppercase separated by underscores, eg SESSION_TIMEOUT
– in Perl use Readonly instead of constant
– for PHP constants related to a class, prefix with the name of the class they are used in.
for example, the constants used by the Benon_DB package should all begin with “Benon_DB_”.

– avoid using double quotes unless necessary
– only simple variables are allowed in an interpolated string
– do not use hashes, arrays, ${var} expressions in interpolated strings

$var = ‘My String’;
$var = “…string… $some_var …more…’.$another_var.’_more stuff…’;
$var = “…string…’.$another_var.’_more stuff…’;
$sql = ‘INSERT INTO mytable (field) VALUES (‘.$db->quote($var).’)’;
$var = “My String\n”;

– one space on each side of the brackets

for ($i; $i < 10; $i++) {
# …

foreach ($arr as $k => $v) {
# …

while ($i < 10) {
# …

– one space on each side of the brackets
– uncuddled elses: return line after a closing curly bracket
– only “if (…) do_something” in ONE line are allowed

if ($a == $b) {
# …
elsif ($a == 1) {
# …
else {
# …

– use all lower case words separated by and underscore
– follow the verb/subject rule, ie get_this, do_something, is_ready
– use a space between the function/sub keyword and the identifier
– use arrays as arguments for public functions in core packages
– use PHPdoc http://manual.phpdoc.org

function print_name($first, $last) {
echo $var;

foo(‘John’, ‘Doe’);
foo(array(first => ‘John’, two => ‘Doe’));
first => ‘John’,
two => ‘Doe’

– use CamelCase, i.e. SomeNamespace::SomePackage
– In PHP use an underscore to fake namespace separation, i.e. SomeNamespace_SomePackage
Hopefully one day PHP devs will get a clue and support namespaces 🙂
– For PHP constructors, use __construct not the name of the package
– abreviations are left uppercase, ie “DB” not “Db”, i.e. Benon_DB_Result

– keywords all uppercase, ie SELECT FROM blah WHERE name = ‘Joe’;