当类由于某种设计原因未实现方法时,返回哪个 HRESULT?
假设我有一个设计不太好的 COM 接口,并且某些类在逻辑上无法实现其方法之一。
例如,有一些类似 Explode()
的方法,许多类无法合理地“爆炸”,但仍然必须实现该方法并且需要返回适当的错误代码。
在这种情况下我会返回 E_NOTIMPL
吗?对我来说,这段代码意味着“尚未实现,请在 2.0 版本中查看”。当一个方法由于某些严重的设计原因而永久不被类实现时,是否也应该使用它?
Suppose I have a not so well designed COM interface and some classes just logically can't implement one of its methods.
Like, for example, there's some method like Explode()
and many classes just can't reasonably "explode" but still have to implement that method and need to return an appropriate error code.
Do I return E_NOTIMPL
in such cases? To me this code means "not yet implemented, check back in version 2.0". Should it also be used when a method is permanently not implemented by a class for some serious design reason as well?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您当然可以为此添加自己的
HRESULT
,但在我看来,在这种情况下返回E_NOTIMPL
是完全有效的。我从来不认为E_NOTIMPL
暗示了稍后实施的意图。You could certainly add your own
HRESULT
for this but in my view it's perfectly valid to returnE_NOTIMPL
in this instance. It's never been my understanding thatE_NOTIMPL
implied an intention to implement at some later date.