usage of property vs getters/setters in business classes

前端 未结 4 1264
暖寄归人
暖寄归人 2020-12-09 11:18

When dealing with buisness classes, like the typical Customer and Employee classes, is it better to use getters and setters only or to use properties?

I am translati

4条回答
  •  误落风尘
    2020-12-09 11:26

    No. Getters and setters are only there in Java because it doesn't have properties. It makes for much cleaner code to use properties. And then if you need a getter or a setter, you can build it into the property, but you don't have to litter the accessing code with a bunch of function calls.

提交回复
热议问题