2 ms·
It is a very abrupt dismissal along the lines of: encapsulation doesn't perfectly encapsulate, therefore it is useless. It is not perfect because the objects y
by jeremyjh 10y ago
It is a very abrupt dismissal along the lines of: encapsulation doesn't perfectly encapsulate, therefore it is useless.
It is not perfect because the objects your class may encapsulate may have been passed in a constructor by reference, meaning there is code outside your class that can mutate those objects.
Even in functional programming languages encapsulation is a useful concept - often in a functional language it is implemented with opaque data structures that can only be manipulated by the module which creates them (constructors are not exported).
I don't think it always means there are not shared references; it all depends on the role of the data in question.