Unit content
Interfaces, contracts and information hiding
A software interface is the part of a component that other components are allowed to rely on. Its contract describes observable behavior; the implementation remains free to change while that contract is preserved.
Information hiding deliberately keeps internal decisions behind that boundary: data representation, helper functions, caches, algorithms and other details that callers do not need to know.
A narrow interface reduces the amount of knowledge shared between components. If callers manipulate internal state directly, an implementation change can force changes throughout the codebase.
Good interfaces expose concepts meaningful to their users rather than merely mirroring internal storage. They also make invalid or ambiguous uses difficult where the type system or API design permits it.
Encapsulation is therefore not about making everything private. It is about choosing explicitly which facts become dependencies of other code and which remain replaceable implementation details.