Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
C# discussion: Interfaces
Message
De
01/08/2008 17:17:16
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Programmation orienté objet
Divers
Thread ID:
01335713
Message ID:
01335979
Vues:
13
>I guess this is what I deserve for asking such an open ended question. At least you didn't say you were in Redmond when someone told you interfaces are good.
>
>>Interfaces good.
>>
>>>The floor is open to discussion.


Mike,

Here is the explanation clarified the concept for me...

"...think at a much higher level. When you're designing an object model:

* interfaces describe "can do" relationships.
* abstract classes describe "is a" relationships.

Or, to put it another way

* interfaces share appearance but not implementation
* abstract classes share both appearance and implementation

When you're trying to decide whether to use an interface or an abstract class, ask yourself:

* is there any situation where two COMPLETELY different objects would need to be treated as the same?

* is there a fundamental "core" of implementation that needs to be shared by EVERY implementation?

* is there a sensible "is a" relationship? A Giraffe IS A Mammal IS AN animal.

* is there a sensible "can do" relationship? A Bitmap CAN DO disposal. "

Eric Lippert

from http://discuss.techinterview.org/default.asp?joel.3.89283.9
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform