Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
(jeffa) Re: Replacing namespacesby jeffa (Bishop) |
on Dec 11, 2001 at 00:19 UTC ( [id://130764]=note: print w/replies, xml ) | Need Help?? |
Interesting code you have there - i can't tell if it's a
hack on the decorator pattern or maybe even the
state pattern. At any rate, i think i see what
the goal is:
You instantiate the First class and test to see if it does the job, if it doesn't, revert to the Second class. This is cool, but it's a maintenance nightmare should you decide to add a Third, or a Fourth, ... all the way to the Nth possible class. I rewrote your code and added some tests - here is the solution domain: And the code: Try it out. Notice the very last expression which outputs the Dump of the object - notice how even though it might belong to package First or Second - $self is the same. That may or may not be a problem for you, because the technique to change $t from First to Second only changes it's package, not it's attributes. In conclusion, the only two problems i see are
jeffa
In Section
Seekers of Perl Wisdom
|
|