Why we need protection for data variable s ? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

Why we need protection for data variable s ?

who's gonna be broken the security of encapsulation? who is out side users ?

26th May 2017, 5:40 AM
MUJEEB I S
MUJEEB I S - avatar
1 ответ
0
It's more about architecture. Encapsulation hides variables or some implementation that may be changed so often in a class to prevent outsiders access it directly. They must access it via getter and setter methods. It is important to take into consideration what parts of your program are doing what. You should generally split up your code into logically consistent chunks.
26th May 2017, 3:08 PM
Felipe Cruz
Felipe Cruz - avatar