Answer the question
In order to leave comments, you need to log in
Should you always use encapsulation?
Some say it's not necessary and it's confusing. Someone says you should do it and everyone will expect you to do it in every class. The book says what you need. How to properly use encapsulation? Set variables via setters, get them via getters? Anytime and anywhere?
Answer the question
In order to leave comments, you need to log in
I think it all depends on the project. If the project grows, then in the future some kind of logic in setters and getters may be required, and if there is no logic, then such setters and getters are no different from an open variable
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question