One step at a time, and be explicit

My father is a maths teacher, he trains individual students to get higher marks with personal lessons. When he helped me from time to time I remember his main advices:

  • always proceed step by step, and never skip a step, never jump to the result even if it seems to be obvious
  • always write in correct readable sentences what you do and why you do it, in addition to the formal maths expressions

I trusted him because these advices have proved to be successful to many students, including me.

Now I realize that these advices are also quite relevant for programming. “One step at a time” rule (cf. TDD)is fundamental to tackle anything even with low complexity. For me this leads to simple rules like One loop per method, and obviously only one responsibility per class and only one task per method. “Write what you do in readable sentences” is also fundamental to name classes and methods with the intent to make everything explicit.

The reasons for these advices in maths are the same in programming. If you skip a step or jump to the result, you have a real opportunity to introduce a mistake, or to be even completely wrong; also, if you do not explain in a readable sentence what you do and why, you may really not get the mark you deserve just because the teacher is not sure of what you did.

For instance, when you factor an algebra expression, if you skip a step it becomes very likely to introduce a mistake like misreading a parenthesis, and that is the same when you write a method implementation. When you have to deal with a maths serie, you really should start to expand manually at least the first three terms, it often tells a lot on the serie and then you can generalize with much more relevance; if you don’t you may take the wrong track from the start… It is the same when you start analysis of a domain, before you can have the correct supertypes you may need to look at the details of at least three concrete types, your analysis will gain relevance.

It is common mistake to think that following these advices makes the work slower. At school I’ve always noticed that many very good students were not that fast, but everything they did was just correct and explained, so they just strongly accumulated score, even if they were not able to finish the problem. On the other side, if you work precipitately you may finish the exercise, but your score will be bad anyway if there is a mistake somewhere..

Initially published on Jroller on Wednesday April 27, 2005


Software development, Domain-Driven Design, patterns and agile principles enthusiast