20 January, 2011

write less

honoring the title and idea of this post i'll just say this to get the point across:

the quality of your solution is inversely proportional to the amount of code you write to solve the problem.

unfortunately, i have to say a bit more to justify my thoughts.

i've always wondered about how to write good code; and i'm not the only one apparently:


well, i've finally figured it out: good code is written by writing as little code as possible. this is true because the when you write the bare minimum you will almost naturally end up with code that is easy to read, easy to test, easy to extend, and therefore, easy to maintain (to see more about the attributes of good code, take a look at the pyramid of code quality).

i understand that there are guidelines and principles that you must still follow when writing "just enough" code, but things really deteriorate fast when you don't KISS.

so next time you're inclined to do solve a problem with code, first think about if there's a way to solve it without any code. then, and only if you absolutely must, write as little code as possible.