Introduce common base class

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
 +
=[http://acisabukody.co.cc UNDER COSTRUCTION, PLEASE SEE THIS POST IN RESERVE COPY]=
 
:''If two or more classes have common data and behavior (i.e. methods) then those classes should each inherit from a common base class which captures those data and methods.'' --Riel's Heuristic 5.10, [[Arthur Riel 1996]]
 
:''If two or more classes have common data and behavior (i.e. methods) then those classes should each inherit from a common base class which captures those data and methods.'' --Riel's Heuristic 5.10, [[Arthur Riel 1996]]
  

Revision as of 05:21, 24 November 2010

UNDER COSTRUCTION, PLEASE SEE THIS POST IN RESERVE COPY

If two or more classes have common data and behavior (i.e. methods) then those classes should each inherit from a common base class which captures those data and methods. --Riel's Heuristic 5.10, Arthur Riel 1996

Example

RH5.10Before.png

The two classes Dog and Bird have common data (weight) and behaviour (eat() and sleep()).

RH5.10After.png

A new class called Animal is created that both Dog and Bird inherit.

See also

Personal tools