Synonym: information hiding
Encapsulation is one of the most important characteristics of an object oriented system.
describes encapsulation as
[BOO91, p. 513]
As the figure of the object MyCar shows, all of its variables are enclosed inside the object's methods and may only be changed by those methods. As it is, when you want to accelerate a real-world car, you don't have to know exactly how the car's engine works. You just have to know that you have to step on the gas pedal and change the gear.
This leads to an easy-to-use interface, with benefits for the user, as well as for the developer:
» The user doesn't have to know details of the internal structure and functionality of an object. What he/she must know is, which operations can be done on the object to change its state.
» The developer can change or improve any implementation details, as long as the interface doesn't change. Another advantage is that all functionality is enclosed in the same object, what makes object handling easier.
As mentioned before, an object oriented system consists of "classes arranged in a class hierarchy". One class at the top of this hierarchy serves as the base for other classes, which should have the same or additional properties.
This process is called inheritance.