文件中的修改历史记录 [英] Modification history in a file

查看:469
本文介绍了文件中的修改历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经工作过几个地方,没有使用源代码管理。他们似乎习惯于围绕他们改变的代码发表评论的习惯,解释变化,使事情可以回复。

I have worked a few places which haven’t used source control. They seemed to get into the habit of putting comments around code they changed explaining the change so that things could be reverted.

我发现这使得代码很难阅读,并且已经相当坚持在引入源代码控制之后不需要这样的注释,因为修订历史会让你匹配门票与更改。

I have found that this makes the code very difficult to read, and have been fairly adamant that such comments are not needed after introducing source control as the revision history will let you match up tickets with changes.

但是现在,我不太确定,我认为记录文件中的文件的主要修订版本以及提交消息可能是好的。这应该使代码更可读。人们是否有最佳实践方法来记录对代码的更改,以便它不会太混乱,但仍然对某人尝试阅读它的解释?

However now, I am not so sure, I think it may be good to document major revisions to a file in a file as well as in the commit messages. This should make the code more readable. Do people have a best practices way of documenting changes to code, so that it is not too cluttered but is still explanatory to someone trying to read it?

只是为了清楚,我不是在谈论文件头(这是一个完整的其他参数)的变化,但在代码中的注释。

Just to be clear, I am not talking about a list of changes in the head of the file (which is a whole other argument) but comments in the code.

推荐答案

代码中的文档应该描述它附近的代码。如果代码更改,文档也应相应更改。版本控制系统应该负责管理什么已更改以及为什么它更改。让代码和它的文档做它的工作(做事情,描述如何/为什么这些事情完成),并让版本控制系统做它的工作(控制/文档的版本和更改)。

The documentation present in code should describe the code it is near. If the code changes, the documentation should also change accordingly. The version control system should take care of managing what changed and why it changed. Let the code and it's documentation do it's job (Doing things, and describing how/why those things are done), and let the version control system do it's job (controlling/documenting versions and changes).

每当您开始指示当前(当前代码)中的历史记录时,您都会遇到麻烦。只要想一下,如果有很多变化,那么一个特别变化很大的代码区域会是什么样子?!

Whenever you start indicating history in the present(current code), you are asking for trouble. Just think what a particularly change-heavy area of code would look like if it had a number of changes?!

这篇关于文件中的修改历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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