Law of Demeter
Overview
Most time when we plan to upscale our application or maintain some features, we end up building it from scratch all over again. This is because any change or adding we would want to make will run across the entire codebase. This kind of codebase is not following the law of Demeter.
What is the Law of Demeter?
The Law of Demeter principle reduces dependencies and helps build components that are loosely coupled for code reuse, easier maintenance, and testability. This principle states that an object should never know the internal details of other objects. It was designed to promote loose coupling in software designs. LoD tells us that it is a bad idea for single functions to know the entire navigation structure of the system.
Below is a demonstration of LoD as give by @arunsasidharan
Law of Demeter violated
Law of Demeter observed