One of the practices in PaD is
?Feeling the Rhythm.? In Agile Development, we keep up with continuous
improvement and activities rather than episodic activities. Recently, a few developers
asked, "when?s the
right time to write unit tests?"
One developer who was sold on test first development asked if he can write all the
tests for a module
before implementing the module.
Another developer who was concerned about time to write the tests asked if he can
write the tests after
completing substantial work and showing progress.
Think of your code as your left foot. Think of your unit test as your right foot.
It really does not matter
which foot you put forward first. However, when taking a nice walk on the beach, you
wouldn?t let one
foot take a mile walk before dragging the other foot to catch up. To keep your balance
and make the
walk pleasant, you follow a rhythm, placing one foot forward and following it with
the other foot within
safe and comfortable distance.
I like to first place my right foot forward; I start by writing a little test for
a piece of code. Once that is
ready, I implement the code (putting my left foot forward now). The code I am writing
shows me that
there may be some boundary conditions I may have to check or some negative tests I
may have to write.
So, I then go off to write some more tests for my code.
In following such a rhythm, writing code feels like a pleasant walk on the beach?