Abstract class

From APIDesign

(Difference between revisions)
Jump to: navigation, search

JaroslavTulach (Talk | contribs)
(New page: An Abstract class in an API is suspicious. Often it just shows the API designer was not sure whether the goal is to create a ClientAPI or ProviderAPI. In case the [[Cla...)
Next diff →

Revision as of 19:35, 12 May 2012

An Abstract class in an API is suspicious. Often it just shows the API designer was not sure whether the goal is to create a ClientAPI or ProviderAPI. In case the ClarityOfAccessModifiers is not obeyed, one can get into significant troubles as illustrated on the factorial example.

Not all usages of abstract classes are bad. For example the ImplementOnlyAbstractClass benefits from richer set of access modifiers one can use in abstract classes than in ImplementOnlyInterface.

Also one can keep ClarityOfAccessModifiers even in abstract classes as for example CharsetEncoder shows by having all ClientAPI methods public final and all the others protected.


Still, in the name of clarity, consider separating APIvsSPI into separate types.

Personal tools
buy