DEV Community

Discussion on: How I finally understood what Encapsulation is

Collapse
 
furiabhavesh profile image
Bhavesh Furia

I read a statement somewhere long time back

When a shopkeeper asks you for money, will you give them your wallet to take the money out ? If you do, then you are breaking encapsulation. The same logic applies to classes and access to methods. In general, public getters and setters result in breaking encapsulation