Difference between revisions of "Law of Demeter"

From Wiki @ Karl Jones dot com
Jump to: navigation, search
(Created page with "The '''Law of Demeter''' ('''LoD''') or '''principle of least knowledge''' is a design guideline for developing software, particularly Object-orient...")
 
(No difference)

Latest revision as of 07:24, 28 April 2016

The Law of Demeter (LoD) or principle of least knowledge is a design guideline for developing software, particularly object-oriented programs.

See also Separation of concerns.

Description

In its general form, the LoD is a specific case of loose coupling.

The guideline was proposed at Northeastern University towards the end of 1987, and can be succinctly summarized in each of the following ways:

  • Each unit should have only limited knowledge about other units: only units "closely" related to the current unit.
  • Each unit should only talk to its friends; don't talk to strangers.
  • Only talk to your immediate friends.

The fundamental notion is that a given object should assume as little as possible about the structure or properties of anything else (including its subcomponents), in accordance with the principle of "information hiding".

Name

It is named for its origin in the Demeter Project, an adaptive programming and aspect-oriented programming effort.

The project was named in honor of Demeter, “distribution-mother” and the Greek goddess of agriculture, to signify a bottom-up philosophy of programming which is also embodied in the law itself.

See also

External links