Java Conventions: use getters/setters WITHIN the class?

前端 未结 12 1821
被撕碎了的回忆
被撕碎了的回忆 2020-11-30 02:32

My professor really emphasizes protecting against privacy leaks by always using accessors and mutators to access private instance variables; however, do I have to use the ge

12条回答
  •  南笙
    南笙 (楼主)
    2020-11-30 02:55

    I use a mix of both. Accessor methods add more clutter so I use them only when the variable is used many times. If the variable is used only once or twice I don't use them.

提交回复
热议问题