Interface should not have properties?

后端 未结 13 1016
攒了一身酷
攒了一身酷 2021-01-07 22:43

My office colleague told me today that is bad practice to use properties in interfaces. He red that in some MSDN article(s), which I couldn\'t find (well I was trying few ti

13条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-07 23:17

    I'll just add my voice in here as well - I've never come across this recommendation. A property is effectively a pair of get/set methods.

    Like every other design decision. If it genuintely makes sense; if it is appropriate for the system under design, if it doesn't cause maintenance problems, if it doesn't cause performance problems, there should be no reason you can't do it.

提交回复
热议问题