in reply to Re (tilly) 1: oo perl - using the super-class
in thread oo perl - using the super-class

hm, no, that's exactly what i don't want. i never want to have the main code say:
$trans = new TransactionA
i want to say
$trans = new Transaction($request);
and have $trans be an instance of TransactionA or TransactionB. i'm not up on oo terminology, but i think what i really want is a TransactionFactory class. again, i'm not sure but the above describes what i'm looking for. i'm just wondering if it's a good thing to look for or is there a better design to use?

Replies are listed 'Best First'.
RE: RE: Re (tilly) 1: oo perl - using the super-class
by merlyn (Sage) on Oct 03, 2000 at 18:52 UTC
    Your original code was fine. Just make sure that neither of your two specific types of transaction inherit from the generic transaction, or you're toast on the new routine!

    -- Randal L. Schwartz, Perl hacker

RE (tilly) 3: oo perl - using the super-class
by tilly (Archbishop) on Oct 03, 2000 at 18:53 UTC
    Well you can do whatever you want with the two argument form of bless, but you will break inheritance.

    OTOH containment (ie making one property of an object be a member of a different class) is usually cleaner than inheritance anyways, but if you play this kind of game you really should document it to avoid potential grief for someone else.