Law of Demeter

The Law of Demeter (LoD) or Principle of Least Knowledge is a design guideline for developing software, particularly object-oriented programs. In its general form, the LoD is a specific case of loose coupling. The guideline was invented at Northeastern University towards the end of 1987, and can be succinctly summarized in one 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).

It is so 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.

Read more about Law Of Demeter:  In Object-oriented Programming, Advantages, Disadvantages

Famous quotes containing the words law of, law and/or demeter:

    No. I am not the law in your mind,
    the grandfather of watchfulness.
    I am the law of your members,
    the kindred of blackness and impulse.
    See. Your hand shakes.
    It is not palsy or booze.
    Anne Sexton (1928–1974)

    “... But here there is nor law nor rule,
    Nor have hands held a weary tool;
    And here there is nor Change nor Death,
    But only kind and merry breath,
    For joy is God and God is joy.”
    William Butler Yeats (1865–1939)

    But the house of the prudent countryman will be, of course, a place of honest manners; and Demeter Thesmophoros is the guardian of married life, the deity of the discretion of wives. She is therefore the founder of civilised order.
    Walter Pater (1839–1894)