So tomorrow, Independence Day, is a pretty significant holiday. But I’m not writing about that right now — I’m writing about July 3. So happy July 3 to you all!
The day was pretty uneventful, really. Work-wise that is. I’m currently working on refactoring some code that, by and large, hasn’t been touched short of bugfixes and minor enhancements for about three years now. And I find myself running into an interesting situation related to refactoring.
Before I get too far into this, I should note that my primary goal in refactoring is not to make it to the Nth level of Extreme Programming, but rather to clean up and reuse code bits as much as practical, namely with the intention of cleaning things up and making the maintenance process easier down the road.
My situation is related to the practicality. My XP (Extreme Programming) ‘training’ of sorts allows me to see all kinds of options for refactoring and in a way ‘centralizing’ code snippets. My lazy ‘training’ allows me to look at several of the same bits and determine that less than 25% of those items will actually be refactored.
Why is this, you say? Interesting question. It all boils down to practicality. Since most [event] things in the application are not terribly complex (they’re driven by the user’s button clicking), there are many, many places where these things can be refactored. An excellent example is the ‘New Record’ button. Most of these buttons do the same thing. I find myself demanding that I combine these tasks into one main procedure, then call that procedure (in one line of code) with the appropriate arguments for customization. However, my practical/lazy side looks at the code to be replaced and determines that for each New Record button in a particular part of the application, there are only three lines of associated code. That’s a net reduction of two lines by putting in the additional effort. Good, eh?
Again, one of my goals is to make future maintenance easier and also remove duplicate bits of code. In this particular case, a character-count comparison of the reduction in code (from three lines to one, considering that I have to now pass arguments to a centralized procedure) is much less impressive. By going that far in the refactoring, we would be looking at a net gain of approximately 10-25 characters. This ultimately cleans things up a little bit, but the net effect on the code itself is pretty much a moot point. We’re not going to be reducing the size of the [compiled] binary by much at all, and considering that there are so many customizations that need to be made (which, refactored would be in the form of additional arguments), our net benefit (aside from having one master location where this code can be changed) is nil. At least if you ask me. Especially because we’re not doing major calculations or anything fancy. We’re putting a recordset into Insert mode, setting the cursor focus, and calling the routine to handle the GUI changes (enabling the save and cancel buttons, for example).
So I came to the conclusion this afternoon that anything less than five lines in nature will likely not be refactored unless it’s incredibly duplicated (only requiring an argument or two, not one for each line reduced). It goes against everything XP I have ever learned, but really, we’re talking about something similar to exclusively designing a database in fifth normal form when we suffer no problems with using fourth normal form. That’s not a terribly good example, but my point comes down to practicality. Sure, a database closely adhering to a high level normal form is fantastic for several reasons (and in our databases, I try damn hard to make sure it’s as normalized as can reasonably be), but there are times when those additional steps no longer ‘buy’ you enough to justify the additional time and/or resources.
Now, that said, I managed to quite nicely refactor several bits of code, and throughout the next week should be able to clean things up pretty well (at least to reasonable satisfaction). So that’s a Good Thing.
As a follow-up to a previous post, I switched my development environment’s color scheme to be white (or colored) on black. Just for grins. It was the afternoon, after all.
While I’m not convinced quite yet that I like the color scheme I’m working with, the change very quickly allowed me to pick out bits of code that I’d likely have overlooked in the black-on-white environment in which I’d previously been working. That really wasn’t all that surprising to me given my previous experience. But it’s amazing what a significant difference in color schemes can do to one’s perception. So I’m going to keep with this for a while (likely tweaking some of the foreground colors in the process) to determine if I like it or not for the long term.
Anyway, my real topic I intended to write about today was related to Kirstin. She had a doctor trip today…namely because she’d not had what I lovingly refer to as a ‘shit event’ for nine days. That’s right — baby girl was a little on the constipated order. She really seemed not to be experiencing any adverse affects of this problem (she wasn’t acting as though in pain or under any sort of strain), but nine days between movements in a symphonic arrangement is a bit much.
Long story short, a quick exam determined that nothing seemed to be out of order and some general suggestions were made for how to ‘speed up the process.’ Well, as of 11PM tonight (her appointment was at 1:30PM), we’ve had three such ‘events,’ and I believe that we’re on our way to ‘all systems normal’ again. So that’s good.
Anyway, it’s now nearly midnight, so I’m going to wrap this up for the night and bid thee adieu. Until next time… Oh yeah — enjoy Independence Day!
“Don’t let it end like this. Tell them I said something.”
– last words of Pancho Villa (1877-1923)
–MZ
