Clean Code: Should Objects have public properties?

前端 未结 13 1753
礼貌的吻别
礼貌的吻别 2021-01-03 20:40

I\'m reading the book \"Clean Code\" and am struggling with a concept. When discussing Objects and Data Structures, it states the following:

  • Objects hide thei
13条回答
  •  灰色年华
    2021-01-03 21:12

    Indeed a C# property is not data, is an accessor, so it's a function operating on data.

    You should avoid public fields, not public properties.

提交回复
热议问题