注释代码已删除 [英] Commenting code that is removed

查看:50
本文介绍了注释代码已删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注释已删除的代码是一种好习惯吗?例如:

Is it a good practice to comment code that is removed? For example:

// Code to do {task} was removed by Ajahn on 10/10/08 because {reason}.

在我的开发人员小组的同行评审中,有人指出我们应该注释以下代码行:被删除。我认为这是一个可怕的建议,因为它会使代码杂乱无章。

Someone in my developer group during a peer review made a note that we should comment the lines of code to be removed. I thought this was a terrible suggestion, since it clutters the code with useless comments. Which one of us is right?

推荐答案

通常,删除的代码不应被注释,正是因为它会使代码库混乱(以及为什么要对不存在的东西发表评论?)。

Generally, code that is removed should not be commented, precisely because it clutters the codebase (and, why would one comment on something that doesn't exist?).

您的缺陷跟踪系统或源代码管理管理工具就是这些评论的来源。

Your defect tracking system or source control management tools are where such comments belong.

这篇关于注释代码已删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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