Thursday, August 2, 2018

Adopting the TDD Mindset by Altering Habits

Previously, I wrote that test-driven development is a mindset, more than it is a skill. It's easy to learn but it's difficult to adopt because you have to change how you see and think about software development.

One way to modify your worldview is to form an habit and allow that habit to gradually transform your perspective. That's exactly how I made my transition to being a test-driven developer.

Initially, I decided I was just going to write a test before I wrote any "real" code. I made this commitment with the understanding that it would occasionally require a minor act of willpower. It would be a matter of discipline.

After a few months of doing things a certain way, it was more than a discipline. It was an habit. It wasn't something that I did because that's the way I felt it should be done. It was just something I did because that's what I did the day before.

Years of habitually-test-driven development gradually reformed my mental model. As time passed, software development and test-driven development merged into a single concept.

At some point, it stopped being something I added to my process, or even how I wrote software. TDD and software development became synonyms, in my mind. There was no question and no contention between forces.

Now, I can barely imagine doing things a different way.

There may be other ways to change your mind. There may be better ways. This one took time, patience, effort, and willpower, but it has one advantage of which I am certain...

It worked for me.