[Chicago-talk] 2 subclasses or Multiple inheritance

me at heyjay.com me at heyjay.com
Tue Mar 23 09:25:49 CST 2004


Thats sorta like what I'm doing.  But it seems that each of the
"trademodule"s should be built with the same interface, and ideally share
some code (if possible)

Jay
----- Original Message ----- 
From: "Steven Lembark" <lembark at wrkhors.com>
To: "Chicago.pm chatter" <chicago-talk at mail.pm.org>
Sent: Sunday, March 21, 2004 6:05 AM
Subject: Re: [Chicago-talk] 2 subclasses or Multiple inheritance


>
>
> -- Jay Strauss <me at heyjay.com>
>
> > I have a class which connects to Ameritrade (broker), and I have another
> > class which connects to InteractiveBrokers.  Both of these classes have
> > methods quote, connect, disconnect.  The class for InteractiveBrokers
has
> > a bunch of others too.  While the method names are the same their
> > implementation is totally different, as are their required input parms.
> >
> > The classes don't share any of the same code, and I don't see them
sharing
> > any/much in the future.
> >
> > I'd like to be able to plug in other brokers as necessary.
> >
> > So my question is, do I make a base class like "broker" and make a
> > Ameritrade and InteractiveBrokers that inherit from broker, or do a make
a
> > broker that inherits from Ameritrade and InteractiveBrokers?
>
> You don't. If the dispatching object has a "tradermodule"
> object stored it in you can use
>
>     $dispatcher->{tradermodule}->foobar( args )
>
> to handle any tradermodule you prefer. You can populate the dispatcher
> entry with a classname initially then use:
>
>     $dispatcher->{tradermodule} = $dispatcher->{tradermodule}->initialize;
>
> to get an object.
>
> --
> Steven Lembark                               2930 W. Palmer
> Workhorse Computing                       Chicago, IL 60647
>                                             +1 888 359 3508
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at mail.pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk
>
>




More information about the Chicago-talk mailing list