4 ms·
There is in my mind another important benefit of following the Law of Demeter: it minimizes coupling. Even in functional programming if you are digging into a
by Conlectus 10y ago
There is in my mind another important benefit of following the Law of Demeter: it minimizes coupling.
Even in functional programming if you are digging into a data structure 5 levels deep, you are potentially coupling a function to 5 different structures, rather than just one.
For example: game.player.bbox.topLeft.x has the potential to break if the game, player, bbox, or point structure change, which makes it fragile. If using an IP language with inheritance, it could also break if any of their super classes change.
- TickleSteve 10y agoCoupling is what the LoD is about, not mutability, its not just another important benefit, its the main point.