How To Write Unmaintainable Code
home.tamk.fi
home.tamk.fi
CODE THAT MASQUERADES AS COMMENTS AND VICE VERSA
Include sections of code that is commented out but at first glance does not appear to be.
for ( j=0; j < array_len; j +=8 )
{
total += array[j+0];
total += array[j+1];
total += array[j+2]; /* Main body of
total += array[j+3]; * loop is unrolled
total += array[j+4]; * for greater speed.
total += array[j+5]; */
total += array[j+6];
total += array[j+7];
}
Without careful attention , would you notice that three lines of code are commented out? // will the next line be compiled??/
no it won't!Not sure if that counts as careful attention, but it's usually clear something could be wrong when someone writes something in a very odd way.
Object oriented programming is a godsend for writing unmaintainable code. If you have a class with 10 properties (member/method) in it, consider a base class with only one property and subclassing it 9 levels deep so that each descendant adds one property. By the time you get to the last descendant class, you'll have all 10 properties. If possible, put each class declaration in a separate file. This has the added effect of bloating your INCLUDE or USES statements, and forces the maintainer to open that many more files in his or her editor. Make sure you create at least one instance of each subclass.
Underscore, a Friend Indeed
Use _var and __var in identifiers.
Even better when it's sometimes __ and sometimes ___ - you can never tell which it is at a glance. (Python is great for this one!)My favorite is "Properly-written code never fails, so exceptions are actually unnecessary."
"If you don't know what to do, just return null and pretend like nothing happened! This way you can put all the blame on the caller. Your code effectively becomes flawless!"