Recent CodeSOD

Code Snippet Of the Day (CodeSOD) features interesting and usually incorrect code snippets taken from actual production code in a commercial and/or open source software projects.

Nov 2012

IInceptionFactory

by in CodeSOD on

The Factory pattern is an excellent way to solve a variety of programming problems using an object-oriented language. It’s a simple pattern, but for some developers, not quite simple enough. Den found this interface :


            

Your Standards Are Too High

by in CodeSOD on

During his interview, Michael was asked what his coding pet peeves were. Things that, as a developer, really got under his skin.

Michael replied with the best answer he could think of. "I hate working inside of sloppy code. I think that it's best to spend time coding up front to save yourself from headaches down the road."


Battleship Booleans

by in CodeSOD on

Barry’s first problem with the code was the use of magic numbers. If the application state variable held “127”, it then certain buttons would be enabled, but if it were “54”, then they should be disabled.

This led to all sorts of rules about combinations of magic numbers, some of which were more obscure than others. A huge library of methods arose to parse them out and derive simple true/false expressions based on combinations of magic numbers.