Insights into the .NET Architecture A Conversation with Eric Gunnerson by Bill Venners with Bruce Eckel February 9, 2004
Don't Burn Your Base Class Bruce Eckel: Does the CLS allow multiple interface inheritance?
Eric Gunnerson: Yes.
Bruce Eckel: But that's a reasonable constraint.
Eric Gunnerson: It's a reasonable constraint if nobody causes you to do anything that makes you burn your base class.
Bill Venners: Burn my base class?
Eric Gunnerson: I'll give you the canonical example. When you want to make a component a remote object, you must derive its class from a base class called MarshalByRef. When MarshalByRef subclasses get marshaled, they get marshaled by reference. You get an object over here and a proxy over there, and the runtime handles all the mechanics. That works great, unless you actually want to use inheritance in your design. Because the designers of remoting decided to do this with the base class, they took the option of using inheritance in any other way away from you. They burned the base class.
Bill Venners: They burned the base class because if I want to remote something, I have to extend their class, not some other class I may want to extend.
Eric Gunnerson: Maybe you can get away with extending a class of yours that extends their class.
Bill Venners: But if it doesn't already extend their class and I can't change it, then I'm out of luck.
Eric Gunnerson: Yes, exactly. The constraint in supporting single inheritance of implementation, multiple inheritance of interface is that you have to pay a lot of attention about what you do. In fact if you go talk to customers that use remoting they say that exact same thing, why are you burning a base class here? You don't need to. You could use attributes or some other mechanism.
Source
For more details, visit http://www.artima.com/intv/dotnet.html
|
No responses found. Be the first to respond and make money from revenue sharing program.
|