首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >你见过的最不实用的评论是什么?

你见过的最不实用的评论是什么?
EN

Stack Overflow用户
提问于 2018-12-08 05:43:10
回答 2查看 0关注 0票数 0

我们都知道,对我们的代码进行评论是编码风格的一个重要部分,使我们的代码可以理解为下一个人,或者甚至是我们在6个月左右的时间。

然而,有时评论不会削减芥末。 我不是在谈论明显的笑话或通风挫折,我说的是那些似乎试图解释的评论,但这样做很差,他们可能不会在那里。 评论太短,太神秘,或者只是完全错误。

作为一个故事,你能否分享一些你曾经看过的那些真的那么糟糕的东西,如果不是很明显的话,请展示它所指的代码并指出它有什么问题?

EN

回答 2

Stack Overflow用户

发布于 2018-12-08 14:18:11

未填充的javadoc样板评论特别无用。他们消耗了大量的屏幕空间而没有贡献任何有用的东西。最糟糕的是,出现一个这样的评论,其他数百个肯定会潜伏。

代码语言:javascript
复制
/**
 * Method declaration
 *
 *
 * @param table
 * @param row
 *
 * @throws SQLException
 */
void addTransactionDelete(Table table, Object row[]) throws SQLException {
票数 0
EN

Stack Overflow用户

发布于 2018-12-08 15:25:25

像这样:

代码语言:javascript
复制
// This method takes two integer values and adds them together via the built-in
// .NET functionality. It would be possible to code the arithmetic function
// by hand, but since .NET provides it, that would be a waste of time
private int Add(int i, int j) // i is the first value, j is the second value
{
    // add the numbers together using the .NET "+" operator
    int z = i + j;

    // return the value to the calling function
    // return z;

    // this code was updated to simplify the return statement, eliminating the need
    // for a separate variable.
    // this statement performs the add functionality using the + operator on the two
    // parameter values, and then returns the result to the calling function
    return i + j;
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100000921

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档