Outside of the realm of college, coding bootcamps, and apprenticeships – how often do we practice our craft?
We code every day at our jobs, so essentially we’re getting in a lot of practice, aren’t we?
We can get our code to run, maybe after a few inevitable hiccups, but in the end it works. We are confident we can get the job done.
Given the mental drain of our daily programming tasks, adding in the commute traffic, and then coming home to chores and our kids’ homework – it doesn’t seem necessary (or even possible) to commit to any more practice.
We want to TDD our code, but test driving still feels difficult. It just doesn’t seem to translate well to daily work after going through a FizzBuzz kata. We’ve solved FizzBuzz once or twice, sure, but now we need to run through different client scenarios and it all seems overwhelming. Can’t I just write the code?
I have gone through the FizzBuzz kata more times than I can count. It seems almost second nature now, starting with the absolute tiniest test case and letting the code grow while being driven by each subsequent test.
It’s that second nature that helped me with the more complex problems.
It’s that second nature that stopped my head from spinning when we needed to code for 5 different scenarios.
We started with the absolute tiniest scenario, wrote a test for it, and wrote the minimum code to get the test to pass. We wrote more tests and it evolved. In minutes. Since we knew we were covering our code with tests, we gave ourselves a subconscious permission to have bare bones code. We knew we would have everything we needed in the end.
When we find TDD or refactoring difficult, it’s worthwhile to practice katas. I’ve heard the kata criticism: “I’d rather have someone who’s coded 100 websites, not someone who’s written the same code 100 times.”
We can have two people, both attending the same gym. The first person shows up every day for 3 hours. In those 3 hours they go through every kick and punch imaginable, exhausting themselves. They want to get as many swings in as possible to prove to themselves that they practiced. The second person shows up at the gym for 30-60 minutes a day. He checks his stance, and sets into practice. He may only focus on 2-3 moves that day. Each time he gauges himself and focuses on form and preventing injury. He pivots his hip on the swing and makes sure his wrist is in the proper position. He works on his reflexes. He follows the advice of his mentors.
Who do you think will last longer? Who do you think has the better form? Who do you think has the least chance of hurting themselves?
We struggle to find time for exercise and realize that if we woke up just 20 minutes earlier, we can develop a habit that enables us to exercise 100-140 minutes a week. Not a bad start.
The same should go for software, and yes, it’s difficult. As software developers, we have confidence that we can eventually get our code to work. We know how to get code on the screen. Once we’re thrown into an environment of deliberate practice (covering our code with tests, recognizing when our code smells, refactoring, etc.), we sometimes freeze. It’s even more difficult when we’re surrounded by our peers. We suddenly look like we don’t know what we’re doing, and that’s ok – it means you’re in an environment where you can grow.
Commit to real practice, take a breath, and watch your form. Be ok with the struggle.