Factor implementation differences into subcomponents
From CSSEMediaWiki
(Difference between revisions)
m |
|||
Line 4: | Line 4: | ||
This means that multiple subclasses can contain the same implementation without repeated code. | This means that multiple subclasses can contain the same implementation without repeated code. | ||
+ | |||
+ | An interesting point to note is that this rule is an early version of the [[Gang of Four]] [[Strategy]] pattern, obviously influenced by Johnson's contribution to the paper. | ||
== Example == | == Example == |
Revision as of 00:59, 20 August 2008
This is Rule 10 in Johnson and Foote 1988.
If different subclasses implement a method in one of a few ways, then the method may not be directly related to the superclass and the implementation should be separated by creating a class hierarchy and composing it within the superclass.
This means that multiple subclasses can contain the same implementation without repeated code.
An interesting point to note is that this rule is an early version of the Gang of Four Strategy pattern, obviously influenced by Johnson's contribution to the paper.
Example
To do.