Scary Code – Red Flags

Every time I navigate through code there are things I see that I would call “Red Flags” that are indicators that either the previous developer(s) didn’t know what they were doing or they built a fragile system.

Here’s a few of the one’s I’ve seen that scare me (and an explanation why if it isn’t obvious). Sadly there are many so I suspect this will be a recurring thread 😉

Red Flag Warning

1.) Anytime I see a variable or parameter named something like “ignoreErrors”.  This could be a totally legit case… but more likely points to either depending on code that often throws random errors or simply not dealing with errors properly and just trying to provide a duct tape solution.

2.) Anytime I see “temp” in a variable name. Again there might be a rare case when shuffling 2 indexes in an array but any other scenario suggests that the developer didn’t spend the time to properly name things and may well have not spent the time to write good logic either.

3.) Anytime I see a catch statement with nothing in it.  If commented with an explanation of how failure is ok then this is fine.  However any other time I see this it looks like the developer left the stub in there to handle later but never came back.

4.) Anytime I see documentation for a method that exceeds the size of the method itself.  This is typically a sign of code master… uhm… what’s that word for when you have the ultimate fun by yourself?  This is a sign of a developer that is actually thinks so much of themselves they feel the need to advertize their skills by going on and on about their code.  More importantly code should be self documenting so if you need to add huge blocks of comments to document your code something has gone wrong.

5.) Anytime I see a method name that ends in a number “2” (or worse yet a 3, 4, 5…) e.g “getBillingInfo2”  This is a sure sign of an initial method not quite being up-to-snuff but rather than the developer fix the method to make it more robust (or provide overloaded/helper methods) a previous developer was lazy and simply cloned the original and hacked in their own stuff.  Other classic symptoms of this disease are methods prefixed/suffixed with “Old”, “New”, “VersionTwo”, “VersionThree”.

Got any “Red Flag” warnings of your own? Let me know and we can share the painful burden of maintaining bad code!


Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s