Interfaces vs. abstract classes [closed]?

The advantages of an abstract class are Ability to specify default implementations of methods Added invariant checking to functions Have slightly more control in how the "interface" methods are called Ability to provide behavior related or unrelated to the interface for "free" Interfaces are merely data passing contracts and do not have these features. However they are typically more flexible as a type can only derived from one class but can implement any number of interfaces.

At least add a reason – JaredPar Apr 14 '09 at 13:27 @JaredPar : I guess it's to discourage answering duplicate questions (btw, I'm not the one who downvoted you) – Brann Apr 14 '09 at 13:34 @Brann, I've unfortunately seen that behavior before. Seems like it would make more sense to use the down vote on the OP.It's their responsibility to search for dupes. – JaredPar Apr 14 '09 at 13:37 I'll +1, if memory serves this is what was in the framework design guidelines.

Great examples in there too. – JoshBerke Apr 14 '09 at 13:37.

The real question is: whether to use interfaces or base classes. This has been covered before. In C#, an abstract class (one marked with the keyword "abstract") is simply a class from which you cannot instantiate objects.

This serves a different purpose than simply making the distinction between base classes and interfaces.

Another thing to consider is that, since there is no multiple inheritance, if you want a class to be able to implement/inherit from your interface/abstract class, but inherit from another base class, use an interface.

Abstract classes and interfaces are semantically different, although their usage can overlap. An abstract class is generally used as a building basis for similar classes. Implementation that is common for the classes can be in the abstract class.An interface is generally used to specify an ability for classes, where the classes doesn't have to be very similar.

The best answer I have seen is in this excellent book by Brad Adams and Krzysztof Cwalina amazon.com/Framework-Design-Guidelines-C....

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions