On Sat, Jan 8, 2011 at 1:25 PM, Martin Makundi
<martin.maku...@koodaripalvelut.com> wrote:
>>> What I hate about java is its one-dimensionality... ehh.. say you have:
>>>
>>> object man
>>> object man carrying bag
>>> bag carrying pencil case.
>>>
>> This isn't a Java problem.  This is a design problem.
>
> How would you workaround the design assuming you cannot change the
> releations between the object models (object model has its own
> requirements/sweetspot)?
>

You would use a more domain-oriented design approach.  Setters/getters
are merely used because of all the frameworks that support (and
expect) them.  Why do you care where the man is carrying his pencil?
Perhaps he's keeping it in his sock. All you want to do is ask the man
object for a pencil.  Having to go through his carrying bag to his
pencil case to get his pencil is exposing the implementation.  If the
man exposes his bag/pencil case to the world, then someone can just
steal the pencil from him without him knowing about it.  However, if
you have to ask him for the pencil and then he can go dig in his bag
to get his pencil case to find a pencil, then perhaps he can do
something at that point and jot down a note that you've just borrowed
a pencil from him.

Reply via email to