Re:Law of Demeter and immutability
by TickleSteve on Friday September 30, 2016 @12:07PM
(#12613300)
Coupling is what the LoD is about, not mutability, its not just another important benefit, its the main point.
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.