Simple
Without a doubt, simple code is better code - more really is less. To misquote Einstein, "Make everything as simple as possible, but not simpler". Rarely have I encountered complicated code that needed to be complicated, even complicated logic does not not require complicated code.
If you aim for nothing else in your code, make it as simple as you can possibly achieve - someone will thank you for it one day, and it may even be yourself.
Expressive of Intent
It should be simple for a casual reader to browse your code, and figure out what you were trying to do. This comes down partially to using meaningful names for variables and methods, and partially down to structuring your code in a slightly better way. Don't sacrifice code clarity for secondary concerns like optimisation or the "wow factor". Simplicity has a lot to bring to this objective, but so does elegance.
Elegant
Code that is well written should be elegant, it should flow, it should read more like poetry than a technical manual. A well written code base is a joy to read, it leads you through the functionality, and always leaves you with a smile on your face. It takes no more than a brief glance at a source file to tell you if it has this quality. You only have to glance at open source projects like Castle or Rhino Mocks to see just how beautiful well written code can be.
Easy to Identify, Hard to Write
And the crux of the problem - good code is hard to write. Really hard to write.
An average developer can pick up a good code base and immediately identify it as being "really good code", but it takes a lot of experience to be the one to create it in the first place. The real skill in writing good code is knowing what you can take away, till nothing remains but the purest form of the solution.
Good developers are creatives, not technical people - technical things can be trained, but creativity is something that you have within and need to nurture. Practice, practice, and practice more - always strive to write simpler, more expressive and more elegant code.
Posted
05-06-2008 7:08 AM
by
Jak Charlton