TDD: A Safety Net For The Future

30 Jun

Test Driven Development (TDD) is like exercising. It’s a lot of work, and you don’t see the results day-to-day, but you’ll be thankful you did it a few months later when you suddenly have rock-hard abs.

I was learning rspec, the Ruby testing framework, this week at Dev Bootcamp, and it really wasn’t that bad. The rspec syntax is pretty simple, and using it forces you to really think about every line of code that you write.

I also ended up refactoring a lot earlier than I usually do (RED => GREEN => REFACTOR!), which made my code A LOT cleaner right from the start. It actually put me more in touch with the DRY (Don’t Repeat Yourself) Ruby mantra, as I was obsessed with not repeating myself both in my production and test code.

While it might seem almost unnecessary to use rspec or another testing framework (Jasmine is the JavaScript one!) for small projects, it’s important to realize that small projects can quickly become big and complicated ones in the future.

This point was really drilled into us by the founder of Dev Bootcamp, Shereef Bishay, when he told us that he lost three years of his life because he didn’t do TDD. When Shereef started his previous company, BetterMeans.com, he wanted to get his product out as fast as possible, so he didn’t do TDD.

However, as he kept adding more and more features, the project became unmanageable to the point where he was afraid to add any more code, because every time he would add something, something else would break. In addition, as BetterMeans was getting more and more popular, he would get emails from developers who wanted to contribute. But as soon as they looked at the code, they were overwhelmed and were no longer interested.

The hardest thing about TDD, just like with exercising, is getting into the habit of doing it. I’m starting this habit today.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s