Timeline for Why shouldn't I make variables public, but should use public getters/setters?
Current License: CC BY-SA 3.0
3 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 24, 2015 at 16:07 | comment | added | stonemetal | @Casey You're right eventually you will need getters and setters somewhere, and when that time comes they will be the right tool for the job. In general though getters and setters show a lack of encapsulation because the class's internal state is leaking out. | |
| Sep 22, 2015 at 20:33 | comment | added | Casey | I agree with the principle but, for instance, a Point class is at some point going to have to provide coordinates... how else than with accessors? | |
| Jul 13, 2014 at 0:48 | history | answered | stonemetal | CC BY-SA 3.0 |