Let’s break Demeter’s Law.

Problems
Unnecessary Indirection
Empty Classes
Readability
Solutions
1. Remove Middle man.
Sample Code
Wrong
Right
Detection
Same as its opposite smell, We can detect this small using parsing trees.
Tags
Coupling
Declarative
Readability
Conclusion
This is exactly the opposite to Message Chain. We make explicit the message chain.
Relations
Code Smell 08 — Long Chains Of Collaborations
Making long chains generate coupling and ripple effect. Any chain change breaks the code.medium.com
More info
Middle Man
If a class performs only one action, delegating work to another class, why does it exist at all?refactoring.guru
Remove Middle Man
Edit descriptionrefactoring.com
https://wiki.c2.com/?MiddleMan
Remove middleman | IntelliJ IDEA
The Remove Middleman refactoring lets you replace all calls to delegating methods in a class with the equivalent calls…www.jetbrains.com
Law of Demeter - Wikipedia
The Law of Demeter ( LoD) or principle of least knowledge is a design guideline for developing software, particularly…en.wikipedia.org
Whenever I have to think to understand what the code is doing, I ask myself if I can refactor the code to make that understanding more immediately apparent.
Martin Fowler
Software Engineering Great Quotes
Sometimes a short thought can bring amazing ideas.medium.com
This article is part of the CodeSmell Series.
How to Find the Stinky parts of your Code
The code smells bad. Let’s see how to change the aromas.medium.com