Think about Loose Coupling | |
PerlMonks |
Implementing methods in a subclass or providing in-place callback: Is it overengineered?by Dallaylaen (Chaplain) |
on Sep 23, 2016 at 09:12 UTC ( [id://1172434]=perlquestion: print w/replies, xml ) | Need Help?? |
Dallaylaen has asked for the wisdom of the Perl Monks concerning the following question: Hello, dear esteemed monks! I just wrote the following in my module. The idea is as follows: allow user to override default methods by either subclassing, or providing a callback. So a subclass with do_foo method and an instance of base class with on_foo member will behave exactly the same. However, looking at this again, I suspect it's being overengineered. Should I just provide default do_foo methods in subclass that search for a callback and croak if none found? This will still allow for both ad-hoc overriding and subclassing. Should I just go with normal OO and leave do_foo() alone? Guess there's no single correct answer after all, but I'd like to hear your opinions and make up my own.
Thank you!
Back to
Seekers of Perl Wisdom
|
|