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.
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.
发布评论
评论(2)
根据代码契约记录接口方法。不要评论其实现,仅评论其语义目的,即它应该做什么,而不是如何做。本文档的受众是您的实现者和您的用户:该方法将被实现并被调用。
只需说明抽象方法实现了接口方法并链接到它,即可记录该抽象方法。对此没有什么额外可说的,并且重复注释违反了 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.
评论
关于帖子的一部分
作者:埃里克·阿纳斯塔斯
我可以想象仅仅复制是错误。然而,可以让 doxygen 为您复制它,然后更改您想要为该实现/范围更改的内容。
有关更多信息,您可以查看@copydoc 的说明。
remark
on part of post
by Eric Anastas
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.