Last weekend I spent some time helping my 13 year old son with his math homework. He had to simplify/rewrite some expressions such as:
This is how he solved it at first:
So, being the teacher that I am, I taught him to do it like this:
That made him think and he resolved to start writing his sums like this:
And that made me think. The answer was correct. All the steps involved too. But I smelled something bad in this solution. Originally when he was learning these sums, my son wrote the long version of his sums but after a while dropped the habit because he found out he could do without. He then wasn’t able to find errors and correct them, so I told him to write the extra steps which made him assume that more steps were better and that more steps would please me and his teacher.
This morning I discussed Test Driven Development with my colleague Paul and we talked about TDD adoption by developers. Many times developers start out well-motivated and writing tests first but as soon as pressure, deadlines and boredom show up they drop the habit and write their tests afterwards to satisfy coverage requirements. Like my son they make a capital mistake.
The extra steps and Test First are not to satisfy the teacher or coverage requirements! They are there to help you think and solve a problem in a controlled way. Writing tests is not a “nice to have”, an extra; it is the way to solve a problem. The coverage requirement and the math teacher are not interested in those lines. All they want is to guide you into a correct, effective way of solving a problem.