Introduction
Getter and setter methods help you safely get and change the values inside an object. They keep data private and controlled.
When you want to protect data inside an object from being changed directly.
When you want to check or change data before saving it.
When you want to hide how data is stored inside an object.
When you want to make your code easier to maintain and understand.
When you want to follow good programming rules about data privacy.