简体   繁体   English

内联存储XML文档,还是将其存储在单独的文件中?

[英]Store XML documentation inline, or in a separate file?

For years I've been storing XML documentation inline in my source code and putting up with a "sea of green", but I recently found out about the <include file="..." path="..."/> directive that can be used in Visual Studio to move documentation into it's own XML file. 多年以来,我一直将XML文档内联存储在源代码中,并忍受着“一片绿色”,但最近我发现了<include file="..." path="..."/>指令,可以在Visual Studio中使用该指令将文档移到它自己的XML文件中。 Apparently intellisense will still work using this method, as will Sandcastle etc for help file generation. 显然,Intellisense仍然可以使用此方法工作,Sandcastle等也可以使用该方法来生成帮助文件。

I was just wondering how others are handling the "sea of green" issue where code gets buried under mounds of documentation? 我只是想知道其他人如何处理代码被文档堆埋没的“绿色海洋”问题? Do you just learn to live with it, or do you move the XML documentation into a separate file and use inline comments where code clarification might be needed? 您是否只是学会使用它,还是将XML文档移到一个单独的文件中,并在可能需要澄清代码的地方使用内联注释?

Pros 优点

  • The code file becomes a lot "cleaner". 代码文件变得更加“干净”。
  • It makes it easier to browse the code and locate a specific code block/method. 这样可以更轻松地浏览代码并找到特定的代码块/方法。

Cons 缺点

  • It may make the code harder for strangers to grok if there is no inline documentation. 如果没有内联文档,可能会使陌生人难以理解该代码。
  • The absence of documentation may create a tendency to forget about the XML file and not update documentation when the code changes. 缺少文档可能会导致忘记XML文件,并且在代码更改时不更新文档的趋势。

http://msdn.microsoft.com/en-us/library/9h8dy30z.aspx http://msdn.microsoft.com/en-us/library/9h8dy30z.aspx

I just leave it inline and use these Visual Studio - Command to collapse all sections of code? 我只是将其内联,并使用这些Visual Studio-Command折叠代码的所有部分? commands to collapse and expand code when I'm looking through large files. 查看大文件时使用命令折叠和扩展代码。 In this case I think the cons outweigh the pros. 在这种情况下,我认为弊大于利。 Unless you and your fellow developers are extremely diligent about documentation I don't see that method working very well. 除非您和您的开发人员对文档非常勤奋,否则我认为该方法不能很好地工作。 Documentation is already lacking in most code bases I've seen, so increasing the difficulty of adding it, in my opinion, is a bad idea. 我见过的大多数代码库都已经缺少文档,因此,我认为增加添加它的难度是一个坏主意。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM