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!
==Advantages== The advantage of following the Law of Demeter is that the resulting software tends to be more [[maintainability|maintainable]] and [[Adaptive reuse|adaptable]]. Since objects are [[Coupling (computer programming)|less dependent]] on the internal structure of other objects, object implementation can be [[Software configuration management|changed]] without reworking their callers. Basili et al.<ref name=Basili>{{cite journal | first1=Victor | last1=Basili | first2=L. | last2=Briand | first3=W. L. | last3=Melo | date=October 1996 | title=A Validation of Object-Oriented Design Metrics as Quality Indicators | journal=IEEE Transactions on Software Engineering | volume=22 | issue=10 | pages=751β761 | quote=As expected, the larger the WMC, the larger the probability of fault detection. | doi=10.1109/32.544352 | url=http://drum.lib.umd.edu/bitstream/1903/715/2/CS-TR-3443.pdf | hdl=1903/715 | hdl-access=free }}</ref> published experimental results in 1996 suggesting that a lower ''Response For a Class'' (RFC, the number of methods potentially invoked in response to calling a method of that class) can reduce the probability of [[software bug]]s. Following the Law of Demeter can result in a lower RFC. However, the results also suggest that an increase in ''Weighted Methods per Class''<ref>{{Cite web|url=https://maisqual.squoring.com/wiki/index.php/Weighted_Methods_per_Class|title=Weighted Methods per Class - Maisqual Wiki|website=maisqual.squoring.com|language=en|access-date=2018-09-20}}</ref> (WMC, the number of methods defined in each class) can increase the probability of software bugs. Following the Law of Demeter can also result in a higher WMC. A [[multilayered architecture]] can be considered to be a systematic mechanism for implementing the Law of Demeter in a software system. In a layered architecture, code within each [[Layer (object-oriented design)|layer]] can only make calls to code within the layer and code within the next layer down. "Layer skipping" would violate the layered architecture.
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)