In his book Kent Beck beautifully explains how TDD addresses the goal of every programmer: "Clean Code That Works".
Although it’s the goal of every programmer; there is always a dilemma.
There are two ways to achieve this:
- I'll write a clean code first; then make it work later.
- I'll write a working code first; clean it up later.
Problem with first approach is; it leads to design that is unnecessarily complex & rigid.
By the way; what's use of clean code if it doesn't work!
The second approach "clean it up later" never happens.
We go on adding code; but never refactor. More we postpone it; more & more it becomes difficult to refactor.
It becomes an ever growing Technical Debt; that at some time becomes impossible to repay. It can potentially reach a state where one has no option but to close the shop.
Look how TDD helps to solve this problem:
TDD goes in iteration : RED - GREEN - REFACTOR- RED bar gives us reason to write a code.
- After GREEN bar; we have a working code; but that may be dirty.
- During REFACTORing we clean up the code.
So at the end of every iteration we have Clean Code that Works!
And these iterations are matter of minutes. RED - GREEN - REFACTOR really gives a nice rhythm while writing code.
---------------------------------------------------------------------------------
There is one parallel:
There are two schools of thoughts:- (1) Capitalism and (2) Communism
Communism says equality should be first achieved in the society; then we should make further economic progress.
Capitalism says we should prosper first; then we can make things equal (or cleaner).
Everyone shares the dream of prosperous society, whose structure is fair. It's just the matter of what comes first.
However; it doesn't happen with Capitalism. Rich become richer & poor become poorer.
But there is problem with Communism as well. If we don't prosper what to do with equality?
Kent has solved our dilemma in programming.
But it seems this problem is still unsolved.
This is quite disturbing. Isn't it?
Any views?
Any views?
Hi Manoj,
ReplyDeleteInteresting leap of thought!
Take a look at Gandhi's Trusteeship philosophy. Looks like Bill Gates and Bono are trying to practice this somewhat.
Happy coding!
Ashok