rovf has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks, I'm faced with what looks like a classical OOP problem: I have a bunch of modules which, by design, offer the same set of functions to the outside, but conceptually with different implementations. In practice, however, a large percentage of the modules have identical implementation for most functions. In OOP, I would therefore do it like this:
Since the majority of function definitions are forwarders, I tried to improve like this: I define a file "Includes.pl", which contains those most common forwarding definitions, and in those of my modules, which need these, I do asub somefunc { &ParentModule::somefunc }
So far, this seems to work, but I'm not that happy with this solution. Maybe there is a more elegant way to do this? It is important, however, that an alternative solution does not involve invoking AUTOLOAD in my modules, because this would also cause problems in the current context. Any ideas?require 'Includes.pl';
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Forwarding functions to a different module
by Corion (Patriarch) on Aug 07, 2008 at 10:35 UTC | |
by rovf (Priest) on Aug 07, 2008 at 10:52 UTC | |
|
Re: Forwarding functions to a different module
by Tanktalus (Canon) on Aug 07, 2008 at 22:15 UTC | |
|
Re: Forwarding functions to a different module
by tod222 (Pilgrim) on Aug 07, 2008 at 19:27 UTC | |
by rovf (Priest) on Aug 08, 2008 at 06:45 UTC | |
by chromatic (Archbishop) on Aug 08, 2008 at 06:52 UTC | |
by tod222 (Pilgrim) on Aug 09, 2008 at 01:04 UTC |