Data encapsulation
Comes from the earlier modular programming methodology.
Objects may hide (or encapsulate) their data, and allow it to be changed only via a function interface.
-
Rationale
Gives much better control of what is allowed to change the data and when.
Makes it easy to say that something else must happen every time some data is changed.
-
Benefits
Much easier to follow code logic than horrible global variables.
Since the exact implementation of storage is hidden from the rest of the program, is simple to change the implementation: the rest of the program needn't change.
-
Examples