Is it a good practice to implement logic in properties

前端 未结 8 686
傲寒
傲寒 2021-02-05 02:39

we use ASP.NET with C# and based on open source projects/articles I passed through, I found many properties were including a logic but when I did so the team-le

8条回答
  •  暖寄归人
    2021-02-05 03:18

    In my opinion this is absolutely ok. The way I see it, the only justification for having properties as a language feature in the first place is that you can have logic in them. Otherwise you may as well just allow direct access to the underlying data members.

提交回复
热议问题