-
Law of Demeter in programming
Law of Demeter in programming You could in short paraphrase as “Don’t talk to strangers!” or “Keep Your hands in your pockets”. A class needing data from a deep chain of objects like – user.getAddress().getStreet().getNumber().It is visible very often in OOP, less in functional approachess ! The Law of Demeter states that method only knows its closest dependencies: itself, passed parameters, created objects, and own fields. Should not be used with dot chains ( they were so fancy when we started Java 8 back in the day). What to Remember? Where Law of Demeter comes from ? Why Demeter ? The Law of Demeter in progamming takes its name from…


