Tuesday, May 31, 2011

programming WTF

I am working as a programmer for 4+ years. There are many times I have shouted at the code which might be from a legacy application or written by a newbie.

I would like to share those moments with you. here it goes.

1)

insane variable naming conventions:

var bookIdArray:Integer; // is it an array variable or integer variable?

var book:Person = new Person();
book.walk();


insane fn naming conventions:

deleteListProducts($data);
// use a single verb for a fn name. dont use as many verbs as u want.

2)

if (isloggedIn == true) {
// ..
} else if (isloggedIn == false) {
// ..
}

3)

var Person:Person=new Person();
Person.go(); // confuse the developer. is go() is a static fn? or Person is an object?


4) comments in code for the sake of commenting:

Ex #1:
// Executing Query
$this->executeQuery(sqlQuery);


Ex #2:
// Modified by John.
// xx = fooObj.fooMethodName(arg1, arg2);

mention what/why/when it has been modified. the person name doesnt add more info for the comment. mention issue id if its a bugfixing.

No comments:

Post a Comment