[thelist] more OOD fun
Marcus Andersson
marcus at bristav.se
Mon Oct 11 14:48:53 CDT 2004
Steve Lewis wrote:
> Scott Dexter wrote:
>
>> The specifics: Person is subclassed into Guest and Guide classes. The
>> Guest class extends Person by adding payment information and
>> comments, items not in the Guide class. Now in the application, if I
>> don't have teh payment information in the IPerson interface, I can't
>> get to it, unless I declare the object as a Guest, which avoids the
>> interface, which is not the best thing to do ... right?
>
> There are more complex relationships possible. I am going to be
> frustrating and answer your questions with other questions.
>
> Why do you need to get the payment information out of the (Guest) Person
> in order to use it? The class should be more than a data structure,
> remember. Does it make sense to delegate the responsibility of handling
> payment activities to the Guest itself?
>
+1
Check out the "code smell" Feature Envy at http://wiki.java.net/bin/view/People/SmellsToRefactorings or
http://c2.com/cgi/wiki?FeatureEnvy (it's based on Martin Fowlers "Refactoring")
/Marcus
More information about the thelist
mailing list