问题描述
当创建一个新的C ++头/源文件时,你要添加什么信息到顶部?例如,您是否添加日期,您的姓名,文件描述等?您是否使用结构化格式的此类信息?
When creating a new C++ header/source file, what information do you add to the top? For example, do you add the date, your name, a description of the file, etc.? Do you use a structured format for this information?
例如
// Foo.cpp - Implementation of the Foo class
// Date: 2008-25-11
// Created by: John Smith
我知道一个团队将CVS提交消息嵌入到每个文件的脚下,但我不确定我要走这么远...
One team I know embeds CVS commit messages to the foot of each file, but I'm not sure I want to go this far...
推荐答案
有关创建文件的人员以及何时编辑文件以及何时编辑文件的信息均在源代码管理中。如果您的团队对签到注释有良好的实践,那么您也会知道每个更改的原因。
Information about who created a file and when and who edited it and when is all in source control. If your team has good practices around check-in comments, then you'll know the reasons for each change too. No need for comments for that stuff.
我认为这是100%的合法性,甚至 - 放置一个注释块,只要有必要,解释的目的类/模块。当下一个人改变它时,他们会更好地了解整体愿景,以及这个文件是否适合他们改变的地方。
I think it's 100% legit - wise, even - to put a comment block, as long as is necessary, explaining the purpose of the class/module. When the next person goes to change it, they'll have a better idea of the overall vision and whether this file is the appropriate place for their change.
有些商店版权声明和其他法律文件夹在源文件中的注释。这使我感到愚蠢 - 如果你的(非OSS)源代码已经在没有你的知识或许可的情况下,把它发送到别人的服务器,版权声明可能不会阻止他们做任何事情。 IANAL,YMMV。
Some shops put copyright notices and other legal folderol in source file comments. This strikes me as just silly - if your (non-OSS) source code has made it onto someone else's servers without your knowledge or permission, a copyright notice is probably not going to deter them from doing anything with it. IANAL, YMMV.
这篇关于您是否在每个.hpp / .cpp文件的顶部添加信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!