Programming Anti-Patterns: Releasing Cthulhu
Some code is elegant. Some code is a quick fix hack.
Some code is maintainable. Some code release Cthulhu.
These are just a few gems I have found over the past year or so…
Math is for the Weak Pattern
if(result == 1) {
obj.foo(0);
}
else if(result == 2) {
obj.foo(1);
}
else if(result == 3) {
obj.foo(2);
}
else if(result == 4) {
obj.foo(3);
}
Subtraction is a poor abstraction;
Scare the Next Guy Pattern
// ... Base DAO containing transaction logic for whole application ...
if(connection.isOpen()) {
aSimple.MethodCall();
// TODO:
}
// ... more complex TX logic ...
Because, what he doesn’t know … might be nothing … or might be something
Decoy Security Pattern
<pre>public Connection getNewConnection() {
Long.Full.Package.Name.Connection c = new Long.Full.Package.Name.Connection();
return new Long.Full.Package.Name.Connection();
}
No cups in this shell game, just database connections
Missing Father Pattern
try {
foo.bar();
}
catch(Exception e) {
throw e;
}
If dad is never around, you end up playing catch with yourself

2 comments