What are the virtues of using XML comments in .NET?

前端 未结 6 1654
醉话见心
醉话见心 2021-01-04 23:56

I can\'t understand the virtues of using XML comments. I know they can be converted into nice documentation external to the code, but the same can be achieved with the much

6条回答
  •  时光说笑
    2021-01-05 00:14

    1. The ide picks up the comments and shows them when using that method.
    2. Everyone who programs C# is probably familiar with the XML commenting system. There's less to learn for a new hire.

    I'm not saying that DOxygen isn't better, it's just that the xml commenting system is more familiar to everyone, and that goes a long way. It's just one less thing you have to train a new hire to do.

    As far as leaving variables uncommented. What may be obvious to you, won't be to someone else (or to you 6 months later).

    Ok now I think I see what you are asking.

    1. Obfuscating comments. The color coding helps. Personally, I quickly scan past the grey text and only read what's green unless I need to read the xml text. (in my settings at least).

    2. We have large monitors so we get more code on the screen in general. (It's cheaper to buy a large monitor than to retrain people generally). The other thing about this too, is that I bet you are only actively looking at one function at a time, so if that entire function fits on a page, you probably aren't suffering too much from not seeing more code. Now if the functions are long, then I could see that being a problem.

    3. We put the summary comments on a single line when possible (assuming it isn't really large). That cuts down on the used space.

    4. I don't know if DOxygen does this, but you can collapse the comments so they are out of the way.

提交回复
热议问题