Abstract vs Interface
From CSSEMediaWiki
(Difference between revisions)
LukeRobinson (Talk | contribs) |
LukeRobinson (Talk | contribs) |
||
Line 4: | Line 4: | ||
That case is known as Abstract vs Interface. | That case is known as Abstract vs Interface. | ||
− | + | The question is should I use an abstract base class or implement an interface? After all, they are both program to the interface not the implementation. | |
[[Image:interface.png]] | [[Image:interface.png]] | ||
[[Image:Abstract.png]] | [[Image:Abstract.png]] |
Revision as of 03:04, 3 August 2010
We all know that we should program to the interface not the implementation. But what is an interface? and how do we know what kind of interface to use?
You might think the answer is simple, and many times it is, but there is a case where the line becomes hard to distinguish.
That case is known as Abstract vs Interface. The question is should I use an abstract base class or implement an interface? After all, they are both program to the interface not the implementation.