Re: design dilemma
From: Cristiano Sadun (TAKEcristianoTHISsadunOUT_at_hotmail.com)
Date: 03/05/04
- Next message: Cristiano Sadun: "Re: design dilemma"
- Previous message: TheFerryman: "Re: design dilemma"
- In reply to: TheFerryman: "Re: design dilemma"
- Next in thread: Cristiano Sadun: "Re: design dilemma"
- Reply: Cristiano Sadun: "Re: design dilemma"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 5 Mar 2004 12:46:54 +0000 (UTC)
TheFerryman <ferry@onthenet.com> wrote in
news:36qg40h08n230pdj61klvq719p54j666eg@4ax.com:
> One thing that struck me this morning is that the following two
> classes provide exactly the same functionality but, if I understand OO
> correctly, most OO programmers would say the second version is bad
> design. Is that correct?
Dont think so. Actually the opposite. I favour using composition over
inheritance unless there's a real strong and provable generalization
involved. In your example, a Body is no way a generalization of a Sense (if
a get the meanings right :-) so I would consider the first as bad design.
The possibly "bad" thing about the second - the accessors - is still
another issue, which can't be captured well at that example's level of
abstraction, dealing to the fact that while a body has senses, they
shouldnt be available as such outside its boundaries.
For your original problem: you want to model a cat, which has vision and
memory, but you make vision depend on memory. If your intent is to allow
vision to coordinate with memory, I'd say that that's what a Brain is for.
:)
-- You dont know what to do when you dont know what you're doing. http://space.tin.it/computer/csadun
- Next message: Cristiano Sadun: "Re: design dilemma"
- Previous message: TheFerryman: "Re: design dilemma"
- In reply to: TheFerryman: "Re: design dilemma"
- Next in thread: Cristiano Sadun: "Re: design dilemma"
- Reply: Cristiano Sadun: "Re: design dilemma"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|