This section contains 452 words (approx. 2 pages at 300 words per page) |
In computer programming, encapsulation is in its broadest sense the process of bringing together elements to produce a new entity. In this sense a function is itself a manifestation of encapsulation because it is a self-contained block of code that performs a set of actions and returns a value of a known type: a function "encapsulates" the combined functionality of the code within it to build new functionality. Similarly, user-defined data types like C structures, C++ and Java classes, and Perl "hashes" are examples of encapsulation because they encapsulate the data in them.
Indeed, object-oriented languages like C++ and Java profoundly depend upon encapsulation to create classes and objects as instances of those classes. Both of these languages contain keywords like "private" and "protected" that force the compiler to rigidly enforce the encapsulation of both data and functionality; encapsulating data in this way is called "data hiding."
Data...
This section contains 452 words (approx. 2 pages at 300 words per page) |