Friday, February 4, 2011

A line of code is one too many

courtesy of

Over-engineering the obvious

One line of code is one too many.

This quote, which I should trademark if I was a little more "entrepreneur", just summarize a situation we keep coming in while leading design sessions, code reviews, etc. How often people comes up with complex solutions to simple problems. We, developers, thrive on complexity. We think the best solution is by definition the most complex one. Or, we find a solution to a problem, which itself provokes another problem, and a solution, and a problem, and on and on. It's hard to just tell everyone "Hey, forget about it. WHAT led us in that direction in the first place ?!?!?!". But, let's face it. We are not working to have fun. And designing complex algorithms and frameworks IS fun.

So in honor of these situations, I came up with this quote: A line of code is one too many.

Ultimately this just says that when you write a line of code, you better have a reason to put it there. A reason you can easily debate with any people reviewing your code. Any line should be left off if it doesn't fill a present need. Any line fulfilling a future need, even probable, should be removed right away. Keep in mind that the future, in terms of software development, is really hard to predict.