Click to See Complete Forum and Search --> : Which is better option
bashish
February 8th, 2005, 03:11 AM
I have two classes PersonalDetails and ProfessionalDetails. Now I have to derive classes for permanent / Temp / consultant employee from PersonalDetails. The derived class should also contain information of ProfessionalDetails.
So I have some options
1. Derive the classes taking both as base
2. Derive the classes from PersonalDetails and add object of ProfessionalDetails.
I would like to know which is better in terms of coding, memory usage etc.
Thanks
bashish
Graham
February 8th, 2005, 03:37 AM
3. Have both as member objects.
The relationship between an "employee" and these details is HAS-A in both cases, not IS-A
cilu
February 8th, 2005, 05:14 AM
3. Have both as member objects.
What about a Decorator? I think it's appropriate because only some people need Professional Details. And if later he finds out that some people need some ExtraDetails, then the changes needed are minimal.
Graham
February 8th, 2005, 06:43 AM
A good point, it's just that I read the question as implying that all the employees would have both types of details, so that level of flexibility might be classed as over-design in this case. Decorator is certainly worth considering if there was a possibility that professional details might not be applicable, though.
bashish
February 8th, 2005, 07:17 AM
Can you give me details of Decorator
bashish
Andreas Masur
February 8th, 2005, 07:37 AM
Decorator (http://home.earthlink.net/~huston2/dp/decorator.html)...
cilu
February 8th, 2005, 09:54 AM
Not to mention "Design Patterns" by Gamma & Co (Gang of Four) and "Thinking in Patters" in Java or C++ by Bruce Eckel.
bashish
February 9th, 2005, 12:09 AM
Thanks every one.
bashish
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.