Improving the Design and Implementation of Object-Oriented Code: The Ongoing Quest for Data Integrity
As we've seen, accessor methods play a very important role in the design and implementation of object-oriented code. I stated earlier that OOP is just as much about the data as the code. In fact, encapsulating the data and the code inside a class is one of the three fundamental object-oriented tenets, along with inheritance and polymorphism.
Controlling access to data is vital, and techniques have evolved to embed this security into the language itself. Whereas C programmers of the pre-OOP era were responsible for enforcing data integrity, today compilers can handle much of this task. And anything that can be automated in this way is a major benefit.