This post originated from an RSS feed registered with Agile Buzz
by Mark Levison.
Original Post: Advantages of TDD
Feed Title: Notes from a Tool User
Feed URL: http://feeds.feedburner.com/NotesFromAToolUser
Feed Description: Thoughts about photography, software development, reading, food, wine and the world around us.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by Mark Levison
Latest Posts From Notes from a Tool User
Advertisement
During last weeks TDD Randori session I was asked, what are the advantages of TDD. Here is my short list:
Writing tests first require you to really consider what you want from the code
Short feedback loop
Creates a detailed specification
Reduced time in rework
Less time spent in the debugger and when it is required you usually get closer to problem quickly
Tells you whether you're last change (or refactoring) has broken previously working code
Allows the design to evolve and adapt to your changing understanding of the problem.
Simplification
Forces radical simplification of the code - you will only write code in response to the requirements of the tests.
Forces you to write small classes that focused on one thing.
Helps create loosely coupled code
Creates SOLID code (Articles: Bob Martin and Chad Myers )
The resulting Unit Tests are simple and act as documentation for the code
Improves quality and reduces bugs by:
forcing us to consider purpose (and the specification of code)
simplifying code (many bugs come from the complexity)
ensuring changes and new code doesn't break the expectations of existing code
Disadvantages? TDD is hard to learn, especially on your own. You can expect reduced productivity for 2-4 months after starting.
Other articles that discuss the benefits of TDD: Twlelve Benefits of Unit Tests , Research Supports The Effectiveness of TDD , TDD Research Findings , How TDD improves development speed and is very cost effective , Test Driven Development Requires Less Debugging , The Benefits of Test-Driven Development
Finally as I stated at the time I believe that these benefits can't be achieved by writing tests after the fact.
Next up will be a short item outlining a one possible TDD adoption strategy.
If you enjoyed this post, subscribe now to get free updates.
Read: Advantages of TDD