[baltimorepm] Closures and Late-Binding Subroutine Calls

Bernie Simon bsimon at stsci.edu
Thu Apr 26 11:10:04 PDT 2012


On 4/26/12 1:19 PM, "Stephen Belcher" <sbelcher at gmail.com> wrote:

>I'm trying to allow someone to set up a class B as a subclass of class
>A::Base::Class using an anonymous callback sub which isolates the
>configuration methods and keeps them out of both A::Base::Class and B in
>order to keep the namespace clear

I'm not sure I understand completely what you're trying to do. But
normally object oriented programming uses both inheritance and composition
to accomplish its job. Composition seems the best way to handle this
problem. In this case, an object of the base class would include a
reference to a configuration object. The configuration object would handle
such issues as reading the configuration file. Since the methods that
handle the configuration are invoked from the base class, subclasses
perform the same configuration through inheritance. But the configuration
methods are encapsulated, as they are only invoked from one method in the
base class, presumably by the new method.  That's the way I handle
configuration in my code.



More information about the Baltimore-pm mailing list