Chapter 3. Resource Encapsulation
Along with abstraction and polymorphism, encapsulation is one of the main tenets of object-oriented programming. Resource encapsulation is a refinement of encapsulation, insofar as the encapsulated data are actually references to allocated resources, albeit that resource is a broad term. A resource can be other class instances, allocated memory, system objects, API/library states, and object states.
Data encapsulation is the protection of an encapsulating type's inner state to ensure consistency of that type, or to abstract the public interface to it. Resource encapsulation, however, is the wrapping up of a resource reference in order to provide a more robust interface to that resource and to help in managing it; ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access