Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C# discussion: Interfaces
Message
From
01/08/2008 17:17:16
 
General information
Forum:
ASP.NET
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
01335713
Message ID:
01335979
Views:
11
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform