I’ve changed some of the language in this post as it was previously appropriating Japanese culture. Here’s a post I wrote about the change.
Test driven development can be hard to learn and requires a lot of discipline to continue as a practice. There are books for learning TDD and they are good but they are also old and can be hard to approach given that learning styles for coding have shifted away from books and more towards the online, the interactive and the overflow.
Books and resources aside, TDD is a vast shift in headspace and it takes time to re-wire the brain for this. We tend to overload our brains these days, throwing huge chunks of delicate, detailed information at it in great one-time lobs and then wondering why nothing sticks. Kathy Sierra, in her talk, Making Badass Developers, takes this apart and submits that we need to reduce cognitive leaks by feeding new information to our brains in much smaller pieces.
In the writing world, my favorite writing teacher suggests to students who are having trouble getting words on the page that they write for 5 minutes a day, every day. After 5 minutes is up, stop and go no further.
Lately, I have found that this applies to TDD as well if you practice. TDD has its own exercises for practice. These exercises, very commonly, are sets of requirements published online in various places by various authors that guide you through testing first. The trick is that if you are learning TDD, you should only work on them for 15 minutes a day. Breaking up the practice into short bursts allows the brain to build new neural pathways day after day.
This is how you build a practice. That practice is important because TDD is most effective if you can stick with it even when coding is stressful. Because we are human, when we are stressed we fall back to whatever it is we have practiced the most. This is when it is hardest to stick to TDD but this is also when sticking to TDD can save you.
If you try learning with exercises, give yourself a month and focus on one of them for 15 minutes a day. Once the month is over, it’s ok if you didn’t finish or you dropped off. Give yourself a fresh start at the beginning of the next month with another exercise.
As an example, I’ve completed the Greeting excercise and just finished up the Calculator excercise. I didn’t finish all of the requirements in the Calculator one, but decided to stop after a month because I got what I wanted from it and felt like I’d spent enough time with it.
Some TDD Excercises
Thanks for the excercise recommendations from Yitz Schaeffer a.k.a. @yitzofthebitz and Chris Hartjes aka @grmpyprogrammer