3 ms·
The point of the law is that if your conditions are true, you are designing the code incorrectly. The point is to avoid making what should be transitive depend
by slowmovintarget 7y ago
The point of the law is that if your conditions are true, you are designing the code incorrectly.
The point is to avoid making what should be transitive dependencies into direct dependencies. The reason for this is that you may terminate transitive dependencies with interfaces, but only if you don't write train wrecks like a.getB().getC().doTheThing(). You should, compose the interfaces so that you are expressing a.doTheThing().
But sometimes ya gotta do what ya gotta do, which is why this was later comically referred to as "The Jolly Good Principle of Demeter" instead of "Law".
- wongarsu 7y ago>The Jolly Good Principle of Demeter Or as Jesus said: The Law of Demeter was made for man, not man for the Law of Demeter (Mark 2:27).