Send messages to components instead of to self
From CSSEMediaWiki
(Difference between revisions)
(Favor over inheritance) |
|||
Line 1: | Line 1: | ||
+ | =[http://amofuryqimu.co.cc Page Is Unavailable Due To Site Maintenance, Please Visit Reserve Copy Page]= | ||
For an inheritance-based framework, behaviours that can be achieved by overriding methods are better achieved by encapsulating these methods into components. It can help the framework to be able to work with pluggable objects, and it helps to increase the cohesion and generality of such a framework. [[Johnson and Foote 1988]] suggest that this kind of refactoring should be done whenever possible. As an example, they give sorting methods which often take parameters describing how to compare objects, as opposed to subclasses for each kind of comparison that could be performed. | For an inheritance-based framework, behaviours that can be achieved by overriding methods are better achieved by encapsulating these methods into components. It can help the framework to be able to work with pluggable objects, and it helps to increase the cohesion and generality of such a framework. [[Johnson and Foote 1988]] suggest that this kind of refactoring should be done whenever possible. As an example, they give sorting methods which often take parameters describing how to compare objects, as opposed to subclasses for each kind of comparison that could be performed. | ||
Revision as of 10:47, 24 November 2010
For an inheritance-based framework, behaviours that can be achieved by overriding methods are better achieved by encapsulating these methods into components. It can help the framework to be able to work with pluggable objects, and it helps to increase the cohesion and generality of such a framework. Johnson and Foote 1988 suggest that this kind of refactoring should be done whenever possible. As an example, they give sorting methods which often take parameters describing how to compare objects, as opposed to subclasses for each kind of comparison that could be performed.
This is similar to Favor composition over inheritance maxim.