Answered Should getters and setters be used for everything?

WB1975

Well-known member
Joined
Apr 3, 2020
Messages
87
Programming Experience
Beginner
Should getters and setters be used for every bit of data you get from a user?

If I have a questionnaire getting data from a user

should getters and setters always be used to get/set information like a name address age etc etc

i understand what they are? just dont know their relevance and how important they actually are.
 
They are called properties. If you have a class and need to pass object state in or out of the class you use properties (always), the object state itself is stored in backing fields. Auto-Implemented Properties can simplify this.
 
Back
Top Bottom