In 2003/2004 the Law of Demeter was revisited for Karl Lieberherr's ICSE 2004 keynote paper and presentation. The Law of Demeter was refined from "Only talk to your friends" to "Only talk to your friends who share your concerns" and this refined form is called the Law of Demeter for Concerns (LoDC). The LoDC is best followed by using Aspect-Oriented Software Development (AOSD) techniques such as AspectJ or DJ. On the other hand, the LoDC leads to better AOSD. Properly following the LoDC has two key benefits: It leads to better information hiding (using the technique of structure-shyness or the more general technique of concern-shyness) and to less information overload for the software developer.
This paragraph is added in September 2011. I am pleased that there is continued attention in the software development domain to the Law of Demeter. The Clean Code Talks series in the Google Tech Talks refers to the Law of Demeter as a promoter of clean code. Here is an enjoyable talk by Miskov Hevery from Google. The Clean Code Talks - Don't Look For Things! I also recommend: OO Design for Testability also by Miskov Hevery. There is also continued activity in the blog sphere. This search finds about a dozen posts from Google that mention the Law of Demeter. From the Google "Testing on the Toilet" Loose Coupling with Demeter. Here is another recent example from July 2011: Demeter: It's not just a good idea. It's the Law by Avdi Grimm in Virtuous Code. A recent paper from the University of Zurich from Fall 2011: An Empirical Validation of the Benefits of Adhering to the Law of Demeter (local copy: An Empirical Validation of the Benefits of Adhering to the Law of Demeter ) Conclusion: quote: "we conclude that obeying the Law of Demeter is a straight-forward approach for developers to reduce the number of bugs in their software."
This paragraph is added June 2013: The talk by Ben Orenstein at RailsConf 2013 provides a very good visualization of the Law of Demeter. See his first lightening talk at the beginning: Visualizing Law of Demeter. His topic is interesting: How to talk to Developers. You learn to sing at the end of the talk!
>From David.E.Smyth@jpl.nasa.gov Mon May 26 17:33:30 1997 >From: "David E. Smyth"
>To: email@example.com >Subject: Law of Demeter > >I have been using LoD pervasively since about 1990, and it has taken >firm hold in many areas of the Jet Propulsion Laboratory. Major systems >which have used LoD extensively include the Telemetry Delivery System (a >real-time database begun in 1990), the Flight System Testbed, and Mars >Pathfinder flight software (both begun in 1993). We are going to use LoD >as a foundational software engineering principle for the X2000 Europa >orbiter mission. I also used it within a couple of commercial systems >for Siemens in 91-93, including a Lotus Notes like system, and a email >system. ... > We have found, however, that breaking the LoD is very expensive! On > Mars Pathfinder, the integration costs of the law breaking parts of > the system were at least an order of magnitude higher, and we had > to pay that cost on every integration cycle -- not just once! We > should have paid the cost once by implementing a more sophisticated > protocol that did obey the LoD.
Synonyms: Principle of Least Knowledge.
Back to home page
Professor Karl Lieberherr College of Computer and Information Science, Northeastern University Boston, MA 02115 lieber at CCS dot NEU dot EDU Fax: (617) 373 5121