Editorials

Perfect Code Day 2

When it comes to writing perfect code, it seems Aaron and I have the same opinion.

Aaron writes:

If have two options;

  1. I can write an easily readable and understandable test over a longer piece of code.
  2. I cannot write an easy, readable test but the actual code would be shorter and more concise.


Under most circumstance I will choose option number 1 above because code coverage is something I value higher than saving a few extra keystrokes. When my code is under a suite of tests, I am a much more confident and relaxed developer. When my code is not under test, there is always a nagging feeling that it may not work exactly like I thought it did. Also, I’m less inclined to go back and rework code if there aren’t tests on it.

Based on my experience, and some support here from Aaron, I would consider code that can be tested to be more desirable that the conciseness of the syntax. I have to admit I am a strong advocate of testing, no matter what. It has saved too many projects for me to ignore.

So, write your perfect code. Make it testable, Make it concise. Better yet, make it something others will be able to understand in the future.

Cheers,

Ben