Applying the Law of Demeter

Brett g Porter BgPorter at NOartlogicSPAM.com
Thu Dec 12 09:47:19 EST 2002


"Max M" <maxm at mxm.dk> wrote in message news:3DF88702.6060208 at mxm.dk...
> John Ochiltree wrote:
> > "Peter Hansen" <peter at engcorp.com> wrote in message
>
> > Also, I've never come across the 'Law of Demeter'. is it something like
the
> > succession of the priests of Diana :-) Please enlighten me.
>
>
> It's about hiding implementation behind an interface.
>
Also check out http://www.ccs.neu.edu/home/lieber/LoD.html , which sez
(among other things...):
<quote>
The Law of Demeter was originally formulated as a style rule for designing
object-oriented systems. "Only talk to your immediate friends" is the motto.
The style rule was discovered at Northeastern University in the fall of 1987
by Ian Holland.

A more general formulation of the Law of Demeter is: Each unit should have
only limited knowledge about other units: only units "closely" related to
the current unit. Or: Each unit should only talk to its friends; Don't talk
to strangers.

In this general form, the LoD is a more specific case of the Low Coupling
Principle well-known in software engineering. The Low Coupling Principle is
very general and we tried to make it more specific. The benefit of the
specific Law of Demeter shown below is that it makes the notion of
unnecessary coupling very explicit.
</quote>



--
//  Today's Oblique Strategy (© Brian Eno/Peter Schmidt):
//  Work at a different speed








More information about the Python-list mailing list