If you don’t know where you’re going… how will you reach your destination?
January 17, 2022
Blog > Development, TDD | Valentina Cupać
If you don’t know where you’re going…
… How will you reach your destination?
If you don’t know exactly what the requirements are…
… How will you implement the requirements effectively?
If you don’t write tests for the requirements…
… How do you know what’s the precise condition of “Done”?
Logically, from a goal-oriented perspective:
0. Start off with a goal, written in human language (the REQUIREMENT)
1. Express the requirements in a more precise way, written in code language, as executable specifications (the TEST)
2. Do the minimal amount of work to satisfy that goal (i.e. implement minimal / simplest code) and run the TEST to confirm the solution works
3. Stand-back, see if there’s a better solution, implement the improved solution (i.e. refactoring) and run the TEST to confirm the solution still works
But wait….
This sound like common sense.
It sounds so simple.
It sounds so logical.
Yes, it is.
Welcome to TDD.
– MACRO level: In software, the overall destination may not be fully known, and the path to the destination may also be unclear. So at macro-level we’re making big guesses both about the destination and the path to it
– MICRO level: However, to move forward, given the uncertainty, we nonetheless have to concretize, we have to choose some direction, some action. This concretization is in the form of requirements, converted to tests. “Creating a unit test helps a developer to really consider what needs to be done. Requirements are nailed down firmly by tests. There can be no misunderstanding a specification written in the form of executable code.” https://lnkd.in/eY7EqWeR
– At the MICRO level, we are moving in small steps, one test at a time. The test verifies helps us verify whether our code meets the requirements.
– However, at the MACRO level, e.g. when we release the system to users, we get validation about the overall direction that we’re moving in, and get feedback whether to change direction
The steps outlined in this post are at the MICRO level (requirements -> tests), but the MACRO overview is covered in the subsequent post about complex systems…
See the follow-up post TDD & complex systems