Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Law of Demeter
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Design guideline for software development}} The '''Law of Demeter''' ('''LoD''') or '''principle of least knowledge''' is a design guideline for developing [[software]], particularly [[Object-oriented programming|object-oriented programs]]. In its general form, the LoD is a specific case of [[loose coupling]]. The guideline was proposed by Ian Holland at [[Northeastern University]] towards the end of 1987,<ref>{{Cite journal |last1=Lieberherr |first1=K.J. |last2=Holland |first2=I.M. |date=September 1989 |title=Assuring good style for object-oriented programs |url=http://dx.doi.org/10.1109/52.35588|journal=IEEE Software |volume=6 |issue=5 |pages=38β48 |doi=10.1109/52.35588 |s2cid=12651917 |issn=0740-7459|url-access=subscription }}</ref> and the following three recommendations serve as a succinct summary:<ref>{{cite web |url=https://github.com/emerleite/demeter |title= README.markdown: Demeter |last = Macedo |first= Emerson |publisher=GitHub |access-date=2012-07-05 }}</ref> # 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]]". It may be viewed as a corollary to the [[principle of least privilege]], which dictates that a module possess only the information and resources necessary for its legitimate purpose. 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 [[top-down and bottom-up design|bottom-up]] philosophy of programming which is also embodied in the law itself.<ref>{{Cite web |title=Law of Demeter: Principle of Least Knowledge |url=https://www.khoury.northeastern.edu/home/lieber/LoD.html |access-date=2024-11-07 |website=www.khoury.northeastern.edu}}</ref>{{Non-primary source needed|date=November 2024}}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)