...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
In reply to Notes from the Refactoring Ward by tlm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |