Data Encapsulation
is the separation of the representation of data from the applications
that use the data at a logical level; a programming language feature that
enforces information hiding.
Example of Program Level Data Encapsulation.
Enclosing all parts of an abstraction within a container
Benefit
- to pretect access to the encapsulated (hidden) data
- Increased modularity.
|
Language Specific
- Most languages like Java have a "protection type"
that can be applied to data and operations.
- Publish access operations so users of a class are encoraged
to use these and not directly/access data.
- getX(), setX() operations.
In C++: Can do information hidding with protection type
declarations of private, public, etc.
|
|