in reply to Re: The Pretty Good Idea of Demeter (Was: Definition of Law of Demeter)
in thread Are lvalue methods (as properties) a good idea?
Choosing the correct class to put it in may be difficult. It may be useful to call x->b->c->d->foo() for lots of different xs that don't necessarily share a base class and adding in a mixin class to all those classes may not be not possible.
Many examples of LoD are really about removing accessors. I think it's better to replace a->mother->brother->child->foo() with a->cousin->foo(). Do not replace it with a->foo_the_cousin() because chances are you'll want to call other methods on the cousin and also because it's not much of a saving in terms of typing (in this case it's not a saving at all).
So my sugestion for a better LoD is Consider replacing chains of accessor methods with a single method
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: The Pretty Good Idea of Demeter (Was: Definition of Law of Demeter)
by Aristotle (Chancellor) on Jan 17, 2005 at 22:30 UTC | |
|
Re^3: The Pretty Good Idea of Demeter (Was: Definition of Law of Demeter)
by jplindstrom (Monsignor) on Jan 16, 2005 at 14:52 UTC |