in reply to Re: Class::Interface -- isa() Considered Harmful
in thread Class::Interface -- isa() Considered Harmful
Inheriting from an abstract base class is dictating an object's implementation. To me, there's a world of difference between saying "even though this mock object inherits absolutely no data or behavior from this class hierarchy, it's a member of this class hierarchy" and "this mock object has the same fingerprint as objects of this class and can be used in their place".
A mock object is not a DBI object. It's not a CGI object. It can act like either though.
I think there's a broader principle here -- substitutability. Inheritance is not the only means by which objects of two different classes can be substitutable. There's also composition and delegation (the "has a" relationship) and equivalence of behavior (the "acts like a" relationship). Making an abstract class would work, but it doesn't express the nature of the substitutability.
I'd like to avoid forcing composition, delegation, and equivalence relationships into the inheritance scheme. If my substitutable object does not fit within the class hierarchy conceptually, why should I have to lie to the compiler and all future maintenance programmers and say that it does?
(I'm very much in agreement with your comments on Java, though. Pity that a good concept sucked up the proper terminology so much that people think I like that approach.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Class::Interface -- isa() Considered Harmful
by Aristotle (Chancellor) on Jan 19, 2003 at 19:49 UTC | |
|
Re^3: Class::Interface -- isa() Considered Harmful
by adrianh (Chancellor) on Jan 19, 2003 at 20:50 UTC | |
by chromatic (Archbishop) on Jan 19, 2003 at 21:37 UTC | |
by Aristotle (Chancellor) on Jan 19, 2003 at 21:57 UTC | |
by adrianh (Chancellor) on Jan 19, 2003 at 21:58 UTC | |
|
Re^3: Class::Interface -- isa() Considered Harmful
by adrianh (Chancellor) on May 22, 2003 at 14:31 UTC |