Friday, October 26, 2012

Code quality

I have been always fascinated with saying more with less.  Some people go on talking for hours without saying anything.  Some can utter just a few words yet say many things about the subject.  When you are trying to convey an idea it always is a good practice to think about what you want to say and how you want to communicate.

I believe the same applies to coding.  When you write code, you want to be as concise as you can be without losing its functionality.  Coding is like writing a poem with lot of refrains.  Good code often reuses common routines and they hit on key points without wasting reader's attention.


I say reader's attention because no code is written and maintained only by program.  At some point in the code life cycle someone will look at it to understand what it was meant to do and see if there is any way to change and improve the code.  Therefore it is important to write readable code.

True test of code quality is when code is modified to change its behavior.  Bad code takes lot of time to change because it's long and complex to understand.  Good code takes less time to change because it's shorter and easy to understand.

Code quality is no abstract concept.  It's a measure of how malleable the code is.

If code is hard to understand and you have to change its behavior,
it's time to refactor so that you can understand next time.
Source : http://itmanagement.earthweb.com/img/2011/01/refactoring.jpg

No comments:

Post a Comment