Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Why Use Interfaces
Message
De
04/01/2008 00:43:15
 
Information générale
Forum:
ASP.NET
Catégorie:
Conception classe
Divers
Thread ID:
01278205
Message ID:
01279399
Vues:
18
Doru,

Ah, but what I'm talking about isn't true multiple inheritance. I agree that that can get very messy. But having classes that implement multiple interfaces solves this problem nicely.

Here's an apropos quote from one of the links that Tracy posted:

Multiple interface implementation is a compromise. It enables you to have multiple interface inheritance, without all of the problems associated with multiple implementation inheritance

And, in the link from Tracy that was a Q&A with Anders, he says:

I think also when you analyze what is it that people want to do with multiple inheritance, in the vast majority of cases I think there are simpler answers than the full multiple inheritance enchilada with virtual base classes and the diamond problem and all of that stuff.

And lastly, Perry's reply to you was spot-on! He said it much better than I have been trying to say. Thanks Perry! =0)

~~Bonnie




>>>>... Interfaces can be used to simulate multiple-inheritance. And there's nothing wrong with using them this way.
>>>
>>>Nothing wrong? I believe that this is, at least, debatable.

>>
>>OK, I'm always up for a good debate ... what are your objections?
>>
>>~~Bonnie
>
>I believe that multiple inheritance (MI):
>- in most cases, shows a flaw in design.
>- and almost always generates maintenance problems.
>I put MI in the same category with things like the Scope Resolution Operator, or event binding. We all hated spaghetti code (sometimes, even if it was our code) for the mess it created, but we were all so happy to get the :: and event binding.
>A complex class hierarchy that uses single inheritance could be challenging, but with MI you can really make it like spaghetti.
>
>I know that in real life we have to compromise, sometimes, and for valid reasons, use interfaces to simulate MI. Some say MI is good, and some say MI is bad - I don't know if there is a clear winner, but I am on the side that believe there is enough wrong with MI. Maybe you meant there is nothing wrong technically, i.e. you can do it, which is true.
>
>I wasn't actually looking for having the debate here, there are people way better than me to do it. I just felt "nothing wrong" was too strong.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform