| « The Confidential Upgrade | The Ace in the Hole » |
"It's some nice code," smiled the software architect at Petr Valasek's company, "it needed refactoring before it was ever written. But the good news is, you get to refactor it now."
And just like that, Petr was a new father. His baby was the bastard child known as the GIS Hardware Monitoring module. It wasn't pretty, but Petr knew it had potential and was excited to refactor the code. One of the first things he came across was this.
switch ( nState )
{
case GIS_NEEDLE_STATE_ERROR:
Diederick;
break;
case GIS_NEEDLE_STATE_UNKNOWN:
Jan;
break;
case GIS_NEEDLE_STATE_INSERTED:
Piet;
break;
case GIS_NEEDLE_STATE_RETRACTED:
Kees;
break;
}
Who are these four dutchmen, Petr wondered, and what are they doing in my code? Digging a bit further, he found how the dutchmen were #defined:
/*case GIS_NEEDLE_STATE_RETRACTED:*/ #define Kees (m_nlGISRetracted &= ~(1 << nIndex)) /*case GIS_NEEDLE_STATE_UNKNOWN: */ #define Jan (m_nlGISRetracted |= 1 << nIndex) /*case GIS_NEEDLE_STATE_INSERTED: */ #define Piet (m_nlGISRetracted |= 1 << nIndex) /*case GIS_NEEDLE_STATE_ERROR: */ #define Diederick (m_nlGISRetracted |= 1 << nIndex)
As for refactoring, Petr considered combining Jan, Piet and Diederick into a single person ("Hans" seemed like a good name), but was a bit concerned that it might create some "multi-personality issue." Of course, not that it mattered because all GIS hardware is considered "retracted" when and only when m_nlGISRetracted equals zero.
|
This is clearly better than my practice of naming all inline functions "Alex", "Jake" and "Mark"...
|
Re: The Four Dutchmen
2009-07-06 09:49
•
by
J., another Dutchman (really!)
(unregistered)
|
|
No, one would need three Dutchmen to screw in a lightbulb (better be a large lightbulb... ;-), that's why the Hans solution will probably not work... Oh wait everyone's switching to LEDs these days...
|
|
Most of the times, you wonder how on earth something like this slips into the code. My guess: Poor programmer don't know what kind of errors there are and what to do with it and ask 4 people: Kees, Jan, Piet and Diederick. All came with a different solution. So, pragmatic as the programmer is, he implements all solutions but does make sure the 4 nitwits who advices him, do get blame forever in this code..
|
|
The year: 1961
We were building a large system for a new Air Force contract. Being short-handed, we subbed a test analysis tool to another division of our company, which needed work. When it arrived, we glanced at the code. Like the Dutchmen, the programmer had made all the procedures names - Eric, Charley, Darlene, Shirley, ... But she went one step further. The arrays (all global, of course) were named Gin, Whiskey, Vodka, Rum, .... Dan Covill San Diego |
| « The Confidential Upgrade | The Ace in the Hole » |