是否可以在源代码中提供关于错误修复的注释? [英] Is it ok to put comments about bug fixes in the source code?

查看:210
本文介绍了是否可以在源代码中提供关于错误修复的注释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果是,你在哪里画线?我的同事和我不同意这个问题。我看到过这样的事情

And if so, where do you draw the line? My coworkers and I disagree on this subject. I have seen such things as

// fixes bug # 22

// fixed bug: shouldnt be decrementing
i++;

如果更改是相当重要的,这是否确定,并从根本上改变了什么方法写?或者你只是更改方法的摘要文本,以反映它现在的意图做什么?

Is it ok if the change is fairly significant, and radically changes what the method was written to do? Or do you simply change the summary text of the method to reflect what it is now meant to do?

我的意见是,这些信息应该放在源代码管理。有些人认为这是坏的,因为那样它将在源代码控制的上下文之外丢失(例如你切换系统并保留历史数据)。

My opinion is that this information should be put into source control. Some state that this is bad because then it will be lost outside of the context of source control (say you switch systems and want to keep historical data).

推荐答案

注释应该说明这些方法的工作原理。

Comments should explain how the methods work.

源代码管理解释了为什么要进行更改。

Source control explains why changes were made.

这篇关于是否可以在源代码中提供关于错误修复的注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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