OOP Demystified

Some programmers may think encapsulation is simply a clever way to make your program orderly by putting related attributes and procedures under one roof. Although this is true, protection is the reason for encapsulation.

Previously you learned in this chapter that there is really no protection against the improper use of attributes and procedures in procedural programming. Both are available for a programmer to use without any checks and balances .

You might say that encapsulation enables a programmer to institute those checks and balances by placing attributes and procedures in a class and then defining rules in the class to control its access.

Категории