Short feedback loops
A feedback loop in learning is a cause-effect sequence where data (often in the form of an ‘event’) is responded to based on recognition…
A feedback loop in learning is a cause-effect sequence where data (often in the form of an ‘event’) is responded to based on recognition of an outcome and that data is used to inform future decisions in similar or analogous situations.
Some days ago I was working on the Bowling Kata because I wanted to use it as an example of Evolutionary Design. I started reading it and I understood the rules small different from they are explained here, it was the very first time I did the Kata.
I have gone bowling with friends, but I didn’t understand very well how the punctuation works and so on. Apart from that, I’m not a native English speaker, so sometimes I didn’t get so well English.
The important part here is that I thought I understood the rules pretty well. So I started creating my tests and solve them, step by step. I was thinking during the development in each small step and finding the solution alone.
Some hours later when I thought the Kata was done I thought that a good idea to show that the program was completely correct was creating a test for a perfect game. I was pretty sure everything was fine because I did TDD and all my tests were passing. I found on the internet the perfect game punctuation, 300. So I created a test to see if my program returns 300 for a perfect game and the result was not 300.
I was thinking that probably I just committed a simple mistake and I could solve it easily. Some hours later trying to understand what was the problem I decided to read carefully the definition of the problem (you know, you cannot accept you fail).
I had understood that the bonus for spare was the punctuation of the next frame, but it was the punctuation of the next roll. I wanted to kill myself (it’s stupid I know because it was just a Kata). The same happened for the squares. Once I understood the problem I thought on two possibilities:
Try to fix the current solution with my current design.
Start again with the kata.
I selected to start again because at the end I have no pressure for having the post done, it was just because I wanted, but I was felt very frustrated because of my time lost. Probably in another scenario I would try to fix my creation.
The interesting point here is that I was able to do the Kata again with all the things I’ve learned much faster because I learned a lot of things doing the Kata about the problem. But the total time to do it was much more than doing it right the first time.
The problem
After I wrote the blog post I was thinking on what was my mistake. I realized that my mistake was trying to obtain external feedback at the very end of my development (long feedback loop). I just tried to verify that I was solving the correct problem when I was finished.
How could do I obtain that feedback earlier to avoid to start again from scratch. The first thing that comes to my mind was pairing.
If I was pairing with someone else we would have more opportunities to find my misinterpretation at the moment we were working with bonus (short feedback loop).
This does not mean it was going to be 100% sure that we did not commit the same mistake, but we would multiply by two the possibilities to find the bug just when the bug was created not some hours later when everything was based on that bug.
Diversity and effectiveness
But also I was thinking on those possibilities to find the bug, is it different if that person has the same knowledge about bowling than me or not?. If the other person has more knowledge than me on bowling we have more opportunities to find the bug earlier.
And here I realized one of the reasons why to have people for different backgrounds is better for a company, why diversity is an advantage for companies.
Imagine if my pair is a native English speaker and loves bowling its impossible to commit my mistake. How many situations can you have on this during your work, probably a lot. So as much diversity you have in your company more possibilities you will have to find bugs earlier.
Pairing VS Code reviews
Why I usually think paring is better than code reviews?, this is one of the reasons. Code reviews feedback happens at the end (in this case should be when I executed the test for the perfect game), when the developer thinks everything is done.
Do you think you would decide to start again from scratch or did you spend more time to fix the bug?.
I don’t have numbers, but my first feeling should be trying to fix the bug with the current code. This normal behavior will produce to reuse the design I created for the other problem (the one that does not exist), is this the best design for the real problem, or I’m just creating a mess?.
I will answer myself, in general I’m adding complexity just because my feelings forced me in that direction. I’m creating a mess.
Even if the reviewer thinks I have to change the design I will try to push him in another direction because I spend a long time working on this solution. The possibilities to find the best solution are less doing code reviews than working both together from the beginning (pairing).
Pair programming tends to create better designs than code reviews just because it is a shorter feedback loop.