Two Guys Arguing

Programming Anti-Patterns: Releasing Cthulhu

Posted in Uncategorized by benjaminplee on 11.10.10

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

All codes have been modified and rewritten to protect the guilty.
About these ads
Tagged with:

2 Responses

Subscribe to comments with RSS.

  1. el_neunie said, on 11.10.10 at 10:39 pm

    I know where some of this came from. If only I too had taken the time to write some of these down.

  2. […] 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 […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.