TDD is like cooking (haha)

I want to make a comparison between my cooking, and my TDD. I started learning how to cook about the same time when I started learning TDD.

Let us discuss the leek soup I made loads of times 🙂 The first time I made it I did not look at any recipes, I just followed my heart. It was awesome, tasted very good! The second time I made it, it was almost impossible to eat and I was wondering what happened. It was horrible. But I did everything almost exactly the same?
Then I started looking into the recipes and found that some things should be added to a leek soup and some not. Some spices are needed in a leek soup, some should be avoided. The ratio of water, leeks, butter was also a very important thing. Slight variations in those thing could make the soup very good or very bad. After following the recipe several times for couple of different soups I started to see the patterns. Even though I have still a lot to learn, I know a bit more how to make a good soup without a recipe. I just can see if it is going to be the kind of soup I like just by looking at the ingredients!

It more or less looks like I am in the third stage of competence when it comes to preparing a leek soup 😉 haha

How did I get there? Using the tool called “recipes”!

How can you get to the next level of competence in software development? Using the tools and practicing as well. The best tool I have found so far is called TDD! Once you are competent you probably will not need the tool, you will just “feel” when something is good or not, you might find that it acctualy slows you down. But for beginners, TDD is in my opinion a very good way of working. Following the very simple rules of TDD allows you to unconsciously produce code that is more likely of high quality and compliant with the harder to understand rules of high cohesion and loose coupling. Following the very simple “red-green-refactor” and “test should be simple” rules is more likely to produce code that is compliant with the harder to understand (or easier misinterpret) SOLID rules, etc.

P.S.
The next tool I would recommend is pair-programming.

P.S. 2

I have just finished reading the new book by Robert C. Martin titled “The Clean Coder: A Code of Conduct for Professional Programmers”. Highly recommended! 🙂