Author: techfox9
Interface vs Abstract Class ..
Thursday, April 23rd, 2009 @ 11:22 pm
- — Inheritance from anything (including abstract)
should be a function of the business model. - — If a class does not _really_ inherit from
an abstract, one should not use it. - — Use interface to avoid the problem of multiple
inheritance. - — Use interface to improve modularity.. if one
uses an abstract class and the class changes,
it may break subclasses.
(not method signatures but logic/code.. changing
method signatures is a problem for both abstract
and interface) - — Use interfaces when some part of the design
will change frequently. - — Interface for plug-in architectures – like
the strategy pattern. - — Use abstract class to provide basic services
for derived classes (event, message handling) - — In favor of abstract class:
- — interfaces may be more difficult to read in
code logic. - — interfaces are somewhat slower due to
indirections.
- — interfaces may be more difficult to read in