|
|
||
William C. Wake's BlogMay 2004 ArchivesRefactorings require new testsPosted by wwake on May 31, 2004 at 05:19 AM | Permalink | Comments (0)Someone asked on the XP egroup about getting access to private methods for testing purposes. Others suggested a number of ways to get this effect, but it got me thinking about refactoring. Refactoring is often thought of as a pure, safe transformation: convert a program into another program with the same semantics but a better design. From the standpoint of a refactoring tool, the "same semantics" part is crucial. But refactoring also has a psychological side: a better design, but also a different design. A different design may induce people to act differently (indeed, that's why we do it!). In particular, a different design may give people different expectations about code. Following are some examples. In each case, I'll assume the code was created by test-driven development, and adequately tested before the refactoring.
Scratch RefactoringPosted by wwake on May 12, 2004 at 03:54 AM | Permalink | Comments (5)I recently had a chance to do some refactoring of some Visual Basic code. I hadn't worked with it in several years. In particular, I hadn't worked with the object support that's in VB.Net. It's very striking how much it's like C# with different keywords. My task was to convert some code from using web services (which were too slow) to just straight object code. Several factors came together:
This led me to do a scratch refactoring: refactoring with the intent of throwing it away and re-doing it. I refactored away two sets of web services, writing down each of the changes I intended to make (along with the name of the affected file.) I found several benefits:
I think it was Brooks who said something like, "It's faster to make a 6-inch mirror and a 10-inch mirror than it is to make a 10-inch mirror." I found that true in this case. | ||
|
|