RE: Thinking OOP problem

Started by
10 comments, last by Sir_Spritely 21 years, 5 months ago
quote:Original post by risingdragon3
I suggest in this case to use get() / set() methods, which return a interface Engine.

I don''t regard that as good general advice either. The problem is twofold.

Firstly, ask yourself "why do we make data private in the first place?" Lots of accessors and mutators in a design can cause the same problems that public data causes. They reveal the internal structure of the class and allow clients to rely on that structure. Also, they are symptomatic of "mechanistic" design, where you are allowing the solution domain to drive and are ending up with interfaces semantically far removed from the problem domain, which is what you are *supposed* to be modelling after all. Don''t let the tail wag the dog - create interfaces based on the "business rules" that the class models.

Secondly, you''re recommending direct violation of the Law of Demeter, which I recommend folks try Googling for. Again, violating LoD makes a design rely on internal structure of classes - this time the composition of classes is revealed to the outside world.

The upshot of both of these problems is that you create yourself a design which is hard to change, where change is the only certainty of s/w development.
Advertisement
Okay...

Now I am seriously confused

Anyone know where I can view an example project for modeling a real world problem such as a Home burglar alarm, a heating system or something along those lines from start to finish.

Like writing the actual description of what you want everything to do right through to the actual Java or C++ code?

That is all I am trying achieve.

By the way thanks for the feedback so far, it has been helpful, a bit confusing as well

Paul.

This topic is closed to new replies.

Advertisement