Lots of information on Stack about this and good advice here and also non-stack there not to forget this but, as a Java programmer, it feels as if Gosling is standing behind me with paddle when I consider making instance members public to avoid getters.
I know there are many schools of thought on this from using friend
declarations to many different flavors and styles of getter/setter. Is it an acceptable practice always for private variables to have a getter (or setter if needed).
What specifically should I consider regarding their avoidance using simple rules. I think the answers given above are good but add complexity to the decision.
Aucun commentaire:
Enregistrer un commentaire