接口所需的方法并不总是有意义

Method required by Interface not always meaningful

从 C# class,我可以访问一组 WCF Web 服务,这些服务通过 Verastream Host Integrator 与大型机对话。它基本上是花哨的屏幕抓取。 Web 服务都是关于检索或更新数据——没有业务逻辑——所以我的想法是使用存储库模式构建数据(转换?)层。

综上所述,我的存储库 class 都实现了一个需要 Retrieve() 和 Update() 的 IRepository 接口。对于一小部分存储库 classes,它们面临具有检索但没有更新的服务,作为最佳实践,我该怎么做?我是否只让 Update 方法抛出 NotImplementedException(),如果是这样,我如何与使用我的 class 的任何人沟通 Update() 没有损坏,但不会被使用。

Do I just leave the Update method throwing a NotImplementedException()

改用NotSupportedException

how do I communicate to anyone who uses my class that Update() is not broken, but not to be used

有一个东西叫做 文档!

此外,NotSupportedException 很好地表明 Update 不支持某些给定的服务实现。它没有损坏,但不受支持。