Skip to main content

Scratch Refactoring

Posted by wwake on May 12, 2004 at 3:54 AM PDT

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:

  • My unfamiliarity with VB.Net and web services.
  • The fact that I was heading out of town for a week and didn't want to risk leaving problems.
  • The team's use of source control which locks checked-out files. (I'm lobbying to change this.)
  • A desire for extra care as the product has almost no automated tests.

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 learned some little tricks for how to get the compiler to tell me what needed doing.
  • Knowing I would throw the result away let the scratch refactoring go more quickly.
  • I learned a couple tricks for the IDE.
  • When I came back after my trip (to do the real thing), I felt like I was just flying through the changes.

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.

Related Topics >>