Minimal

stressed for motivation and achievement

2004-01-22

 

Test-Driven Development and mock objects

At work, we’ve recently moved to agile development methods and generally updated our practices. One of the things we’ve adopted is Test-Driven Development (“TDD”). From the things I’ve read and heard about it, you’d think it’s some kind of panacea, not only improving quality assurance, but also improving your code design.

From what I understand, TDD promotes highly-cohesive, loosely coupled designs — things we were taught to strive for at university, but which I’ve rarely created. Now, it’s really happening, but there was an uncomfortable hurdle to get over first. As with so many things that are evangelised, the downside of loose coupling was never really addressed.

From my experiences, loosely coupled classes tend to mean an increase in the amount of setup code you have to write in order to use them — setup code that has to be repeated everywhere you use the class. Such repetition is often cited as an evil thing elsewhere, so it seems to me that TDD is not without its downsides.

I still believe there are more pluses than minuses, mind. I’m now in a position to write automated unit tests and to use mock objects to keep an eye on the collaborations of the class under test. It’s a wonderfully reassuring safety net that I’ve never had before and there are many more benefits beside that. I just wish the evangelists of TDD were a little more open to acknowledging the trade-offs you would be making by adopting it.


Comments: Post a Comment



<< Home

Archives

April 2002   May 2002   June 2002   July 2002   August 2002   September 2002   October 2002   November 2002   December 2002   January 2003   February 2003   March 2003   April 2003   May 2003   June 2003   July 2003   August 2003   September 2003   October 2003   November 2003   December 2003   January 2004   February 2004   March 2004   May 2004   June 2004   July 2004   August 2004   September 2004   October 2004   November 2004   December 2004   January 2005   February 2005   March 2005   April 2005   May 2005   June 2005   July 2005   August 2005   September 2005   October 2005   November 2005   December 2005   January 2006   February 2006   March 2006   April 2006   May 2006   June 2006   July 2006   August 2006   September 2006   October 2006   November 2006   December 2006   January 2007   February 2007  

This page is powered by Blogger. Isn't yours?