Sunday, October 21, 2012

What is cruft code?


While I was in Denver this weekend I noticed a good example of cruft code.  Simply put it is code that is never used.  The reason it never gets called is because of bad design, bugs, or upgrades that where poorly planned.

In the example above, the shower ring stops the door before the door stop.  The door stop is never used no matter how you try to open the door.  They could of either designed the system to give the door enough space to use the door stop or they could of simply left the door stop off.  Either way it seems wasteful.  Imagine the money this hotel could of saved if they would of left these off of every single room in the place.  In software, it doesn't lead to material waste but it can make your code harder to read and debug.  If you must have cruft code, make sure you comment and explain why.  This way future developers can spend more time using your code to make greater things rather than spending time trying to figure out your code. 

For more examples and further definition, view the wiki page on this topic. http://en.wikipedia.org/wiki/Cruft

Happy Coding.

No comments:

Post a Comment