What is encapsulation?
ncapsulation is a principle based on hiding the state of objects
estricting their access to various parts of your program
achieved with the use of private access modifiers and the getter and setter methods
How do you create a fully encapsulated class?
Make all the instance variables of a class private.
Only use getter and setter methods to read or write values
make your class read-only or write-only by declaring only getter or setter methods
add variable logic/constraints in the setter methods
contribute to the objective of code-safety
Glasp is a social web highlighter that people can highlight and organize quotes and thoughts from the web, and access other like-minded people’s learning.