+ 2
I really do not understand the "property" and the "setter". The "property" makes the attribute read-only, but the "setter" makes the attribute mutable. So if we want to use "property", why we need to introduce the "setter".
2 Answers
+ 3
Properties are OOP feature. Mind getter and setter as of events, that occurs transparently when someone access attribute. It may be useful to verify or format value.
+ 3
it's good to have control over your variables rather than letting them be accessed freely. You may want to, for instance, deny a change in a variable or even call another method in your setter