Dot Net Tricks

Articles about .NET, ASP.NET, C#, Object Oriented Programming and Agile Methodologies
Welcome to Dot Net Tricks Sign in | Join | Help
in Search

Software Theosophy

TDD + Resharper = Refactoring Payoffs

So the project i mentioned the other day in my last post has had minimal need for refactoring.  Part of that is because I'm such a super badass developer who always gets things right the first time (yeah right), and part of it is that the project is small enough and young enough that there isn't need for massive changes yet.

But today, there was some stuff that had been bugging me, so I decided to do some cleanup, aka refactoring.  Specifically:

  • I changed the names of 4 classes.
  • I changed the names of a bunch of interfaces for the above classes.
  • I changed the name of a persisted property.
  • I changed the field in the database for that property.
So I made these changes and Resharper took me 50% of the way there towards keeping my existing functionality intact.  It renamed all the references, strings, my NHibernate XML Mapping files, dictionary names, and all sorts of things.

But then I ran my unit tests.  I found all kinds of things broken from the refactoring.  Within minutes i had all this fixed and working properly.  Finally I had to do a quick regression test thru the web layer, and found a few things here and there that had to be fixed.  This was only necessary because I haven't really tried creating Unit Tests for my Views, although apparently other people have.

In another, testless, project this would have taken a lot longer, in the realm of a few hours instead of only minutes.  But this was only a small project that i've been working on and off for a few months.  Imagine something on the scale of a 6 month project or a 2 year project with multiple developers. 

I'm starting to get hooked.  TDD hasn't really started to pay off until now.   If you care about refactoring, you owe it to yourself to really try TDD.



Published Thursday, December 11, 2008 5:36 PM by Fregas
Filed Under: , ,

Comments

No Comments
Anonymous comments are disabled

About Fregas

Craig is currently the Lead Developer in Fort Worth, Texas for Enilon Group, a web development firm. He has been programming since 3rd grade (using the Commodoore PET) and professionally for the past 7 years. He has written several articles for ASPToday.com and co-authored the book "Beginning Web Programming using VB.NET and Visual Studio .NET" Currently, his favorite programming language is C#, but he has programmed in Visual Basic, T-SQL, Ruby, ColdFusion, ASP 3.0/VBScript, ASP.NET, Javascript, Java and even Pascal. Besides programming, Craig is best known for his cooking and his somewhat offbeat sense of humor.

This Blog

Post Calendar

<December 2008>
SuMoTuWeThFrSa
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

Syndication

Powered by Community Server, by Telligent Systems