Sep 7, 2018 · 1 min read
The “container” object simply just holds a reference to the object it got as argument of a setter or constructor. It is in no way more privileged than anybody else holding a reference to that same object. The referred to object object itself is still encapsulated however since its state can only be modified by calling its methods.
Immutability may be preferable but I think it is orthogonal to encapsulation. And it is orthogonal to Functional vs. OO because Object Oriented languages can and typically do provide ways to implement immutability.