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

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.

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

Replies are listed 'Best First'.
Re^4: Abusing Exporter for Conditional Inheritance
by mojotoad (Monsignor) on Mar 17, 2005 at 19:13 UTC
    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?

        With all due respect, perrin, the factory solution strikes me as more complex. I am willing to consider it, however, but I still don't understand how you can accomplish it without localizing @ISA. Unless I'm missing something obvious?

        Thanks,
        Matt