>A DOH! moment

>Update 2009-01-01: The first refactoring is done and attached to bug 259853. There is still more to do to break up some overly long methods, but it is now easier to test the various pieces.

I have been working on some refactoring of the current XML formatter code. It’s taking a while to break up a roughly 2000 long line Class, but it’s going well. The reason for the DOH moment was when I started running into having to apply the “Replace method with Method Object” refactoring on some of the various format methods in the code. I started getting away from running the unit tests and just kept doing the Replace Methods to get things to compile. I had been working on this for a day and half, and hadn’t run the tests. As I was getting compilation errors, and figured I needed to clean that up. I eventually, realized, that even if I did get all the compilation errors cleaned up I would have no clue as to where any unit test failures would have occurred.

So, I scrapped everything, and replace my content with the last known time I had run the unit tests again, and proceeded again. It’s a good thing too…as soon as I did the first Replace Method with Method Object refactoring an ran the tests, they failed. I had forgotten to make sure that the Preference settings that had been set earlier were passed to the new method object. So I fixed that, and all the current tests passed. Since I hadn’t even run the tests before doing these type of refactorings and I had done many of these in a day without running tests, it would have been a night mare trying to figure out what wasn’t working.

Uncle Bob’s latest post on Fudge anyone, reminded me of my own situation a bit. I like the morals he came up with:

Moral #1: Fudge tastes good while you are eating it, but it makes you fat, slow, and dumb.

Moral #2: Eat the damned dog food. It’ll save your posterior from your own maladroit decisions.

Particularly, I agree with Moral #2, use what you write in your day job. Ideally, if you work on an editor use that editor in your day job. You are more likely to fix things sooner if you are directly affected by it. It’s why XSL Tools has become my primary XSLT Editor, it forces me to address the issues that affect my own use everyday. It’s why JDT is such a good editor for Java development in eclipse. The JDT team uses it themselves to develop eclipse. The same goes for PDE.

This entry was posted in eclipse, refactoring, xml. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s