[OOP] 03 - Encapsulation
encapsulation
- setting the access level in the class methods and attributes
- public
- protected
- private
getter and setter functions
-
helps access and change private attributes
-
getter function only retrieves the current value
- it cannot change the value
encapsulation boundaries
- private properties do not extend to child classes, or the public object
- protected properties extend to child classes, but not the public object
- when overriding with functions in the child classes,
- the access level can be same or weaker
- not stronger
- once the object is created,
- only public attributes and methods can be accessed