A Beginning Developer’s Experience With TDD

Article summary

test driven development cycleAs a summer intern at Atomic Object, I’ve learned a lot about Test-Driven Development (TDD), a practice that Atomic uses heavily. I’d used TDD in one college class, but it wasn’t really explained; we just sort of used it without knowing exactly what was going on.

On my current project, we’ve been using TDD a lot, and learning the process has been difficult. But the more I test code, the more apparent it becomes that TDD is great way to ensure you’re getting the behavior your want from your application.

Why TDD?

TDD helps me understand what my code is doing.

One of the things that I noticed about myself before working at Atomic was that I wasn’t always sure what my code was doing. Using TDD gives me much better insight into how the code works together and enables me to think more clearly about what my code is actually doing.

When I write a test, I have a clear indication of how I want my application to behave. Once the test is written, it’s easy to write code to make the test pass. With TDD, I know that once my test passes, my application is behaving as I expected it to (providing my tests are written correctly).

TDD requires me to learn new testing frameworks.

In order to develop an application with TDD, you will need to learn some new testing frameworks for the language you are writing in. I have recently become a lot more familiar with Cucumber, RSpec, and Mocha. These new frameworks have allowed me to think about my applications in new ways.

Prior to using TDD, I used a lot more trial and error and print debugging. With a testing framework, there is little need for that; you are able to control the behavior of the application based on how you write you tests. In most cases, the testing framework will also be written in the language that you are testing!

TDD helps me to learn new languages faster.

Now that I am using TDD to help drive my applications, I find it easier to get ramped up on languages I am not familiar with. When I started at Atomic Object, I had only written one small Ruby on Rails application. In fact, I was part of a small team that worked on the project, so I didn’t have a full understanding of what was going on.

Since starting with TDD, I have learned more about not only Rails, but Ruby as well. As I mentioned before, most testing frameworks are written in the language that you are testing, so learning the language tends to be faster. One of the things that I noticed about getting up to speed quicker is refactoring. After refactoring, I have been through the code a few times, and I usually pick something new up from the language.

TDD helps me to be fearless.

Software work can be very intimidating, but my Atomic peers have encouraged me to become fearless when coding. And I’ve noticed, more and more, that TDD is making it happen. Because I have written tests for my application, and I know exactly how the application is behaving, it is much easier for me to jump in and make a change without fear of breaking the application entirely.

Conclusion

Using TDD for the summer has taught me a lot about myself and my ability to program. The best way to overcome the obstacle of learning to TDD is simply just to get out there and use it. As for me, my experience using TDD has been great. As I continue my journey as a developer, I will be testing all of my code!