Re: Design Pattern Question
- From: "H. S. Lahman" <h.lahman@xxxxxxxxxxx>
- Date: Sun, 19 Aug 2007 15:25:47 GMT
Responding to Marshall...
Xllo said something like:
...[snip]...
I would like to explore this design further.
Assuming there is a heirarchy of classes.
Employee from which is derived ManagerEmployee,
HREmployee, HRManagerEmployee, etc.
I'm compelled to offer an off-beat explanation as to why IMO the above (and their inter-relationships) are almost always mistakes when expressed strictly as class hierarchy. What happens when an employee is promoted to Manager...and how could he?
There is a formal mechanism for this known as subclass migration. Basically one deletes the old object and instantiates a new one with the same identity and attributes in the new subclass. However, it tends to be messy and fragile in practice, so it isn't used very much.
Today I think most people prefer to delegate roles and employ the GoF State pattern for exactly this reason. That reduces the migration to dynamic instantiation of a single relationship.
*************
There is nothing wrong with me that could
not be cured by a capful of Drano.
H. S. Lahman
hsl@xxxxxxxxxxxxxxxxx
Pathfinder Solutions
http://www.pathfindermda.com
blog: http://pathfinderpeople.blogs.com/hslahman
"Model-Based Translation: The Next Step in Agile Development". Email
info@xxxxxxxxxxxxxxxxx for your copy.
Pathfinder is hiring: http://www.pathfindermda.com/about_us/careers_pos3.php.
(888)OOA-PATH
.
- Prev by Date: Re: Passing a lot of parameters in constructor?
- Next by Date: Re: omg-100 uml exam prep
- Previous by thread: Re: Passing a lot of parameters in constructor?
- Next by thread: Re: Design Pattern Question
- Index(es):