Intelligent children pattern
From CSSEMediaWiki
(Difference between revisions)
m (Reverted edits by Ebybymic (Talk); changed back to last version by BenMcDonald) |
|||
(5 intermediate revisions by 5 users not shown) | |||
Line 3: | Line 3: | ||
Basically it states that the children of a [[Parallel hierarchies problem]] should know about the corresponding children of the other heirarchy. | Basically it states that the children of a [[Parallel hierarchies problem]] should know about the corresponding children of the other heirarchy. | ||
+ | [[Image:Intelegent Children.jpg|800px]] | ||
− | [[Image: | + | |
+ | |||
+ | |||
+ | ==Abstract Accessors== | ||
+ | An abstract accessor can be used to access the Operator from an object that is only know to be a Vehicle. This lets your Vehicle object have a contract about containing an Operator. This is know as the [[Defer identification of state variables pattern]]. | ||
+ | |||
+ | [[Image:ICP_-_Abstract_Accessor.png|800px]] | ||
+ | ===Language Notes=== | ||
+ | J2SE5.0 and above allows covariant return types in overridden methods if the object returned is a subclass of the type returned by the method with the same signature in the superclass. | ||
+ | |||
+ | C++ does not allow any overridden methods with covariant return types | ||
Line 10: | Line 21: | ||
* [[Robert Cecil Martin 1997b]] | * [[Robert Cecil Martin 1997b]] | ||
* [[Defer identification of state variables pattern]] | * [[Defer identification of state variables pattern]] | ||
+ | * [[Define classes by behavior, not state pattern]] | ||
* [[Parallel inheritance hierarchies smell]] | * [[Parallel inheritance hierarchies smell]] | ||
− | * [[Parallel hierarchies | + | * [[Parallel hierarchies]] |
Latest revision as of 03:10, 25 November 2010
This idea is similar to the Defer identification of state variables pattern.
Basically it states that the children of a Parallel hierarchies problem should know about the corresponding children of the other heirarchy.
Abstract Accessors
An abstract accessor can be used to access the Operator from an object that is only know to be a Vehicle. This lets your Vehicle object have a contract about containing an Operator. This is know as the Defer identification of state variables pattern.
Language Notes
J2SE5.0 and above allows covariant return types in overridden methods if the object returned is a subclass of the type returned by the method with the same signature in the superclass.
C++ does not allow any overridden methods with covariant return types