You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: design-patterns/law-of-demeter.md
-47Lines changed: 0 additions & 47 deletions
Original file line number
Diff line number
Diff line change
@@ -6,50 +6,3 @@
6
6
7
7
## Mnemonic for the Law of Demeter
8
8
The post [Visualization Mnemonics for Software Principles](http://www.daedtech.com/visualization-mnemonics-for-software-principles) by [Erik Dietrich](https://github.com/erikdietrich) provides a very effective trick to understand (and never forget anymore) what the Law of Demeter is. An Italian translation is available [here](https://github.com/arialdomartini/mnemonics/blob/law-of-demeter/README-italian.md).
9
-
10
-
## Code Example
11
-
An example of code violating the Law of Demeter is provided by [Krzysztof Grzybek](https://github.com/krzysztof-grzybek)
12
-
13
-
```javascript
14
-
classPlane {
15
-
constructor(crew) {
16
-
this.crew= crew;
17
-
}
18
-
19
-
getPilotsName() {
20
-
this.crew.pilot.getName();
21
-
}
22
-
}
23
-
24
-
classCrew {
25
-
constructor(pilot) {
26
-
this.pilot= pilot;
27
-
}
28
-
}
29
-
30
-
classPilot {
31
-
getName() {
32
-
// ...
33
-
}
34
-
}
35
-
```
36
-
37
-
It's bad, because it creates tight coupling between objects - they are dependent on internal structure of other objects.
0 commit comments