Young Programmers |
| October 11, 2008 |
Bad Programming Style |
|
|
Login Panel |
 |
|
|
Resources |
 |
|
|
|
|
After being pissed off with my Java teacher, I decided to spend the rest of the course pushing the limit of how bad my programs could get without failing the course. I'll list some of the highlights here. Many are inspired by (or even stolen from) Roedy Green's essay on how to write unmaintainable code.
-
One-letter variable names. Not very imaginative, but a cool side effect is that you can fit more code on a single line. Sometimes you can make pretty complex algorithms fit on a line or two.
-
Silly variable name scheme. If you don't want to use one-letter names, at least use some naming scheme with no relevance to the code. "Alice's Adventures in Wonderland" is a good start.
-
Don't comment your code.
-
If comments are enforced, I'll give you one hint. A certain book is available as an e-text from Project Gutenberg.
-
Lie. Just remember that if you lie all the time, nobody will believe you. Make sure that most variable names and comments are correct, but that the 5% most important and complex code will have misleading variable names and comments lying about the purpose of the code.
-
If there's a simple and fast way to do things, avoid it. I once decided that text output in Swedish would be too inflexible, so I made sure that all messages were handled in Esperanto internally. Of course, this required a large and inefficient class to automatically translate these messages at run time.
How did my crusade go? I got things thrown at me by the teacher, but ended up with an A in the course |
|
|
|