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
I know where some of this came from. If only I too had taken the time to write some of these down.
[…] Tips: IE Caching Can Byte, Notes to self: Keep SVN in sync w/ Git The Poor Man’s Way, and Programming Anti-Patterns: Releasing Cthulhu. Honestly, these were cop-out posts. I know I will go back at reference them at some point, but […]