[nycphp-talk] Constants interfaces
Michael B Allen
ioplex at gmail.com
Wed Sep 3 15:12:59 EDT 2008
On Wed, Sep 3, 2008 at 2:20 PM, Kenneth Dombrowski <kenneth at ylayali.net> wrote:
> I don't have a problem with multiple inheritence, it just seems very
> kludgey to me to implement it with interfaces; I guesss PHP gives you
> little choice though..
Quite the opposite. The only non-kludgey way to implement multiple
inheritance is to use interfaces because if you use a class you cannot
implement *it* without extending it and you cannot (or should not)
extend multiple classes as overriding inherited methods can easily
lead to non-deterministic behavior.
For example, let's say you have financial instrument interfaces
"Stock", "Bond", "MutualFund" and "MoneyMarket" where a mutual fund
can be traded like a stock or a bond but a money market instrument has
characteristics of a mutual fund (I'm not a financial wiz - this is
just an example). So which one do you make the base class? The answer
is very simple: none. You make an interface for all of them and then
create concrete classes that implement each of the interfaces
required.
Mike
--
Michael B Allen
PHP Active Directory SPNEGO SSO
http://www.ioplex.com/
More information about the talk
mailing list