in reply to Re: Abusing Exporter for Conditional Inheritance
in thread Abusing Exporter for Conditional Inheritance

I'm not so sure that class factories are the right approach in this case. From the Class::Factory docs:
Factory classes are used when you have different implementations for the same set of tasks but may not know in advance what implementations you will be using.
In my case it's the reverse: I have the same implementation for a different set of tasks.

Thanks for your thoughts,
Matt

  • Comment on Re^2: Abusing Exporter for Conditional Inheritance

Replies are listed 'Best First'.
Re^3: Abusing Exporter for Conditional Inheritance
by perrin (Chancellor) on Mar 17, 2005 at 19:02 UTC
    A class factory can be a way to hand back the same class with different initialization parameters. The point is to hide the initialization stuff behind a simple call.

    In the case you describe here, if the code calling this thing knows which one it wants, I think you should actually either just make the two classes and call them or make a class that has some kind of method like "set_collection_color()" for switching the behavior.

      Yet the only difference between the two cases is the contents of @ISA. And localizing @ISA is probably not a good idea. Last night tye pointed out that it's probably not thread safe, and look here for an explanation from gbarr as to why it's not efficient.

      Matt

        Yet the only difference between the two cases is the contents of @ISA

        Yes, and? Why look for a complex and likely to fail solution when you have a simple and certain to work one?