
13th June 2008 by
Chris
It has long been a debate on how to describe 'good code'. What are the criteria for declaring a code to be good, neat, and dry?
My advocacy is to promote writing good quality code. It is by painstaking practice and tons of reading that I get to exercise this advocacy. It is but a long journey, but little steps lead you to understanding and qualifying a code to be of high quality. So what are my benchmarks?
- Long codes are less readable and more likely to fail.
Ruby scripts are far smaller and more compact in size compared to Java codes or C++ codes. Trust me, I've seen some and comparing them to Ruby, reading Java codes or C++ codes that are not mine would take me a longer time for understanding (even if docs and other help materials are present). Ruby has good metaprogamming (that sometimes gets abused because of monkey patching) and produce straightforward codes. Each line would end up more like real English sentences.
If you write ruby codes that take up to more than twenty lines.. hmm.. well, its doomed to fail, for sure.
Refactor and review!
- Codes that don't look anything like its API source is really smelly.
APIs are there for you to use as a general sitemap. It is your guide to efficiently write code with ease. Usually, APIs are well documented and even provide examples or snippets of codes to demonstrate its use. The lines of codes involved may also be present for you to inspect its process and even predict if it will pass your expectations.
Read the rest of this entry