你见过的最不有用的评论是什么? [英] What's the least useful comment you've ever seen?

查看:92
本文介绍了你见过的最不有用的评论是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们都知道,评论我们的代码是编码风格的重要组成部分,使我们的代码可以理解为下一个人,或甚至我们自己在6个月左右。

We all know that commenting our code is an important part of coding style for making our code understandable to the next person who comes along, or even ourselves in 6 months or so.

然而,有时候一个评论不会削减芥末。我不是在谈论明显的笑话或放空的挫折,我在说的看似是试图解释的评论,但做得那么糟糕,他们可能不会在那里。 太短的评论太秘密,或者只是简单错误

However, sometimes a comment just doesn't cut the mustard. I'm not talking about obvious jokes or vented frustraton, I'm talking about comments that appear to be making an attempt at explanation, but do it so poorly they might as well not be there. Comments that are too short, are too cryptic, or are just plain wrong.

作为一个古怪的故事,你能分享一些你所看到的,只是,如果不明显,代码它指的是并指出它有什么问题?

As a cautonary tale, could you share something you've seen that was really just that bad, and if it's not obvious, show the code it was referring to and point out what's wrong with it? What should have gone in there instead?

另请参阅:

推荐答案

我曾经在一个有奇怪的C编译器的项目上工作。除非在两个语句之间插入注释,否则它对一个有效的代码段发出错误。所以我将注释改为:

I once worked on a project with a strange C compiler. It gave an error on a valid piece of code unless a comment was inserted between two statements. So I changed the comment to:

// Do not remove this comment else compilation will fail.

而且效果很好。

这篇关于你见过的最不有用的评论是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆