giza: Giza White Mage (Default)
[personal profile] giza
A few of the jobs I've worked at over the years have reqired me to maintain code written by those before me. Sure, undocumented code is a pain, but some things end in me shaking my head while muttering "WTF?" to myself over and over.

Here are a few examples:

1) Calling srand() in a for loop. That seeds the random number generator. You don't need to keep reseeding the generator on every iteration of the loop!

2) Writing code like this:

try {
   function_call();
} catch (Exception e) {
   throw (e);
}


Do you not understand how exceptions work? Throwing an exception you just caught is totally redundant!

3) Writing code like this:

if (condition) {
   return (true);
} else {
   return (false);
}

return (false);


The astute programmer will note that the final return statement is never reached. Do you not understand how return statements work? o.O

4) Things like this:

$file = fopen($filename);
$line = fgets($file);


Is it that hard to check the return value of a function? Do you like seeing file permission errors all over the webpage? I don't!

Related reading: The Chronicles of George (aka, The System is "Havening" a Problem!)
Also related: The Daily WTF
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

giza: Giza White Mage (Default)
Douglas Muth

April 2012

S M T W T F S
1234567
891011121314
15161718192021
22232425262728
2930     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags