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:

    There is ... but one response possible from us: Force, Force to the uttermost, Force without stint or limit, the righteous and triumphant Force which shall make Right the law of the world and cast every selfish dominion down in the dust.
    Woodrow Wilson (1856–1924)

    The law is a great thing,—because men are poor and weak, and bad. And it is great, because where it exists in its strength, no tyrant can be above it. But between you and me there should be no mention of law as the guide of conduct. Speak to me of honour, and of duty, and of nobility; and tell me what they require of you.
    Anthony Trollope (1815–1882)

    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)