Marick's Law 7
A month ago I was deep in the throes of shipping the current release of FitNesse. I just wanted to get it done. I was close to delivery when I spotted a subtle flaw. To fix this flaw I decided to insert identical if statements into each of 9 implementations of an abstract function.
My green wrist band was glowing a nasty shade of puke. I knew I was duplicating code. I knew that I should use the Template Method pattern. But that just seemed too hard. I was convinced that it would be faster to spew the duplicated code out into the derivatives, get the release done, and then clean it up later.
So this morning I was doing something else, and I spotted this duplicated code. I sighed, as I looked down at my green wrist band, and thought to myself that I’d better eat my own dog food and clean this mess up before it gets any worse. I was dreading it.
I made sure that every occurrence of the statement was identical. Then I went to the base class with the intention of refactoring a Template Method. When, what to my wondering eyes should appear, but a Template Method that was already there.
I sheepishly copied and pasted the if statement from one of the derivatives into the Template Method, and then deleted the other eight instances.
I ran the tests.
They all passed.
Damn.
My green wrist band is shouting: “I TOLD YOU SO!”
For my penance I did 20 recitations of Marick’s law. “When it comes to code it never pays to rush.”

I agree with this, but I have to say that pairing makes it easier to implement. So much harder to slack off with others watching
Hmmm. Perhaps we should make a plug-in for our IDE which has a little character applauding when it recognizes a refactoring we did. :) Perhaps a nice sound. (Ding!)
And a raspberry when it sees us doing too much cut n paste.
Oh i agree on that, rushing code always puts us in trouble! But i did not know about these green wrist band and i just love them, i’ll send a donation and will get a few for the office, it’s a funny reminder that can really get helpfull!
So much harder to slack off with others watching …..
can you give more
Hi..thanks for the information… loved it simply Oh man! What an amazing thing to say