3 ms·
Encapsulation also helps enforce interfaces. Anything outside of an object should only interact with it via an external interface. This allows you to reason a
by hexagonc 13y ago
Encapsulation also helps enforce interfaces. Anything outside of an object should only interact with it via an external interface. This allows you to reason about the interaction of objects independently of the implementation of those objects. In theory, this allows you to change the implementation of an object without the interacting objects knowing, thus reducing the overall complexity of the program as well as potential bugs.