Article 67R77 CodeSOD: Else To

CodeSOD: Else To

by
Remy Porter
from The Daily WTF on (#67R77)

David inherited a codebase that's a few decades old. As each developer has taken it over, they've done their best to follow the code standards that the previous developers used, to at least keep the codebase consistent. A few rebels may have gone a different route, like the right one, but too many just followed the patterns that were already there.

This means that there are a lot of variables named things like a and aa and aaa. There are 4,000 line functions and loads of copy/pasted code.

In other words, all the usual markers of bad code are there. But the special feature that David inherited is that in the code, this is a common way to express an if/then/else:

if (someCondition){DoTheThings();goto skipIt;}DoTheElseThings();skipIt://program continues

Not every conditional is written this way. There are a few developers who, as they modified the code, tried to whip it up into some sort of sane shape. But not enough did that. So these kinds of blocks are just scattered everywhere.

otter-icon.png [Advertisement] Continuously monitor your servers for configuration changes, and report when there's configuration drift. Get started with Otter today!
External Content
Source RSS or Atom Feed
Feed Location http://syndication.thedailywtf.com/TheDailyWtf
Feed Title The Daily WTF
Feed Link http://thedailywtf.com/
Reply 0 comments