你遇到过的源代码中最好的注释是什么?
当前回答
Get This hack!
在一行汇编代码中,在几页未注释的代码之后。
其他回答
public GetRandomNumber()
{
// Chosen by a fairly rolen dice
return 12;
}
在一个名为“Bar”的类中(这是一个不具有描述性名称的UI控件),类头文件:
/// <summary>I pity the "foo".</summary>
Remove()方法:
/// <summary>A "foo" and his money are soon parted.</summary>
更糟糕的是,业务合作伙伴从生成的文档中指出了这一点。更糟糕的是,这些可能是我们从那家伙那里得到的最接近有用文件的东西。
我想我有过这样的经历:
if (case1) { // trivial
...
}
else { // we are screwed
/* fill in later */
}
好吧,我可能用了一个比搞砸更强烈的词
我刚刚在。net的自定义Linq提供程序中找到了这个:
//select is a royal pain in the ass where
//the parameter passed to CreateQuery isn't actually the one that goes in the call
//requiring this workaround. Not sure how straight Linq to Objects does it.
还有这个
//expressions have to be compiled in order to work with the method call on
//straight Enumerable somehow, LINQ to objects itself magically does this.
//Reflector shows a mess, so I (Aaron) invented my own way. God love unit tests!
我刚刚也找到了这个…一切都会变得更好
//ok, this is a hairy, dirty, and nasty piece of code
//the alternatives are substantially worse than this though
//i.e. when you do your own provider, LINQ assumes that
//you are going to implement your own expression tree visitor and
//do it all yourself. Frankly, I still have xmas shopping to do
//and I really don't want us to be foobared when we get
//even more extension methods added to LINQ
//therefore, we are pulling execute based on taking the calling the
//standard execute on enumerable, but using our own class
//
//optimization can occur from here on an as needed basis, that is
//check for the value of mex.Method.Name, and write a handler for
//that method
//
//also, it may not be a bad idea to rather than do this reflection
//each and every time somehow cache the reflected methodinfos and do
//lookups that way that said, we need a complete red/green/refactor
//cycle here before I am touching that one
还有这个
//Compile that mutherf-ker, invoke it, and get the resulting hash
我只是发表了这样的评论:
// this control (Resistance) is FUTILE!