Is it a good practice to implement logic in properties

前端 未结 8 665
傲寒
傲寒 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-05 03:07

    Property access is expected to be instantaneous (no long waits), consistent (no changing values), and safe (no exceptions). If you can make those guarantees, I think putting logic in properties is OK.

提交回复
热议问题