我应该如何记录继承的成员?

发布于 2024-09-15 04:52:13 字数 1431 浏览 6 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

虐人心 2024-09-22 04:52:13
  • 根据代码契约记录接口方法不要评论其实现,仅评论其语义目的,即它应该做什么,而不是如何做。本文档的受众是您的实现者您的用户:该方法将被实现并被调用。

  • 只需说明抽象方法实现了接口方法并链接到它,即可记录该抽象方法。对此没有什么额外可说的,并且重复注释违反了 DRY(不要重复自己)原则:您必须记住在两个地方对其进行任何更改。 (当然,对于不实现接口方法的抽象方法,请以与记录接口方法相同的方式记录它。)

  • 记录具体实现说它实现了接口方法和/或它覆盖了抽象成员。如果与调用者相关,则可以选择添加有关其实现的信息 - 例如,其性能特征或可能抛出异常的情况等。

  • Document the interface method according to its code contract. Do not comment on its implementation, only on its semantic purpose, i.e. what it’s supposed to do, not how. The audience for this documentation is both your implementors and your users: the method will both be implemented as well as called.

  • Document the abstract method simply by saying that it implements the interface method and linking to it. There is nothing extra to be said about it, and duplicating the comment violates the DRY (Don’t Repeat Yourself) principle: you would have to remember to make any change to it in both places. (Of course, in the case of an abstract method that doesn’t implement an interface method, document it in the same way that you would document an interface method.)

  • Document the concrete implementation by saying that it implements the interface method and/or that it overrides the abstract member. Optionally add information about its implementation if it is relevant to the caller — for example, its performance characteristics, or situations in which it might throw, etc.

妞丶爷亲个 2024-09-22 04:52:13

评论
关于帖子的一部分
作者:埃里克·阿纳斯塔斯

仅仅复制粘贴似乎是错误的
每个级别都有相同的描述。

我可以想象仅仅复制是错误。然而,可以让 doxygen 为您复制它,然后更改您想要为该实现/范围更改的内容。
有关更多信息,您可以查看@copydoc 的说明

remark
on part of post
by Eric Anastas

It seems wrong to just copy and paste
the same description at each level.

I can imagine it being wrong to just copy. It is however possible to let doxygen copy it for you and then change what you would like to change for that implementation/scope.
For more information, you can look at the description for @copydoc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文