Following the KISS rule

Rube Goldberg's Self-Operating Napkin

Fair warning:  this post contains no more than my idle musings.

As a programmer, programming is fun to me.  I’m sure a lot of other code monkeys feel the same way.  It is satisfying to be presented a problem, and create a solution for it.  It is a great feeling to just go in the zone and come up with a piece of code that would make you wonder if another better programmer possessed you for a brief moment.

It is easy to get carried away sometimes though.  The problem is that we fall in love with concept or piece of code and want to use it all the times.  It could be something we came up with ourselves, or something we saw on a blog post somewhere.  It is just so cool that we have to work it into our daily repertoire, whether the situation calls for it or not.  Next thing you know, we have a project using MVVM/n-tier hybrid architecture with a custom-built ORM, all to display an RSS feed.

That is one of the trappings we programmers often fall into; we get sucked into elaborate and complex solutions to do a easy task, when the best solution is often the simplest one.  It may be a little counter-intuitive, but at times it is almost easier to come up with a Rube Goldberg solution than it is to come up with a straightforward one.  Some times It may be because of unfamiliarity with a new programming language and its features, or simple tunnel vision.  Other times it’s because we get caught up with the latest industry trend.  Regardless of why, the end result is often this beast of a code that contains 500 lines to do what 20 lines would do better.

So my advice is to seek simplicity and follow the KISS rule (keep it simple, stupid).  The most elegant code I have seen is often the one that is least verbose (but not illegibly so).  Besides, a simpler code is also easier to maintain, and you’ll thank yourself 6 months later if (when) you have to go back to the old code for whatever reason.


Illustration: Self-Operating Napkin by Rube Goldberg