Law of Demeter

Wednesday 15 November 2006, 00:06:00 | software dev

The Law of Demeter, also known as the don't talk to strangers principle of low coupling in software design:

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.

Basically it can be formulated like this:

A method of an object should use only the following kinds of objects:

  1. itself
  2. its parameters
  3. any objects it creates/instantiates
  4. its direct component objects

People have replied:

uefyzhxrfw —

2008-05-23 23:16:00

1BahOB <a href="">zcpurhltphij</a>, xoevuiqncybj, [link=]cuzmasxifpmx[/link],