- **Epistemic status:** #budding The Law of Demeter (LoD) or principle of the least knowledge is a software design principle with a focus on object-oriented programming proposed by Ian Holland at Northeastern University towards the end of 1987. Similar to the [[Modularity]] principle, it is a specific case of loose coupling. This principle can be summarized 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 focus is that an object should assume as little as possible about the structure and properties of anything else, including its subcomponents. ## Advantages Software tends to be easier to maintain and follows the [[Easier to Change (ETC) principle]] because, since objects are less dependent on the internal structures of other objects, the object's implementation can be changed without reworking the callers. ## Disadvantages Software can result in many wrapper methods being developed to be able to be utilized in components, increasing developing time and bloating the software. --- ## References - “Law of Demeter.” In _Wikipedia_, May 6, 2022. <https://en.wikipedia.org/w/index.php?title=Law_of_Demeter&oldid=1086427216>. - Thomas, David, and Andrew Hunt. _The Pragmatic Programmer, 20th Anniversary Edition: Journey to Mastery_. Second edition. Boston: Addison-Wesley, 2019.