We have mentioned encapsulation and interface many times and in different contexts. It was neither accidental nor intentional. It was unavoidable. Encapsulation and interface were born out of necessity to keep the implementation hidden as much as possible. It addresses two problems that plagued early programming:
- Unregulated shared access to the data
- Difficulties in changing the code when the relations between parts are not well structured
OOP is a successful solution. It ensures controlled access to the data (object state) and flexibility (freedom to change) the implementation as needed as long as the interface is not changed. In addition, it helps to organize the design and development of software. ...