Introduce common data class

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
(New page: Instead of having the same attributes in two (or more) classes, the common data should be put into a separate class. In C/C++, a structure is often used to manage common data. Because of t...)
 
(category and see also)
Line 1: Line 1:
 
Instead of having the same attributes in two (or more) classes, the common data should be put into a separate class. In C/C++, a structure is often used to manage common data. Because of the maxim [[Favor composition over inheritance]], using an external data class is better than moving the common data into a base class. This should only be done if common behaviour is also shared (see [[Introduce common base class]]).
 
Instead of having the same attributes in two (or more) classes, the common data should be put into a separate class. In C/C++, a structure is often used to manage common data. Because of the maxim [[Favor composition over inheritance]], using an external data class is better than moving the common data into a base class. This should only be done if common behaviour is also shared (see [[Introduce common base class]]).
 +
 +
== See also ==
 +
* [[Riel's heuristics]]
 +
 +
 +
[[Category:Riel's heuristics]]

Revision as of 01:16, 28 July 2009

Instead of having the same attributes in two (or more) classes, the common data should be put into a separate class. In C/C++, a structure is often used to manage common data. Because of the maxim Favor composition over inheritance, using an external data class is better than moving the common data into a base class. This should only be done if common behaviour is also shared (see Introduce common base class).

See also

Personal tools