Skip to content

Useless code.

January 10, 2007

I was going through some code for a project that we’ve inherited. This is perhaps the worst code I’ve seen to date. On a whole, the structure is understandable but it is extremely monolithic and tightly coupled. There are deep levels of nesting and the coding convention makes things horrendous to read.

An example of the useless code:

SomeObject A = new SomeObject();

if (A != null) {

// do something

}

Now, when can that call to the contructor fail?
An exception? then the next line won’t even get executed
Constructor returns null? it can’t.
Runs out memory? then it being null is the least of your worries

There is no reason for that line and that additional level of nesting.

Advertisements

From → Uncategorized

Leave a Comment

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

%d bloggers like this: