Interface should not have properties?

后端 未结 13 1134
攒了一身酷
攒了一身酷 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 22:57

    The only way I can think about, why properties are bad for interfaces is, when you define interfaces for services (such as WCF, WebServices, Remoting) that are hosted on diffrent machines or application domains.

    Cause properties imply that they are fast (aka. getting and setting values) which is not true for services, due to network and serialization activity. An explizit method for getting or setting values in service interfaces imply it could take some time to complete the operation.

提交回复
热议问题