你遇到过的源代码中最好的注释是什么?


当前回答

我刚刚在。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

其他回答

public int hashCode() {
//sucks, but what're you gonna do

/*
int hash = 7;
for (int i = 0; i < array.length; i++)
    hash = hash * 31 * (null == array[i] ? 0 : array[i].hashCode());
return hash;
*/

return 0;
}
BEGIN.
// Here might be dragons
.
.
 IF...
 // Beware of the Jabberwocky
 .//user the force, luke
 .
 .
 ENDIF.
.
END.

我在我发布的WordPress模板中发布了这个“许可声明”。不管怎样,我觉得这很有趣。

/* The License:
You (from this point on referred to as The You) are hereby 
granted by me (from this point on referred to as The Me) 
license to knock yourself silly with this template. 
By using this template The You implicitly accepts this 
license and pledges solemnly to never claim creative 
ownership of any graphics, code, concepts, eggs, bacon, ideas, 
colors, shapes, hypertext-transfer protocols or other conduits 
of the visual splendor thatis this template. 

The Me, in turn, pledges equally solemnly to be far too 
lazy to ever check up on you, so if you do manage to pull 
some chicks The Me won't have a cow. 
However The Me would be sorely disappointed if The You 
were to try and sell or distribute this work without 
acknowledging The Me. Seriously. The Me will come down on 
The You like a large quantitiy of hard and heavy objects 
that in large quantities may be harmful and possibly even 
lethal to The You; So don't even think about it, The Buster.
*/
/*
* After 36 hours, 2 holes in my wall and writing my code right beside the API
* this still doesn't work.
* function getMap():void takes in an event object @param: evt:mouseEvent
* I will now retire for the day with a bottle of rum and 2 hours of crying
*/

为了保护有罪的人,价值观被改变了

这是一个承包商留下的,他一直在做一段负责测试电子邮件登录的代码。我们不相信,所以我们试了一下,这是一个有效的登录到他的个人帐户;我们再次检查了修订历史,他有两个签入来编辑它:一个是添加代码,另一个是注释掉它。

我们只添加了美术内容,而不去管其他内容;另一名开发人员认为,用未来的自己给他发电子邮件(游戏邦注:比如《The Office》)会很有趣,他说,在登录停止之前,他每天都要发两周的电子邮件。

'    ROFL:ROFL:LOL:ROFL:ROFL
'        ______/|\____
'  L    /          [] \
' LOL===_      ROFL    \_
'  L     \_______________]
'            I      I
'        /---------------/

'TODO: REMOVE MY INFO AND REPLACE WITH USER CREDENTIALS
'Private TEST_LoginName As String = "DurgshA@Exmaple.org"
'Private TEST_Password As String = "Humsal892"
'Private TEST_Server As String = "imap.secureserver.net"

我最喜欢的部分不是他做了这件事,也不是他不小心把它留在原地等待签到——而是当他再次看到它时,他只是把它注释掉了,而不是删除它。如果我们不知道它在那里,我们就不会去看原始版本:-D