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.