...then I notice some obvious duplications in my code! I get to work right away. After a couple of hours of refactoring I succeed in distilling the foul repetition to the irreducible essentials:
my @todo = ( [ 'foo', 42, 'http://www.google.com' ], [ 'bar', 6, 'http://www.boingboing.net' ], . . . . . . [ 'mumble', 101, 'http://search.cpan.org' ], ); jewel( @$_ ) for @todo; # gloriously refactored code follows...
Yep. That's right. Once all the duplications are factored out, I determine that whatever it was my code was repeating requires, in essence, a bit of string, a number, and a URL. Everything else follows beautifully from this!!!
Unfortunately, now I'm left with all this gnarly, irreducible junk that has no intrinsic meaning whatsoever other than being the input to my jewel. (I suppose it makes sense that after factoring out all the regularities the crazy stuff is left behind.)
I must tame this last bit of orneriness, but how? Encapsulation! I create a class, InputToJewel, with accessors, string, number, and url...
At this point I wake up in a cold sweat.
the lowliest monk
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Notes from the Refactoring Ward
by revdiablo (Prior) on Sep 08, 2005 at 22:44 UTC | |
|
Re: Notes from the Refactoring Ward
by Tanktalus (Canon) on Sep 08, 2005 at 23:08 UTC | |
|
Re: Notes from the Refactoring Ward
by kvale (Monsignor) on Sep 08, 2005 at 22:42 UTC | |
by Anonymous Monk on Sep 09, 2005 at 00:01 UTC | |
|
Re: Notes from the Refactoring Ward
by pg (Canon) on Sep 09, 2005 at 00:26 UTC | |
by Anonymous Monk on Sep 09, 2005 at 00:58 UTC |