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


//ALL YOUR BASE ARE BELONG TO US

...这让我的老板以为有人黑进了系统。他不知道这个笑话。


Get This hack!

在一行汇编代码中,在几页未注释的代码之后。


我发现了这个:

I'm not sure what I did

// TODO: Implement this function!

//I am not sure why this works but it fixes the problem. 

这是之前的一组代码,技术上确实解决了问题,它的意思是,但打破了其他3个东西....


目前为止最好的一个:

"This code makes baby Jesus very sad!". 

它像这样引用一个String的初始化:

String blankSpaces="                              "+ //100 whitespaces
                   "                              "+ //200 Whitespaces
                   ...
                   "                                        " //100 whitespaces

你懂的。


/* Please work */

下面是一个必须声明的局部变量,只是为了将一个常量传递给库函数:

// This only exists because Scott doesn't know how to use const correctly

Many years ago (about 1994) I was working on a Oracle PRO*C application for a large multi-national software company that you will have heard of. The app I was working on was a massive Oracle application and they had a utility that ran overnight tidying up data and doing all sorts of aggregate calculations. Every time anything needed doing as a batch job, it got shoved into this utility and as you can imagine it became an absolute monstrosity. It was also notable for the tiny number of comments that it had for such a massive program.

它为数不多的评论之一仍然是我所见过的对纯粹的WTF的最好的评论……我试图在一个函数中找到一个bug,它有数百行长,中间是函数中唯一的注释:

/* I did this the other way */

直到今天,这仍然是我所见过的最好的评论。


/* You are not meant to understand this */ 

//Code sanitized to protect the foolish. using System; using System.Collections.Generic; using System.Text; using System.Reflection; using System.Web.UI; namespace Mobile.Web.Control { /// <summary> /// Class used to work around Richard being a fucking idiot /// </summary> /// <remarks> /// The point of this is to work around his poor design so that paging will /// work on a mobile control. The main problem is the BindCompany() method, /// which he hoped would be able to do everything. I hope he dies. /// </remarks> public abstract class RichardIsAFuckingIdiotControl : MobileBaseControl, ICompanyProfileControl { protected abstract Pager Pager { get; } public void BindCompany(int companyId) { } public RichardIsAFuckingIdiotControl() { MakeSureNobodyAccidentallyGetsBittenByRichardsStupidity(); } private void MakeSureNobodyAccidentallyGetsBittenByRichardsStupidity() { // Make sure nobody is actually using that fucking bindcompany method MethodInfo m = this.GetType().GetMethod("BindCompany", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (m != null) { throw new RichardIsAFuckingIdiotException("No!! Don't use the fucking BindCompany method!!!"); } // P.S. this method is a joke ... the rest of the class is fucking serious } /// <summary> /// This returns true if this control is supposed to be doing anything /// at all for this request. Richard thought it was a good idea to load /// the entire website during every request and have things turn themselves /// off. He also thought bandanas and aviator sunglasses were "fuckin' /// gnarly, dude." /// </summary> protected bool IsThisTheRightPageImNotSureBecauseRichardIsDumb() { return Request.QueryString["Section"] == this.MenuItemKey; } protected override void OnLoad(EventArgs e) { if (IsThisTheRightPageImNotSureBecauseRichardIsDumb()) { Page.LoadComplete += new EventHandler(Page_LoadComplete); Pager.RowCount = GetRowCountBecauseRichardIsDumb(); } base.OnLoad(e); } protected abstract int GetRowCountBecauseRichardIsDumb(); protected abstract void BindDataBecauseRichardIsDumb(); void Page_LoadComplete(object sender, EventArgs e) { BindDataBecauseRichardIsDumb(); } // the rest of his reduh-ndant interface members public abstract string MenuItemName { get; set; } public abstract string MenuItemKey { get; set; } public abstract bool IsCapable(CapabilityCheck checker, int companyId); public abstract bool ShowInMenu { get; } public virtual Control CreateHeaderControl() { return null; } } }

更新:代码的原作者已经暴露了自己,所以我必须在适当的地方给予赞扬。Dan McKinley在我入职后不久就离开了我所在的公司,他讲述了更多关于代码的内容,解释了一些背景知识和“Richard”所写的一些“WTF”。


Catch (Exception e) {
 //who cares?
} 

我不止一次使用过这个方法,当我对一个数学公式做了一些不明显的简化时,我不想记录:

//this formula is right, work out the math yourself if you don't believe me

在头文件的顶部:

/* Project : XYZ (Please somebody shoot me!)
 *
 * File : $Id: defs.h,v 1.1 $
 *
 * Purpose : Create havoc rather than peace among many nations
 *
 * History : Back-ported changes that were not in CVS.  Please somebody,
 *  shoot us and put us all out of our misery.
 */

“XYZ项目”(已改名)是一个长达七年的折磨。最后这句话是由一个从头到尾都参与其中的坚定的灵魂写的。


来自usenet的经典:

Teradyne硬件建模器代码的深层是一个例程 一大堆十六进制数字到SYS$QIO调用中。唯一的评论是 “这里发生了奇怪的魔法”。


// This code sucks.

{
This is a gathering place for all unit tests.
Create a TUnitTestWrapper, then call "RunAllUnitTests".

This class will create an instance of each thing to be tested, and call each of
their unit tests.

It does not really do any testing on it's own; it just gives a common place from
which to call everyone else's tests.

This way, one day, we can automate our testing with each build. [Cue laughter]
}

int Q13Factor = 8125; // 2^13 for Q13 

-- Comment this later

这是一个4000多行的PL/SQL过程的第2行。唯一的评论。手术已经进行了4年了,后来还是没来…


在开发团队中每个人都在大量编辑的代码文件头部:

'Avert your eyes, it may take on other forms!

好弗兰德斯。


//你不需要理解这个

经典。


在一个完全没有注释的2000行方法中

{ 
  { 
    while (.. ){ 
      if (..){
          }
      for (.. ){ 
          }
         .... (just putting in the control flow here, imagine another few hundred ifs)
      if(..)   {
            if(..)     {
                   if(..)   {
                ...
                (another few hundred brackets)
                       }
                  }
         } //endif

(实际上有一天,我把所有的括号都去掉了,只是为了看看它有多糟糕,而且,没有格式化,得到了这个:

{{{{}}{}{}{}{}}{{}{{}{}{}{}{}{}{{}{}}{}{}{{}{}{}{}{}{}{}{}{}{}{}{{}}}{{}{{}}{{{}}}{{}{}{}{}{}{}{}{{}}{}{{{}}{}{{}{}}{{{}}{}{}{}{}}{{}}}{}{{}{}{}{{}{{}}{}}{{}}}{{}}{{}}{{}}{}{{}}{{}}{{}}{{}{}{}}{}{}{{{}}{{}}}{}{}{}{}}{{{}{{}{}{}{{}{}{}{}{}{}}{}}{{}}{{}{}}}{{}}{{}}}{{}}{{}}{}{}{}{}{{}}{{}{}{}{}}}}{}{}}{{}{{{}{}{}{}}}}{{}{{{}}}}{{}{{{}{{}}{}{{}}{}{{}{}}{{}}{}{{}}}{{}}}}{{}{}{}{}{}{{{}    {{{{}}{}{}{}{}}{{}{{}{}{}{}{}{}{{}{}}{}{}{{}{}{}{}{}{}{}{}{}{}{}{{}}}{{}{{}}{{{}}}{{}{}{}{}{}{}{}{{}}{}{{{}}{}{{}{}}{{{}}{}{}{}{}}{{}}}{}{{}{}{}{{}{{}}{}}{{}}}{{}}{{}}{{}}{}{{}}{{}}{{}}{{}{}{}}{}{}{{{}}{{}}}{}{}{}{}}{{{}{{}{}{}{{}{}{}{}{}{}}{}}{{}}{{}{}}}{{}}{{}}}{{}}{{}}{}{}{}{}{{}}{{}{}{}{}}}}{}{}}{{}{{{}{}{}{}}}}{{}{{{}}}}{{}{{{}{{}}{}{{}}{}{{}{}}{{}}{}{{}}}{{}}}}{{}{}{}{}{}{{{}{}{{}}{}}}{}}{{}}{{}{}}{{}{{}{{}}}}{{{}{{{}}}}}{{{{{}}}}}{}{}{}{{{{}}}{}{}}{{}{{}}}}{}{{}}{}}}{}}{{}}{{}{}}{{}{{}{{}}}}{{{}{{{}}}}}{{{{{}}}}}{}{}{}{{{{}}}{}{}}{{}{{}}}}

endif出现在第800行左右)


简单但有效的注释,在一些不太安全的c++代码之前

// yikes

这实际上是我在实现原型转换为实际代码时所做的:

// Abandon all hope you who needs to debug this

是的,有比我聪明的人在之后重构了代码(它必须有一个好的结局)。


THIS PROGRAM HAS CODE THAT DOES NOT MEET STANDARDS      

这个评论几乎出现在我们这里的每一个节目中....


这不是严格意义上的评论,但是…

那是20世纪90年代中期,我正在进行一次大的迁移:小软件供应商,大客户,压力很大。我们有很多转移门柱的东西;这个项目很难控制。我是关键的开发人员,但对系统还不熟悉,而另一个开发人员是供应商的所有者/创始人。

在几个月没有按时完成任务,也没有让客户满意之后,公司的所有者/创始人找来了另一名远程工作的开发人员。(我可以大胆地说,新开发人员的技能和经验都不如我。)

好吧,这个新人对我已经做过的代码做了一些更改,然后一两个月后我又回到了代码的同一区域,其中有一些我以前没有见过的变量。他的名字叫StupidMark。

伙计,这是不对的。我的意思是,有团队合作方面的考虑,但是:在这个环境中,变量名可能会出现在运行时错误消息中。我只是说说而已。

在我看来,那个新人的代码并没有让我们更接近可交付的产品,这让侮辱变得更伤人了。


// If this comment is removed the program will blow up 

当被问及什么是“最好的评论”时,我们的回答都是我们能找到的最糟糕的评论,这充分说明了我们的职业……


If you have reached this part in the code, then this program sucks.

using namespace std;            // So sue me

最初的《毁灭战士》拥有一个带有静态墙壁的引擎,但却不能移动;结果,所有的门都是垂直打开的;任何东西都不可能水平移动。当源代码发布后,我在查看代码时,在处理门的源文件中看到了这个,在一大块注释掉的代码的开头:

// UNUSED
// Separate into p_slidoor.c?

#if 0           // ABANDONED TO THE MISTS OF TIME!!!
//
// EV_SlidingDoor : slide a door horizontally
// (animate midtexture, then set noblocking line)
//

// but the "real" solution is much more complicated

从jpgraph


// this is really complicated

没有其他评论了


// Magic. Do not touch.

// Okay, let's do the loop, yeah come on baby let's do the loop
// and it goes like this ...

大概30页的xslt的中间部分

<!-- Here be dragons  -->

/* logic */
#ifndef TRUE
# define TRUE 1
#endif /* TRUE */
#ifndef FALSE
# define FALSE 0
#endif /* FALSE */
#define EOF_OK TRUE
#define EOF_NOT_OK FALSE

以及在IOCCC页面上的mkentry.c的其余部分。每次读这篇文章的时候,我都笑不出来。


试着在谷歌代码搜索中输入你最喜欢的脏话,它会消磨掉许多无聊的时间。以下是我最喜欢的例子:

/* These magic numbers are fucking stupid. */

/* Dear free software world, do you NOW see we are fucking
   things up?! This is insane! */

/* We will NOT put a fucking timestamp in the header here. Every
   time you put it back, I will come in and take it out again. */

# However, this only works if there are MULTIPLE checkboxes!
# The fucking JS DOM *changes* based on one or multiple boxes!?!?!
# Damn damn damn I hate the JavaScript DOM so damn much!!!!!!

/* TODO: this is obviously not right ... this whole fucking module
   sucks anyway */

/* FIXME: please god, when will the hurting stop? Thus function is so
   fucking broken it's not even funny. */

我个人最喜欢的

 # code below replaces code above - any problems?
 # yeah, it doesn't fucking work.

// drunk, fix later

真希望我是在开玩笑。根据编写代码的开发人员的了解,我认为他是认真的。


// I have to find a better job

以下是4个,排名不分先后:

// Father, forgive me, for I am sinning

// heaven help me

// horse string-length into correctitude 
(from a textbook)

// what, me worry?

“这永远不会发生”。

朋友,这是我的临终遗言……


(A bunch of code that's really weird looking)  //Kludge.

return 1; # returns 1

//This code sucks, you know it and I know it.  
//Move on and call me an idiot later.

在给一个朋友看了这篇来自《Coding Horror》的文章几个小时后,我看到了他对代码的评论:

// valdez先生是一个暴力的精神病患者。别惹他生气。


/* This is O(scary), but seems quick enough in practice. */ 

后面是四个嵌套的for循环


// Bad Christian, No cookie

这里的Cookie不是指浏览器Cookie


const int TEN=10; // As if the value of 10 will fluctuate... 

//The following code is commented out
//(a load of commented out code followed)

我经历了一个睡眠不足的编程过程,开始只写引用自《搏击俱乐部》的评论。

多年后,我仍然在浏览代码,发现了一条让我发笑的评论。大多数只是随机的想法。然而,我确实保持我的评论行比率相当好!

// This shouldn't happen. The only way this can happen is if the
// <code>JFileChooser</code> has returned a <code>File</code> that doesn't exist
// on the system. If this happens we can't recover, and there is more than likely
// a rip in the space time continuum that the user is too distracted by to notice
// anything else.

 /**
   * This method leverages collective synergy to drive "outside of the box"
   * thinking and formulate key objectives into a win-win game plan with a
   * quality-driven approach that focuses on empowering key players to drive-up
   * their core competencies and increase expectations with an all-around
   * initiative to drive down the bottom-line. I really wanted to work the word
   * "mandrolic" in there, but that word always makes me want to punch myself in
   * the face.
   */
private void updateFileCountLabel() {

// sometimes I believe compiler ignores all my comments

# absolutely foul heuristic code.
# ..it's dirty, but you want it.

and:

# VERY USEFUL DEBUGGING AID, for when the above all goes pearshaped:

刚从大学毕业的我渴望亲自动手。我的第一个任务是……“为我注释此代码”。

傻瓜。

过了一段时间我就厌倦了……

// this function doesn't actually calculated the profit, like it says --it really signals the mothership orbiting saturn that the planet is ripe for takeover

[later]

// I don't think anyone is going to read this

[various permutations on that last one]

/* Halley's comment */

事实上,有一天我在一些代码上看到了这个,这些代码是在截止日期很急的时候写的。

//This was clearly written under duress

经典ASP:

'Is it worth it, let me work it'
'I put my thing down, flip it and reverse it'
'Ti esrever dna ti pilf, nwod gniht ym tup I'

NextIP = StrReverse(UserRecordset.Fields.Item(0))

我在重用我很久以前写的一个PHP类时发现了这一点。我仍然不记得那里有什么,我仍然发现它没有任何用处……我甚至不记得我写过那篇评论;所以当我找到它的时候,我真的笑出声来了。

try
{               
    // Some database logic
}
catch (Exception $ex)
{
    // sure, it looks silly and I honestly cant remember what code used to go here... but i swear i will
    // find a use for this code.... eventually....
    throw $ex;
}

其中最经典的是皮埃尔·德·费马对他著名的“大定理”所作的评论:“这一页的空白处太小了,无法写下证明。”

350多年后才找到证据。

(根据维基百科,这是原文:)

Cubum autem在双cubos, aut 二元象限 象限,和将军 无限超quadratum中的一无所有 在两种情况下 我们是恶魔 米拉比林健康。Hanc marginis exiguitas不是caperet。

...并翻译成英语:

(把立方体分开是不可能的 化成两个立方,或者化成四次方 2 / 4次方,或者一般来说,任意 幂大于二成二 喜欢权力。我发现了一个真正的 这是一个绝妙的证明 边际太窄,无法容纳。)


在JUnit API中找到:

/**
 * ...as the moon sets over the early morning Merlin, Oregon
 * mountains, our intrepid adventurers type...
 */
public Test createTest(Class theClass, String name) {
    ...
}

stop(); // Hammertime!

一个文件中5000多行代码中很少的一些注释 事实上,我和那个为自己的编码风格辩护的程序员有过一次争论…… 无可奉告! 没有评论;-)(或者很少) 遗憾的是,这是产品代码。

offset=1;
for (i=0;i<=len;i++)
    {
    if ((i!=0)&&(i<len)) //-3
        {
        switch(mess[i])
            {
            case ETX:
            case ETB:
            case DLE:
                buf[offset]=DLE;
                offset++;
                break;
            }
        }
    buf[offset]=mess[i];
    offset++;
    }

我喜欢这个开关!

for (n=0;n<offset;n++)
{
    Sleep(TR);  //Modif A
    Sleep(T);//
    FWriteFile(hCom,buf+n,1,&dwMot,NULL);
    if (ECHO)
        FReadFile(hCom,tab,1,&dwMot,NULL);
}

不,没有注释解释什么“修改A”是在标题。

if (GetFileSize(hSlotFile,NULL)==3600)   //5*720

720是多少?


在为一家芬兰移动网络设备制造商工作期间,我深入研究了硬件抽象层,发现芬兰语单词“puukko”出现了100多次。

“puukko”是一种万能刀,每个芬兰人的工具箱里或家里都有。它被用于从剥土豆到电脑维修(我的观察)的所有事情。我相信在这个语境中,它相当于芬兰语中的“Hack”。

我的芬兰同事否认了这一点,并说这更像是“外科手术/干预”……我差点就相信了,直到我看到下面的评论:

/* Perkele ISO Puukko! */ -> Fucking Big Hack!

在LucasArts的电脑游戏《the Eidolon》(游戏邦注:这款游戏本身就很古怪)的源代码中可以看到……

// He's dead, Jim!

/* My lawyer told me not to reveal */

// I dedicate all this code, all my work, to my wife, Darlene, who will 
// have to support me and our three children and the dog once it gets 
// released into the public.

//Abandon all hope ye who enter beyond this point

// TODO - Comment this function

为什么你不应该将你的软件开发外包的一个经典案例:

public class Contact
{
    //...    

    /// <summary>
    /// Gets or sets the name of the first.
    /// </summary>
    /// <value>The name of the first.</value>
    public string FirstName
    {
        get { return _firstName; }
        set { _firstName = value; }
    }
}

Repeat
    ...
Until (JesusChristsReturn) ' Not sure

-- Change Log:  Not needed. The code is perfect 'cause I wrote it.
-- If you change it, it will break.

我正在检查一些代码注释,以检查它们是否有意义,并看到上面的一行。


long john; // silver

//There can Only Be one HIGHLAN....err..Singleton
public class SomeSingleton
{
...
}

virgin = 0;     /* you're not a virgin anymore, sweety */

i++; // increment variable i

用于政府目的的企业等级系统中的评论

'RH 5/24/06 burn me if this dosn't work.. :)

好RH.....公司总裁/首席开发人员


//open lid


//take sh!t


//close lid

文件打开,数据转储,文件关闭…


在几年前编写Perl时,我在顶部和底部添加了这些注释:

# <magic type="voodoo">

...

# </magic>

下一个研究它的人在Perl中并不是那么热门,他花了一段时间搜索文档,看看“魔法”和“巫毒”是怎么做的。从那以后,我试着添加更多有用的评论……


// Catching exceptions is for communists

来自Mike Duncan在SQLite上的页面。


在XSLT文件的头文件中:

DON'T TOUCH THIS SCRIPT -> XSLT is like arcane, black magic

// Hard to explain

它最后也坏了。难怪很难解释清楚


我相信在JBoss的某个地方有一行写着

return null; //Not really null

我一直很喜欢这句话。


 * ...and don't just declare it volatile and think you've solved
 * the problem. You young punks think you know what volatile
 * means... why in my day we had to cast it volatile uphill
 * both ways, and the code still didn't work! Whippersnappers...

// The following strings are meant to be funny.  Do not edit these strings
// unless you are funny, too.  If you don't know if you're funny, you're
// not funny.  If fewer than 2 people unrelated to you have told you that 
// you're funny, you're not funny.

在被迫为贫血域对象编写单元测试时,这些对象不过是getter和setter的包(我也是被迫写的):

// zzzzZZZZzzzz....

// human madable inconvenient. Way too sucks.

我仍然没有完全理解它的含义,但我发现它对于许多代码来说是非常正确的。


// I know the line below is wrong, but it came that way from our IP vendor, and 
// the driver won't work if you "fix" it. I've had to revert this change 4 times
// now. Leave it alone, or I will hunt you down and hurt you
if (r = 0) {
    /* bunch of code here */
}
else
{
   /* even more code here */
}

高斯林的Emacs源代码中的ascii艺术头骨和交叉骨骼(这里很难重现)(警告说他编写的超热屏幕管理包不容易理解)。


唐纳德·克努斯的另一个经典作品:

注意上面代码中的bug; 我只是证明了它是正确的,并没有尝试过。


/*
 * You may think you know what the following code does.
 * But you dont. Trust me.
 * Fiddle with it, and youll spend many a sleepless
 * night cursing the moment you thought youd be clever
 * enough to "optimize" the code below.
 * Now close this file and go play with something else.
 */ 

// set break point here - you'll never reach it

一个奇怪而恰当的有趣错别字:

断言(0);//永远不要在这一点上犯错


// I am not sure if we need this, but too scared to delete. 

if(m_measures =/*=*/ --index)
{
    ....

我记不清了,大概是这样的:

Person p = new Person("John", "Doe", "male");
Collection women = new ArrayList();
women.insert(p.getTail());

这是肮脏的代码;)


/*************************** Drag And Drop Section - Start (you should be me to mess with this section)*********************************************/

if(count<0) count=0;    //don't get me wrong but this has to be done :p

不是注释,而是属性

[ThereBeDragons]

还有一个是我在IHttpHandler的实现中看到的

//What is this?
public bool IsReusable
{
    get{return false;}
}

try {
  dataSource.close();
}
catch (SQLException ex) {
  // Do nothing, since we're going to trash this anyway
}

当然,这类事情实际上是JDBC(或者至少是Oracle的JDBC驱动程序)中的wtf,因为它可以在关闭连接时抛出SQLExceptions…


注意上面代码中的bug;我只是证明了它是正确的,并没有尝试过。

这是唐纳德·克努斯写的。


//把这个放在这里的人是个白痴…这根本不管用!

但是代码还在那里……


用VB写的很好。我今天早上跑进了NET,得到了一个笑声…

''' <summary>
''' Represents an exception that was logged.  Since System.Exception implements IDictionary, it can't be
''' serialized, so I had to write this.  Pretty fucking stupid thing to have to do, System.Exception should
''' be serializable right out of the box, IMHO.
''' </summary>
''' <remarks></remarks>
Public Class LogException

catch (Ex as Exception)
{
     // oh crap, we should do something.
}

没有什么比一个空的catch块更能让人觉得代码是健壮的....


/// <summary>
/// The possible outcomes of an update operation (save or delete)
/// </summary>
public enum UpdateResult
{

    /// <summary>
    /// Updated successfully
    /// </summary>
    Success = 0,

    /// <summary>
    /// Updated successfully
    /// </summary>
    Failed = 1
}

我刚刚注意到自己在写这个

// not brilliant solution, but fair enough heh.

try {

} finally { // should never happen 

}

我告诉学员至少做一些异常处理。这是我在每一个db调用....返回

Catch (Exception e) {
    //eat it
}

/* Emits a 7-Hz tone for 10 seconds.
  True story: 7 Hz is the resonant frequency of a
  chicken's skull cavity. This was determined
  empirically in Australia, where a new factory
  generating 7-Hz tones was located too close to a
  chicken ranch: When the factory started up, all the
  chickens died.
  Your PC may not be able to emit a 7-Hz tone. */

main()
{
    sound(7);
    delay(10000);
    nosound();
}

(Turbo C 2.0版本参考指南中的声音功能)


[onload_1;block=begin;when 1=0]

Some of the techinques in this template are rather obscure, just trust me, they need to be there.
OTOH a better sollution would be to create a few seperate templates and pick one in the php-script...

[onload_1;block=end]

// I don't know why I need this, but it stops the people being upside-down

x = -x;

// This procedure is really good for your dorsolateral prefrontal cortex.

你们中有些人,由于某种特殊的原因,不知道DPC,当你深入学习新东西时,你大脑的这一部分会亮起来。


// Any maintenance developer who can't quote entire Monty Python
// movies from memory has no business being a developer. 
const string LancelotsFavoriteColor = "$0204FB"

Case 1:
   ...
   break;
   ...
//I don't want do do this but [my coworker] says it's part of the code standard
default:
   break;

来自Java 1.2的SwingUtilities:

doRun.run();  // ... "a doo run run".

不是真的评论:

DvLog::Log("This silly log message fixes a PSCRIPT5.DLL gpf when printing to Adobe.");

可悲的是,没有评论,PSCRIPT5.DLL真的炸了…


'Do not optimize these next two lines. Compiler bugs lurk.

他们做到了。将变量压缩到第二行表达式中会导致跳到堆中间并尝试执行数据。


一些源代码中的德语注释,由机器或非常疲惫的人翻译+谷歌

; Rechnen ja ; have faith in yes

我猜原来的意思是“假设这里是真的”…但从那以后,我就把它当成了人生的咒语。


这是我最喜欢的评论。

/// I intend to do this as shittily as possible because there are many better products that will totally blow this out of the water
/// and we don't have them so whatever

在后面的文件中,我们有更多的乐趣

/// sidestep a bug in WCF (that we can't send types across)
/// or, depending on how you look at, this issue is a Feature

稍后再讲

if( where == null)//be nice

这是我曾经必须支持的实际代码。在努力理解AstaSaysGooGoo和AstaSaysGaaGaa(在那里有更多的astaTempVars被声明和使用)的逻辑之后,我准备放弃。我终于抬头看到了“@author”的评论,整件事开始有意义了。

/*

* @author Andrew Asta
*/
public class AstaClass{

    private String astaVar1;    
    private String astaVar2;    
    private String astaVar3;    
    private String astaVar4;    
    private String astaVar5;    
    private String astaVar6;    
    private String astaVar7;    
    private String astaVar8;    
    private String astaVar9;    
    private String astaVar10;   

    public void AstaSaysGetData(){
        //JDBC statement to populate astavars 1 through 10
        //...
        String astaSqlStatment = "Select astaCol1, astaCol2, astaCol3... From AstaTable Where...";
        //..
        //...
    }

    //Perform data manipulation on astavars...
    public void AstaSaysGaaGaa(){
          [removed for sake of brevity]
    }


    //Perform more data manipulation on astavars...
    public void AstaSaysGooGoO(){
        [removed for sake of brevity]
    }

    public void AstaSaysPersist(){      
        //JDBC statement to save astavars to DB 
        String astaSqlStatment = "Update AstaTable set astaCol1 = @astaVar1
                                                  , set astaCol2 = @astaVar2
                                                  , set astaCol3 = astaCol3... 
                                                  Where...";
    }
}

另外,我更改了实际作者的真实姓名,以避免我陷入任何纠纷等等…


在OLTP数据库事务的主要触发代码中找到:

-- This line negates the @inverseqty, which is the
-- negative of the @insertedquantity.  This works through the
-- magic of the trigger.  In fact, this code is a lot like
-- the bermuda triangle!
@negquantity = -1 * @inverseqty

  mov si, pCard      ; captain?

有一些旧的javascript代码,写得很好。然后是一条评论线

// and there is where the dragon lives

接下来是一个功能,4个人花了一天时间来理解它在做什么。最后我们意识到它根本没用,什么都没有。


在一个著名的商业DOS电子表格应用程序中:

/* This comment was just added in order to check-in a file that was last 
checked in by [Insert Programmer FirstName] "Back-to-the-Future" [Insert 
Programmer LastName]. While testing for year 2000 problems, he accidentally 
checked-in this file while his machine clock was set forward to the year 2000. 
This meant that the source code was always newer than the object file and 
compiled every time the code was built. I'm checking this file in again to 
fix that. */

我继承了一个没有任何UAT交付给客户的项目。它被踢出了栅栏,要求赔偿。

他们第一次使用它,它自然就爆炸了。它是一个插入库,可以覆盖任何以文件名而不是文件描述符作为参数的系统调用。

许多系统调用已经被遗忘。

当我开始使用这款游戏时,它的代码包含了以下内容:

/* core dumps around here but this is hardly ever called */

and

/* don't know why this works but it seeems to be ok */

哦,没有单元测试。一位同事已经开始添加缺失的系统调用和单元测试。

编写代码的那些混蛋还在团队中,他们根本不在乎已经交付的垃圾!


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

A:很简单——就是那个帮我解决了我当时遇到的任何问题的人,而且有很多这样的人!

其次是那些帮助指导新开发避免已知陷阱的方法。


' Oh man I'm pissed. I think I better go home.

哪里喝醉了


//Not a bug, parameter position can change..., if you think this is wrong, you are in fact wrong.

// Jay knows what's going on here, but will he remember in a year? Not very likely, this code sucks, but it works so do not change it.

这条评论被贴在一个巨大的“如果”区块上…哦,它操纵一个对象数组的对象数组的对象数组的字符串对象数组,可以是字符串或数字,取决于至少3个因素…(是的,我必须调试这段代码并更改它,我写了注释,但我没有写原始代码)。;)


离开我的上一份工作,我嵌入了一些ascii艺术到源代码…


                                      ,_-=(!7(7/zs_.             
                                   .='  ' .`/,/!(=)Zm.           
                     .._,,._..  ,-`- `,\ ` -` -`\\7//WW.         
                ,v=~/.-,-\- -!|V-s.)iT-|s|\-.'   `///mK%.        
              v!`i!-.e]-g`bT/i(/[=.Z/m)K(YNYi..   /-]i44M.       
            v`/,`|v]-DvLcfZ/eV/iDLN\D/ZK@%8W[Z..   `/d!Z8m       
           //,c\(2(X/NYNY8]ZZ/bZd\()/\7WY%WKKW)   -'|(][%4.      
         ,\\i\c(e)WX@WKKZKDKWMZ8(b5/ZK8]Z7%ffVM,   -.Y!bNMi      
         /-iit5N)KWG%%8%%%%W8%ZWM(8YZvD)XN(@.  [   \]!/GXW[      
        / ))G8\NMN%W%%%%%%%%%%8KK@WZKYK*ZG5KMi,-   vi[NZGM[      
       i\!(44Y8K%8%%%**~YZYZ@%%%%%4KWZ/PKN)ZDZ7   c=//WZK%!      
      ,\v\YtMZW8W%%f`,`.t/bNZZK%%W%%ZXb*K(K5DZ   -c\\/KM48       
      -|c5PbM4DDW%f  v./c\[tMY8W%PMW%D@KW)Gbf   -/(=ZZKM8[       
      2(N8YXWK85@K   -'c|K4/KKK%@  V%@@WD8e~  .//ct)8ZK%8`       
      =)b%]Nd)@KM[  !'\cG!iWYK%%|   !M@KZf    -c\))ZDKW%`        
      YYKWZGNM4/Pb  '-VscP4]b@W%     'Mf`   -L\///KM(%W!         
      !KKW4ZK/W7)Z. '/cttbY)DKW%     -`  .',\v)K(5KW%%f          
      'W)KWKZZg)Z2/,!/L(-DYYb54%  ,,`, -\-/v(((KK5WW%f           
       \M4NDDKZZ(e!/\7vNTtZd)8\Mi!\-,-/i-v((tKNGN%W%%            
       'M8M88(Zd))///((|D\tDY\\KK-`/-i(=)KtNNN@W%%%@%[           
        !8%@KW5KKN4///s(\Pd!ROBY8/=2(/4ZdzKD%K%%%M8@%%           
         '%%%W%dGNtPK(c\/2\[Z(ttNYZ2NZW8W8K%%%%YKM%M%%.          
           *%%W%GW5@/%!e]_tZdY()v)ZXMZW%W%%%*5Y]K%ZK%8[          
            '*%%%%8%8WK\)[/ZmZ/Zi]!/M%%%%@f\ \Y/NNMK%%!          
              'VM%%%%W%WN5Z/Gt5/b)((cV@f`  - |cZbMKW%%|          
                 'V*M%%%WZ/ZG\t5((+)L\'-,,/  -)X(NWW%%           
                      `~`MZ/DZGNZG5(((\,    ,t\\Z)KW%@           
                         'M8K%8GN8\5(5///]i!v\K)85W%%f           
                           YWWKKKKWZ8G54X/GGMeK@WM8%@            
                            !M8%8%48WG@KWYbW%WWW%%%@             
                              VM%WKWK%8K%%8WWWW%%%@`             
                                ~*%%%%%%W%%%%%%%@~               
                                   ~*MM%%%%%%@f`                 
                                       '''''                     


// THE LOOP THAT DO EVERYTHING!!!!!!!

来自一个显然在看巨蟒剧团的小伙子:

> //现在,for something完全 > // different: 类theLarch {


大约1997年,Netscape网络浏览器的UNIX风格的源代码:

/* HP-UX sucks wet farts from dead pigeons' asses */

不幸的是,在Moz开源之前,这些珍珠被移除了……


消毒:

//Forward declarations:

class X {}; // TODO: Remove {}  ! When we get X defined....

在linux 1.0内核调度器(schedule .c)中:

Dijkstra可能讨厌我。

/*
 *  'schedule()' is the scheduler function. It's a very simple and nice
 * scheduler: it's not perfect, but certainly works for most things.
 * The one thing you might take a look at is the signal-handler code here.
 *
 *   NOTE!!  Task 0 is the 'idle' task, which gets called when no other
 * tasks can run. It can not be killed, and it cannot sleep. The 'state'
 * information in task[0] is never used.
 *
 * The "confuse_gcc" goto is used only to get better assembly code..
 * Dijkstra probably hates me.
 */
asmlinkage void schedule(void)

(…)


//休斯顿,我们有麻烦了


// No women, no children... What movie???

这是一个旧的IOCCC获奖条目,我不得不下载整个获奖档案——一个巨大的1.4 M——和grep的几个短语,我记得错了才找到它。

从语法上看,这可能不是注释。或许是这样。我还没想明白。它肯定没有注释分隔符,但也没有字符串分隔符。

C="Lint says "argument Manual isn't used."  What's that
mean?";

没有价格来猜测棉绒的产量。

对于好奇的人来说,这个条目在这里。


我经常看到这种情况:

// TODO make this work

生产源代码:

// Remove this if you wanna be fired

sqlite源文件顶部:

/*

** The author disclaims copyright to this source code.  In place of             
** a legal notice, here is a blessing:                                          
**                                                                              
**    May you do good and not evil.                                             
**    May you find forgiveness for yourself and forgive others.                 
**    May you share freely, never taking more than you give.

*/

 // WARNING!!!
 // Very perversive code ahead!

... about a 20 lines of "very perversive" code ...

// Now you can call your grandmother back. ;)

一段时间前我在一个PHP CMS中添加的注释。

if (/*you*/ $_GET['action']) { //celebrate

    /* Mark: If there's one thing you learn from this code, it is this...
   Never, ever fly Air France.  Their customer service is absolutely
   the worst.  I've never heard the words "That's not my problem" as 
   many times as I have from their staff -- It should, without doubt
   be their corporate motto if it isn't already.  Don't bother giving 
   them business because you're just a pain in their side and they
   will be sure to let you know the first time you speak to them.

   If you ever want to make me happy just tell me that you, too, will
   never fly Air France again either (in spite of their excellent
   cuisine). 

   Update by oej: The merger with KLM has transferred this
   behaviour to KLM as well. 
   Don't bother giving them business either...

   Only if you want to travel randomly without luggage, you
   might pick either of them.
   */

Fix problem where Nulls don't work properly.  Stupid Microsoft!

代码以迂回的方式一行一行地将null转换为零长度的字符串,因为愚蠢的程序员不理解null是什么,也从未听说过Nz()函数。


// fix for groupid > 9 
// if groupid ever gets to 100 everything will break (again)

if (groupid < 10) {
groupid = "0" + groupid;
}

// Added because boss changed his mind : 20020111,20020501,20020820, ...
// Commented out because boss changed his mind : 20020201,20020614,20020908, ...

在ETL脚本之间的主要黑客RPG数据库和SQL Server一个。我大概有10到20次这样的评论……


这是我们团队微观管理效果的一个活生生的例子:

// I am not responsible of this code.
// They made me write it, against my will.

... 我们敬爱的技术总监很喜欢把代码和编码指南都硬塞到开发人员的喉咙里(*)。

当然,当项目负责人寻找bug的原因时,发现它在“非最佳代码”中,他就不那么高兴了……

(*)当然,我指的是强大的VB国王……如果你想评估强大的VB国王的全部力量,你可以阅读下面的SO帖子:你被迫遵循的最奇怪的编码标准规则是什么?...


//If you're reading this, then my program is probably a success

// GK Experimental

(GK是编码器的首字母缩写)

用来表示部分代码,实际上,是实验性的。:)

这是一个很好的标志,当你在调试过程中碰到它时,你可能会在接下来的几个小时里忙着修复黑客。;)


我在一家大型投资银行看到,该银行要求记录和评论所有应用程序中断

Without a crash 

Or mighty bang 

The sync disk 

Did it's process hang

所有bug由David S. Miller添加


struct core_unlocker
{
    core_unlocker(lock)
    {
        m_lock = lock
        unlock(lock)  //Abandon All Locks, Ye Who Enter Core!
    }
    ~core_unlocker()
    {
        lock(m_lock)
    }  
    private:
    Corelock m_lock;
}

javascript函数的第一行:

// this part is more difficult

WTF?


在SJ CA拍卖业务的早期,我曾与一个名叫Rick Dorin的人合作过。他写编译器的时候,你必须整天拨弄卡片。他的错误信息之一是

错误太多……让更少的!


在一组相当长且复杂的while循环和if块的末尾,开发人员插入了最后的注释:

else
{
    // wobbly wilson said this would *never* happen!!
}

机智和讽刺的简洁混合:)


这是我自己代码中的一个,但它仍然非常有趣,我认为最好还是把它放在网上,因为它是在公共SVN中。

// These were orginally up and down. When it was clear the names were
// inapplicable, they were renamed to retain the joke.
// Sorry if you were hoping for useful variable names.
quantum strange, charm;

aComment = 'this is not aComment' # this is aComment
class T(object):
    def f(this):
        this is not aComment

几年前,我在一个没有单元测试可言的大型代码库中工作。

代码中隐藏了一个执行一些日历计算的方法。它有点坏了,由于一些不幸的情况,不得不以一种非常笨拙的方式处理夏令时。

我们不得不修了几次,每一次,我们都会在几个月后发现一些东西坏了。

在花了一整天的时间修复和分析之后,我把代码放到了源代码控制中,并附上了这样的评论:

// this code was written after a version trying to do {this} failed because of {reason},
// previously we were doing {this} which failed because of {reason}. This is 
// now written {this} way so that {lots of reasons here}. If you want to touch
// this code, please make sure that it produces the right answers when tested with:
//
// {some sort of unit test}

最终,我的团队被外包了。有时我想知道这段代码发生了什么:)


我只是发表了这样的评论:

// this control (Resistance) is FUTILE! 

场景一:

return 0; // Happy ending

场景二:

int32_t Interpolate1DSignal(
  Array1D<float64>::Handle hfInputSamples,         // samples to be interpolated
  Array1D<float64>::Handle hfInterpolationFilter,  // polyphase filter coefficients,
  int32_t iFilterInterpolationFactor,              // # of "rows" in polyphase filter
  int32_t iFilterLength,                           // Length of each row in filter
  float64 fInterpolationFactor,                    // Factor to interpolate the
                                                   // signal by
  float64 fTimingOffset,                           // Offset into the signal (units   
                                                   // of samples)
  Array1D<float64>::Handle hfOutputSamples         // left as an exercise for the reader
);

我参与的一个大型项目在自动构建中使用了StyleCop和FXCop,并使用规则来防止人们检入带有未注释字段、方法、属性等的代码。

有些人对必须添加“获取或设置全名”之类的注释到自记录属性(如FullName)感到非常恼火,以至于他们不得不努力编写一个宏来绕过这些规则。

宏为方法、属性等插入了XML摘要标记,其中一个单一的不显示Unicode字符作为标记内容,这将欺骗构建规则,同时对为了注释而盲目坚持的东西进行轻微打击……

...至少直到他们引入了另一条规则来检查注释中的Unicode字符。


从一个遗留的Perl CGI脚本:

# This is convoluted and evil, sorry.

来自我们的一个项目。 在一个源文件末尾的某个地方。

/*@                                    /\  /\
 * @                                  /  \/  \                        ----- |   | ----      |---\ |    | /--\  --- |   |  ---- /--\ /--\
 *  @                                /        --                        |   |   | |         |   / |    | |      |  |\  |  |    |    |
 *   \---\                          /           \                       |   |---| ----      |--/  |    |  \     |  | \ |  ----  \    \
 *    |   \------------------------/       /-\    \                     |   |   | |         |  \  |    |   -\   |  |  \|  |      -\   -\
 *    |                                    \-/     \                    |   |   | ----      |---/  \--/  \--/  --- |   \  ---- \--/ \--/
 *     \                                             ------O
 *      \                                                 /                 --- |   | ----  /--\        |--\   /--\   /--\
 *       |    |                    |    |                /                   |  |\  | |    |    |       |   | |    | |
 *       |    |                    |    |-----    -------                    |  | \ | ---- |    |       |   | |    | | /-\
 *       |    |\                  /|    |     \  WWWWWW/                     |  |  \| |    |    |       |   | |    | |    |
 *       |    | \                / |    |      \-------                     --- |   \ |     \--/        |--/   \--/   \--/
 *       |    |  \--------------/  |    |
 *      /     |                   /     |
 *      \      \                  \      \
 *       \-----/                   \-----/
 */

我没有亲身经历过这种情况,但这是一个很好的故事(详见我的评论中的解释):

#define MSGTAG_B33R     0x723 /* RIPLVB */

今天刚加了这个:

// Hardcoded this for time sake ... will make andrew fix later :)

'""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
'
'  NOTE: DON'T SCREW WITH THIS CODE UNLESS YOU REALLY UNDERSTAND IT!
'
'""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

我想我有过这样的经历:


if (case1) { // trivial
...
}
else { // we are screwed
 /* fill in later */
}

好吧,我可能用了一个比搞砸更强烈的词


# To understand recursion, see the bottom of this file 

在文件的底部:

# To understand recursion, see the top of this file

在一个名为“Bar”的类中(这是一个不具有描述性名称的UI控件),类头文件:

/// <summary>I pity the "foo".</summary>

Remove()方法:

/// <summary>A "foo" and his money are soon parted.</summary>

更糟糕的是,业务合作伙伴从生成的文档中指出了这一点。更糟糕的是,这些可能是我们从那家伙那里得到的最接近有用文件的东西。


<!-- THIS IS THE MAIN CONFIGURATION FILE FOR THE ENTIRE BLOODY DIRECTORY    -->
<!--    WHATEVER YOU DO, DO NOT EDIT THIS FILE WITHOUT TALKING TO ME FIRST  -->
<!--                                I'M SERIOUS                             -->
<!-- (scroll down) -->

从《雷神之锤III》的资料中,我在一些随机的帖子中偶然发现了这一点。该文件的完整源代码可以在这里找到。这是一种非常快速的求平方根倒数的方法。至于最好的评论呢?当然,这是一种常见的方法,但考虑到它附着在直线上,它的神奇之处在于它的伟大之处。

float Q_rsqrt( float number )
{
  long i;
  float x2, y;
  const float threehalfs = 1.5F;

  x2 = number * 0.5F;
  y  = number;
  i  = * ( long * ) &y;  // evil floating point bit level hacking
  i  = 0x5f3759df - ( i >> 1 ); // what the fuck?
  y  = * ( float * ) &i;
  y  = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
  // y  = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed

  #ifndef Q3_VM
  #ifdef __linux__
    assert( !isnan(y) ); // bk010122 - FPE?
  #endif
  #endif
  return y;
}

//When I wrote this, only God and I understood what I was doing
//Now, God only knows

options.BatchSize = 300; //Madness? THIS IS SPARTA!

伟大的一个泄露的Windows 2000源代码:

! !如果你把制表符换成空格,你会被杀死!!!!!!!* !!!!!!!!!!!!!!这样做会破坏构建 过程 !!!!!!!!!!!!!!!!* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

http://www.kuro5hin.org/story/2004/2/15/71552/7795


在1983年的COBOL中见过:

   C   I don't know what this next bit does so I'll jump around it
       GOTO DONE.

//迭代一次 美元我+ +;

不幸的是,它是我的,在我的“必须评论一切”阶段。


//Mr. Compiler, please do not read this.

当我在一些网站上工作时,我在嵌入式JS的开始发现了这一点:

我觉得这么做很肮脏,但那家伙想在。net中实现它


从C #

#region Hack - Shield Eyes Before Expanding

/// <summary>
/// A single uint with all of the bits set to represent the different tracing
/// </summary>
/// <remarks>
/// Ugly I know, so if you can think of a better way, feel free to rewrite.
/// </remarks>
[Browsable(false)]
public uint TraceBitfield
{
    // Snip
}

#endregion

很久以前,我遇到了一些连接脚本,虽然我不记得语法,但我记得注释,因为我是平克·弗洛伊德的粉丝。

//Attempt Handshake: Hello? This is London calling. Are we reaching you?


//Handshake Failed: I don't understand...he just hung up.

//Visual Studio Bug Workaround:
//http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=101677

//To fix 'CJumpToHelper::GetInstance()' : undeclared identifier compiler errors, change the number lines below
//until the file compiles correctly. (This needs to be done anytime a change is made to this file)

    //////////////////////////////////////: There should be 1-10 of these lines
    //////////////////////////////////////: There should be 1-10 of these lines
    //////////////////////////////////////: There should be 1-10 of these lines
    //////////////////////////////////////: There should be 1-10 of these lines
    //////////////////////////////////////: There should be 1-10 of these lines
    //////////////////////////////////////: There should be 1-10 of these lines
    //////////////////////////////////////: There should be 1-10 of these lines
    //////////////////////////////////////: There should be 1-10 of these lines
    //////////////////////////////////////: There should be 1-10 of these lines
    //////////////////////////////////////: There should be 1-10 of these lines

int MyFunction()
{
    // There once was a man named Dave
    int Result = 0;

    // Whose code just wouldn't behave
    MyObject *Ptr = new MyObject();

    // He left to go to a meetin'
    Result = Ptr->DoSomething();

    // And left his memory a leakin'
    return Result;
}

c++怎么样


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

当我还在路透社工作的时候,我们的一个feed处理人员发表了一条评论,让一些人认为万能的上帝在帮助我们……

// Jesus told me to skip to the end of the message here

后来我们发现有一个拉丁美洲的联系人叫耶稣(HeyZus)。


顶部的:靠近单位顶部的:

// Oh what a tangled web we weave
// When first we practice to deceive
// ASTA

一些来自Linux内核的代码:

/* Sun, you just can't beat me, you just can't.  Stop trying,
* give up.  I'm serious, I am going to kick the living shit
* out of you, game over, lights out.
*/

-

/* 2,191 lines of complete and utter shit coming up... */

-

#if 0 /* XXX No fucking way dude... */

这个我在Python 2.5的“twisted”包中找到的(文件是tcp.py在第371行)

# Limit length of buffer to try to send, because some OSes are too
# stupid to do so themselves (ahem windows)
return self.socket.send(buffer(data, 0, self.SEND_LIMIT))

我不再有确切的代码包,但我清楚地记得注释。

// The code below needs to be changed immediately.
// I wish I was a little bit taller
// I wish I was a baller
// I wish I had a girl who looked good, I would call her.

catch (Domain.ConcurrencyException)
{
    // somebody changed it between the time we loaded it and now.
    // weird, huh?
}

一个可怕的解码补丁(意大利语翻译):

/**
*@return the value 
*@param key: the id of the list of instruments
*@PS this function is a violation of all the laws of the 
*software engineering, 
*commons sense, highway code 
*and ONU decision about the coding.
That sh*t...
*/

这是众所周知的,但我喜欢它(在sys/ufs/ufs_vnops.c中):

/*
 * A virgin directory (no blushing please).
 */

在FreeBSD内核源代码树中(甚至在之前,回到4.xBSD)


在LKM中:

/*
* Dear Richard Stallman,
*
* This one's for you.
*
* Sincerely,
* Me
*
*/
MODULE_LICENSE( "GPL" );

/* Hammer Time! */

我不知道为什么,也不知道他在写代码时是否穿着防撕裂尼龙降落伞裤


有人抱怨说,“最好的”评论会带来最糟糕的评论。恕我直言,他们更有趣,所以“更好”,但这是我读过的最好的评论:

/*
Major subtleties ahead:  Most hash schemes depend on having a "good" hash
function, in the sense of simulating randomness.  Python doesn't:  its most
important hash functions (for strings and ints) are very regular in common
cases:

>>> map(hash, (0, 1, 2, 3))
[0, 1, 2, 3]
>>> map(hash, ("namea", "nameb", "namec", "named"))
[-1658398457, -1658398460, -1658398459, -1658398462]
>>>

This isn't necessarily bad!  To the contrary, in a table of size 2**i, taking
the low-order i bits as the initial table index is extremely fast, and there
are no collisions at all for dicts indexed by a contiguous range of ints.
The same is approximately true when keys are "consecutive" strings.  So this
gives better-than-random behavior in common cases, and that's very desirable.

OTOH, when collisions occur, the tendency to fill contiguous slices of the
hash table makes a good collision resolution strategy crucial.  Taking only
the last i bits of the hash code is also vulnerable:  for example, consider
[i << 16 for i in range(20000)] as a set of keys.  Since ints are their own
hash codes, and this fits in a dict of size 2**15, the last 15 bits of every
hash code are all 0:  they *all* map to the same table index.

But catering to unusual cases should not slow the usual ones, so we just take
the last i bits anyway.  It's up to collision resolution to do the rest.  If
we *usually* find the key we're looking for on the first try (and, it turns
out, we usually do -- the table load factor is kept under 2/3, so the odds
are solidly in our favor), then it makes best sense to keep the initial index
computation dirt cheap.

The first half of collision resolution is to visit table indices via this
recurrence:

    j = ((5*j) + 1) mod 2**i

For any initial j in range(2**i), repeating that 2**i times generates each
int in range(2**i) exactly once (see any text on random-number generation for
proof).  By itself, this doesn't help much:  like linear probing (setting
j += 1, or j -= 1, on each loop trip), it scans the table entries in a fixed
order.  This would be bad, except that's not the only thing we do, and it's
actually *good* in the common cases where hash keys are consecutive.  In an
example that's really too small to make this entirely clear, for a table of
size 2**3 the order of indices is:

    0 -> 1 -> 6 -> 7 -> 4 -> 5 -> 2 -> 3 -> 0 [and here it's repeating]

If two things come in at index 5, the first place we look after is index 2,
not 6, so if another comes in at index 6 the collision at 5 didn't hurt it.
Linear probing is deadly in this case because there the fixed probe order
is the *same* as the order consecutive keys are likely to arrive.  But it's
extremely unlikely hash codes will follow a 5*j+1 recurrence by accident,
and certain that consecutive hash codes do not.

The other half of the strategy is to get the other bits of the hash code
into play.  This is done by initializing a (unsigned) vrbl "perturb" to the
full hash code, and changing the recurrence to:

    j = (5*j) + 1 + perturb;
    perturb >>= PERTURB_SHIFT;
    use j % 2**i as the next table index;

Now the probe sequence depends (eventually) on every bit in the hash code,
and the pseudo-scrambling property of recurring on 5*j+1 is more valuable,
because it quickly magnifies small differences in the bits that didn't affect
the initial index.  Note that because perturb is unsigned, if the recurrence
is executed often enough perturb eventually becomes and remains 0.  At that
point (very rarely reached) the recurrence is on (just) 5*j+1 again, and
that's certain to find an empty slot eventually (since it generates every int
in range(2**i), and we make sure there's always at least one empty slot).

Selecting a good value for PERTURB_SHIFT is a balancing act.  You want it
small so that the high bits of the hash code continue to affect the probe
sequence across iterations; but you want it large so that in really bad cases
the high-order hash bits have an effect on early iterations.  5 was "the
best" in minimizing total collisions across experiments Tim Peters ran (on
both normal and pathological cases), but 4 and 6 weren't significantly worse.

Historical:  Reimer Behrends contributed the idea of using a polynomial-based
approach, using repeated multiplication by x in GF(2**n) where an irreducible
polynomial for each table size was chosen such that x was a primitive root.
Christian Tismer later extended that to use division by x instead, as an
efficient way to get the high bits of the hash code into play.  This scheme
also gave excellent collision statistics, but was more expensive:  two
if-tests were required inside the loop; computing "the next" index took about
the same number of operations but without as much potential parallelism
(e.g., computing 5*j can go on at the same time as computing 1+perturb in the
above, and then shifting perturb can be done while the table index is being
masked); and the dictobject struct required a member to hold the table's
polynomial.  In Tim's experiments the current scheme ran faster, produced
equally good collision statistics, needed less code & used less memory.

Theoretical Python 2.5 headache:  hash codes are only C "long", but
sizeof(Py_ssize_t) > sizeof(long) may be possible.  In that case, and if a
dict is genuinely huge, then only the slots directly reachable via indexing
by a C long can be the first slot in a probe sequence.  The probe sequence
will still eventually reach every slot in the table, but the collision rate
on initial probes may be much higher than this scheme was designed for.
Getting a hash code as fat as Py_ssize_t is the only real cure.  But in
practice, this probably won't make a lick of difference for many years (at
which point everyone will have terabytes of RAM on 64-bit boxes).
*/

我最喜欢的评论是:

//the XML returned from this request is *mind-bogglingly* bad. Terrifyingly bad.
//a completed batch looks like this:
//<Batch>batchid=363777811 status=Done dateandtime=09/18/2007 09:53:10 PDT activateditems=335 numberofwarnings=0 itemsnotacivated=17 </Batch>
//and an incomplete batch like:
//<Batch>batchid=363778361 status=In Progress </Batch>
//so we'll just parse each item as a regex. Thanks Amazon.

Amazon实际上是这样返回XML的。


在20世纪80年代早期的某个时候,我们在PL/I中为公用事业编写财务建模代码。接到一个客户的电话,说代码在评论之后就爆炸了

/* Honest this works */

这家伙用了我们的标准金融方程花了大约15页的代数把一堆代码组合成一个方程。在三里岛事件后,当公用事业公司不得不以巨大的代价注销他们的核电站时,这个方程失败了,因为FIXED BIN 15(整数)溢出,如果代数没有发生,就不会发生这种溢出。


// This code was written by a genius so don't try to understand it with
// your tiny little brain.

这是我们在前雇主购买的智能卡产品中发现的唯一一条评论。一群荷兰密码学博士写的嵌入式C语言和汇编程序

// echt halmaal gek - no way!

(它的意思是“真的完全愚蠢”……这对我们也没有帮助)


在某些汇编程序中,在包含&h723的行末尾

' RIP LVB

(明白吗?)


//说明:!!待办事项


在拉丁语中,从但丁的《神曲》中进入这里的人,请放弃希望。


// The ratio of a circle's circumference to its diameter.  Remember to change
// this to 3.0 if you move to a site in Indiana.

#define Pi                                      3.1415927

不是一个评论,而是一个goto标签

ICantBelieveImUsingAGoto:

REM Don't delete this print statement ****** will die

所讨论的流程是一些遗留代码中的服务


从Joomla !来源:

// fudge the group stuff

从Joomla !来源:

// this is daggy??

# let's pretend we are free, for a while

在教室前面发现了这个。接下来是一个(天真的)实现ORM的尝试。我还是不明白他为什么这么写。


/**
 * Always returns true.
 */
public boolean isAvailable() {
    return false;
}

永远不要依赖评论……


Dennis M Ritchie在这里有一个关于一些古老UNIX注释的页面


来自c#中的单元测试类:

#region quis custodiet ipsos custodes?

[Fact]
public void TestPositive()
{
    Assert.Equal(4, 2 + 2);
}

[Fact]
public void TestNegative()
{
    Assert.Equal(5, 2 + 2);
}

#endregion

我看到有人对代码的评论:

// This comment is self explanatory.

我猜他是想说“可变的”,但这个错误造成了一个有趣的评论……想想这里的循环逻辑,以及写它的徒劳。


对上帝诚实:

// This is crap code but it's 3 a.m. and I need to get this working.

// I love the smell of dirty XML in the morning
xml = xml.Replace("xmlns=\"urn:bsd.orion/inventory\"", "");

在初始化链表时:

last = first; /* Biblical reference */

简洁而滑稽。


// If you're reading this, that means you have been put in charge of my previous project.
// I am so, so sorry for you. God speed.

i++; //increment i

Linux的评论

这里有很多不错的……

这些都是linux中的注释

http://lwn.net/1998/1015/a/f-word.html

我的最爱:

./arch/sparc/kernel/ptrace.c
/* Fuck me gently with a chainsaw... */

./drivers/scsi/qlogicpti.h
/* Am I fucking pedantic or what? */

我尤其对此感到内疚,在我的大多数项目中嵌入了非建设性的注释、代码诗歌和小笑话(尽管我通常有足够的理智在发布代码之前删除任何直接冒犯的内容)。这里有一个我特别喜欢的,放置在一个设计很差的“上帝物体”下面:

/**
* For the brave souls who get this far: You are the chosen ones,
* the valiant knights of programming who toil away, without rest,
* fixing our most awful code. To you, true saviors, kings of men,
* I say this: never gonna give you up, never gonna let you down,
* never gonna run around and desert you. Never gonna make you cry,
* never gonna say goodbye. Never gonna tell a lie and hurt you.
*/

我很抱歉! !我就是忍不住.....!

还有一个,我得承认我还没有真正把它放出来,尽管我很想在我的一个不那么直观的课上这么做:

// 
// Dear maintainer:
// 
// Once you are done trying to 'optimize' this routine,
// and have realized what a terrible mistake that was,
// please increment the following counter as a warning
// to the next guy:
// 
// total_hours_wasted_here = 42
// 

我前几天刚检查过这个…

/// <STERNLY-WORDED-WARNING>
/// Pay attention to this or I will hunt you down.
/// ...
/// </STERNLY-WORDED-WARNING>

(“……”== "专有的东西,我不能发布")。我只是喜欢我的措辞严厉的警告元素。


//  Hey, your shoe's untied!

后面跟着一些可疑的代码,在这些代码中,

//  Keep looking!  I think it was the other shoe!

最后,

//  How strange -- I must be seeing things.  Anyhow, I'm going to go take a shower, now...

我只是在一个非常简单的大学课程测试c++程序中碰到了这个。

我在评论一个类。

在析构函数中…

// Choose! Choose the form of the Destructor!
// The choice is made! The Traveler has come!

在js代码中:

// hack for ie browser (assuming that ie is a browser)

我曾经使用MS SQL Server Developer 2000实现了一些文档工作流(人工工作流的东西)。

它由一堆触发器组成,这些触发器将被添加到数据库中,使其遵循工作流规则。

在其中一个触发器中,微软的某个人写了如下内容:

//Determine if the database has been "Grizzlified"

(该产品的内部名称是“Grizzly”,所以我觉得这很有趣)。


我曾经见过这个:

//this used to be a comment

这是在PHP代码中找到的

$s=2; // chicken and bacon wrap for lunch

多么有用,幸运的是$s是不言自明的


-- Beyond this point, there'll be dragons

我觉得更长的说法^^更能说明问题


// long live COM'n'Roll
public enum StatusCode
{
        //success codes
        S_OK                                            = 1,
        S_NONE                                          = 2,
        S_SQL_OPERATIONS_LISTS_EMPTY                    = 3,

        //error codes
        E_NO_MATCHING_END_FOUND                         = -1,
        E_SEQUENCE_NUMBER_NOT_FOUND_AT_BEGINNING        = -2,
        E_SEQUENCE_NUMBER_NOT_FOUND_AT_END              = -3,
        E_FORWARD_AND_BACKWARD_OPS_COUNT_DO_NOT_MATCH   = -4,
        E_FORWARD_AND_BACKWARD_IDS_DO_NOT_MATCH         = -5,
        E_IDS_DO_NOT_MATCH                              = -6
}

// HACK ! COPY/PASTE this and look for another job

// Caveat implementor

来自Apache Xalan源代码:

/**
 * As Gregor Samsa awoke one morning from uneasy dreams he found himself
 * transformed in his bed into a gigantic insect. He was lying on his hard,
 * as it were armour plated, back, and if he lifted his head a little he
 * could see his big, brown belly divided into stiff, arched segments, on
 * top of which the bed quilt could hardly keep in position and was about
 * to slide off completely. His numerous legs, which were pitifully thin
 * compared to the rest of his bulk, waved helplessly before his eyes.
 * "What has happened to me?", he thought. It was no dream....
 */
protected static String DEFAULT_TRANSLET_NAME = "GregorSamsa";

进一步阅读The Daily WTF。


这一点对其他人来说很有趣,但对我来说就不那么有趣了。我从一个开发人员那里继承了代码(ASP),而他自己也继承了它。第一个程序员编写了一些很难理解的代码。第二个开发者添加了如下评论(为了保护不那么无辜的人,名字被隐藏了):

'This code was written by **************.
'I haven't a clue what it does. He hasn't a clue what it does.
'Nobody else has a clue what it does or how it does it.
'It is something to do with data but **** knows what.
'The ******* still works so please do not change this code,
'even though it is a complete pile of ****.

那我为什么不觉得有趣呢?嗯,这是一个客户内部网的ASP代码。

...正是那位顾客向我强调了这条评论。

:-(


//Woulda
if(x) {}
//Shoulda
else if(y) {}
//Coulda
else {}

不是代码注释,而是SVN在同一个文件上提交注释:

第一次提交(在测试人员返回结果后,再进行数十次提交):

Squashed some IPR mod bugs. The were big and juicy ones, too.

2日提交:

Squashed some more mod bugs. Those are some nasty bugs, them mod bugs...

3rd:

Squashed some more mod bugs. They are like cockroaches: they'll live through a nuclear war.

4th:

Squashed some more John bugs. They too are like cockroaches: they appear anywhere John goes. Wait. That doesn't sound right.

5:

Same John bug. It didn't die, just played 'possum.

是的,我厌倦了"修复bug"


.class {border:1px solid gold;} /*我可怜这个傻瓜*/


// StupidCompilerDontInline(SCDI), in the test project where
// allcode was in a single cpp the compiler had inlined nearly
// everything which lead to nice stackoverflow.
// To prevent this the metods are made virtual
#define SCDI virtual

//MailBody builders for two outgoing messages
StringBuilder hanz = new StringBuilder();
StringBuilder franz = new StringBuilder();

当我读到这篇文章时,我仍然会笑出声来……


最近在我们的代码中发现了这一点(我们开发企业软件):

// Instance of excel
Excel excel = this.CreateExcelInstance();
excel.Open(stream); // how to close it?!

在此之前,我确信我们已经摆脱了这些“有趣的东西”,我们正在以正确的、意识形态正确的方式做这件事……


以下注释来自我必须调试的一个旧项目:

//Haleluya i can go home!

从谷歌代码项目:

# This job would be great if it wasn't for the fucking customers.

有一次我发现:

// I wish (boss name) could do this by him self.

有一次,我问一个同事如何用我们的内部框架做一些事情(忘了具体是什么,一些晦涩的技术调用)。 他说“简单,看这里”,然后在他的编辑器中打开一个。java文件,在几页代码中间给我看了这个注释:

// HERE

我刚刚检查了一下,注释仍然在这个文件中:)


我喜欢GNU双utils中的一些注释。这个来自BFD som.c:

/* You'll never believe all this is necessary to handle relocations
   for function calls.  Having to compute and pack the argument
   relocation bits is the real nightmare.

   If you're interested in how this works, just forget it.  You really
   do not want to know about this braindamage.  */

这个也是:

/* Don't ask about these magic sequences.  I took them straight
   from gas-1.36 which took them from the a.out man page.  */

...

/* Keep track of exactly where we are within a particular
   space.  This is necessary as the braindamaged HPUX
   loader will create holes between subspaces *and*
   subspace alignments are *NOT* preserved.  What a crock.  */

另一个:

/* We will NOT put a fucking timestamp in the header here. Every
   time you put it back, I will come in and take it out again. ... */

从气体:

/* Yes this is ugly (storing the broken_word pointer
   in the symbol slot).  Still, this whole chunk of
   code is ugly, and I don't feel like doing anything
   about it.  Think of it as stubbornness in action.  */

我曾经参与过Windows 3.0的源代码。(我赶紧补充一句,作为一名微软员工,不是!)在那里,我遇到了一个文件加载器,它可以多次重新输入,并且有一个讨厌的双关语的例子(只是为了显示作者有多聪明)。

这些乱七八糟的可重入代码是用Intel程序集jmp指令(在C代码中间)执行的,它的标签是“we_are_not_in_kansas_any_more_toto”。


我猜它被病毒式传播了,我在一个守护进程(Linux)中发现了以下防止OOM杀手选择它:

/*
 * Don't OOM me, bro!
 */

这紧跟在mlockall()之后,以防止进程交换,注释如下:

/*
 * Don't swap me, bro!
 */

try {
   doSomething();
} catch(err) {
   // Die quietly
   alert(err);
}

曾经有一个为我工作的程序员在他的代码中加入了“Style”注释,他在代码中编写了关于特定实现细节的内部争论,当他在某个特定的编码决策上被否决时,他就会离开。

例子:

的风格 '这是有争议的,但我传递图像句柄,而不是简单地 '传递缩放值,以保持调用代码更简单(通过a '一对声明语句)。或者,我可以传递这些数据 成员,但这将违反封装。

的风格 就像我在其他地方做过的一样,我将正式提出抗议 的表格),将注释序列化的实现视为 '一个属性,而不是一对Load/Save方法。这可能是 “风格的问题,值得商榷。


Exception up = new Exception("Something is really wrong.");
throw up;  //ha ha

'this next if statement - just how it is. don't try to understand it because you won't. :)

这就是工作保障。


// barcore.cpp - MFC

//.....
HBRUSH CControlBar::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
    LRESULT lResult;
    if (pWnd->SendChildNotifyLastMsg(&lResult))
        return (HBRUSH)lResult;     // eat it

//......

// Eat it - just like eat this.

// Iced odnako
bool Iced{get;set;}

/////////////////////////////////////// this is a well commented line

几年前我在。h文件里看到的。

// It may be a hack, but it works.

我在COBOL程序中看到的一些东西让我感到恐惧

* All comments pertain to the lines which follow.

这是什么意思?

有人对评论感到不舒服,以至于不得不写一个元评论? 有人习惯将注释放在相关代码的下面,而被告知要将注释放在上面?这是怎么发生的?


在游戏中,这个物体可以被踩到,或者:

stepOff(); //bitch

在一个项目中,我们有一个依赖ppwlib,当时它的FreeBSD端口有点糟糕,所以我不得不从源代码手动构建它。但它并没有立即起作用,我不得不研究代码;有一些复杂的类层次结构,部分代码是由宏生成的,其父类声明以它们开始

// The root of all evil ... umm classes

long long ago; /* in a galaxy far far away */ 

在我决定用脚本语言取代它之前,我必须将它添加到旧的数据驱动规则引擎中。

        /************************************************************
        *                                                           *
        *  .=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-.       *
        *   |                     ______                     |      *
        *   |                  .-"      "-.                  |      *
        *   |                 /            \                 |      *
        *   |     _          |              |          _     |      *
        *   |    ( \         |,  .-.  .-.  ,|         / )    |      *
        *   |     > "=._     | )(__/  \__)( |     _.=" <     |      *
        *   |    (_/"=._"=._ |/     /\     \| _.="_.="\_)    |      *
        *   |           "=._"(_     ^^     _)"_.="           |      *
        *   |               "=\__|IIIIII|__/="               |      *
        *   |              _.="| \IIIIII/ |"=._              |      *
        *   |    _     _.="_.="\          /"=._"=._     _    |      *
        *   |   ( \_.="_.="     `--------`     "=._"=._/ )   |      *
        *   |    > _.="                            "=._ <    |      *
        *   |   (_/                                    \_)   |      *
        *   |                                                |      *
        *   '-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='      *
        *                                                           *
        *      LASCIATE OGNI SPERANZA, VOI CH'ENTRATE               *
        *************************************************************/

对于我编写的memcache包装器/处理程序接口模式类,我实现了以下方法。

/**
*  Do not use, ever - left in place for testing purposes
*/
function  I_David_WillHuntYouDownAndHurtYou_Badly_IfIFindThisUsedAnyWhereInTheAppLibrary(){
...
}

这基本上是一个超级核函数,它告诉所有单独的memcache服务完全刷新自己,并从我用于键的单个名称空间计数器(例如{_counter_key value}_)重新开始。{_counter_key value})

Another minor novella I wrote was for an automated downloader for a data vendor, detailing how much I hated this vendor and went to great lengths of postulating that their infrastructure's batch system was run by a gerbil, running on a wheel and after so many revolutions of the wheel the next queued task would be started. It was written over the course of 6 months of adding additional exception handling, estoric checks like ( if we got 768 Bytes of \s characters, that means the query to their DB timed out and the spaces are the result of empty failure print statements.


在大学的一次家庭作业中,一位老师特别坚决地要求我们注释代码:

//I wonder if she actually reads these.

当作业被返回时,在注释“是的,我愿意”旁边用红笔写着


// Oh crap, i think i'm gonna yack

随后不久又有:

// TODO: end this lunacy

class Act //That's me!!!
{

}

try {

}
catch (SQLException ex) {
    // Basically, without saying too much, you're screwed. Royally and totally.
}
catch(Exception ex)
{
    //If you thought you were screwed before, boy have I news for you!!!
}

我最喜欢的(我必须承认我用过很多次):

// Yes...I know this is repulsive and stupid.
// But <%CompanyOwnerOrManagerToken%>, not knowing a thing about code,
// demanded I do it anyways. SO, go crap on their desk, not mine.
// K THX BYE 

不是在代码中,而是在相关的bug跟踪系统中:

这不可能是我代码中的bug。我非常小心地编码。


try
{
...
}
catch(Exception ex)
{
//if this happens the world is going to end...
}

现在猜猜发生了什么……


//  If you delete the credits, I will fucking kill you.

在joomla模块中找到。


   // Some wanker in ISO got rid of ifstream(int), ofstream(int), and
   // fstream(int).  Twit.

我不知道这是有趣还是悲伤..但是和我一起工作的一个实习生有这个小宝石来计算每个单位的价格

...

// get the units from the form 
int numUnits = Integer.parseInt(request.getParameter("num_pieces")); // this break at random times

//price 
float price = Float.parseFloat(request.getParameter("price")); // same as above

// Under certain conditions the following code blows up. I don't know those conditions.
float pricePerUnit = price / (float)numUnits;

...

... 或者去死//婊子


/**---------START-----------**/

  //  IMPLEMENTATION GOES HERE

/**---------END-----------**/

但没有代码;)


// John! If you'll svn remove this once more,
// I'll shut you, for God's sake!
// That piece of code is not “something strange”!
// That is THE AUTH VALIDATION.

你怎么看?下面的代码是安全的“svn删除”。


这是我今天重构一些代码时发现的一条评论

if( year < 100 ): year += 2000 #lol, Y2K

$this->getSelect()->where ('main_table.product_id = -1'); // Mom, Dad... sorry

// insert comment here

} catch (PartInitException pie) {
    // Mmm... pie

我只是在我自己的代码中遇到了这个问题。它在一个用于类别选择的洋红色管理模板中:

        /*
         * OK; before you read the following code know what I am trying to do.
         * I needed to get the list of child catagories from the root node so that
         * the root node didn't appear in the selection box. But for some stupid
         * fucking reason the stupid fucking DBA wont let me access the items using
         * indicies and I instead have to use their stupid fucking Iterator
         * implementation. So there.
         */
        $firstList = $this->getRootNode()->getChildren();
        foreach ($firstList as $node)
        {
            $nodes = $node->getChildren();
            break;          // wtf?
        }

我要把语言从我们的旗舰产品中移除;但我记得我非常沮丧。如果我没有留下评论,我会试着修改它,但会遇到和以前一样的问题。


回到《Hitchhiker’s Guide》刚问世的时候,我曾经测试过某些内容是否可滚动,以及用户是否尝试着滚动,这是一种限制可变长度的语言。所以:

if (scroll and noScroll) # or tea and no tea

// nobody read comments!

这在我自己的代码中出现过几次。显然我摸了不止一次。

// TODO: Fix this.  Fix what?

我在查看TVNZ网站早期迭代的HTML源代码时发现了这个宝藏(如果你在家玩的话,从571行开始):

<!-- Hopfully we can do this otherwise the nav is going to be pretty plain and Hong will go postal. -->

// The hackiest hack that ever did hack

它在WordPress博客引擎(wp-admin/includes/user.php -如果有人真的想看黑客攻击本身)。


//If the Current Record is Getting End Dated, We should not create New History Entry. 
//We Just need to Update the Previous History Entry
//If the History is already End Dated and the New Record is now removing End Date, Then 
//We should not update the Previous History End Date. 
//We Just need to Create the New History Record Only.
//Alright.. 
//Alright.... 
//Enough Comments. Code it. :-)

#define SHIT_HAPPENED (BASE + 1)   /* generic shit happened */

在eMule, Preferences.cpp中,强制最小上传速度限制与下载速度限制成正比的方法:

uint16 CPreferences::GetMaxDownload(){
//dont be a Lam3r :)
    uint16 maxup=(GetMaxUpload()==UNLIMITED)?GetMaxGraphUploadRate():GetMaxUpload();
    if( maxup < 4 )
        return (( (maxup < 10) && (maxup*3 < prefs->maxdownload) )? maxup*3 : prefs->maxdownload);
    return (( (maxup < 10) && (maxup*4 < prefs->maxdownload) )? maxup*4 : prefs->maxdownload);
}

/* FIXME This must absolutely be removed before 4.0.7 release
 * TODO really remove this */

我们已经发布了4.0.7,4.0.8,4.0.9和4.1版本…


我最喜欢的是一个用java编写的学校项目的一些业务逻辑中的一个变量名。

int StupidJava = -1;

刚刚在一些Actionscript中发现了这个,我必须更新…

/*
* spaghetty code in this module.
* hardcoded variables for load paths for the content window.
* Needs (vast) improvement.
*/

..大:(


// A Gorgon class - For the love of Zeus don't look directly at it!

有一次,我在另一个讨论中看到这样的内容:

// I can't divide with zero, so I have to divide with something very similar
result = number / 0.00000000000001;

聪明的解决方案,不是吗?(如果有人不确定,这就是个笑话)


这比你在许多评论标题中看到的可怕的法律通知和免责声明要好得多。从SQLite。

/*
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
*/

经典的旧netscape mozilla代码。我个人喜欢

就是不能乱来。而且移动记忆会毁了我们,还有 一切都太他妈难搞清楚了。所以,我放弃了,Mac 完全完全地吸走完整的岩石

但还有很多其他有趣的。


// TODO: Drive an ashen stake through the foul heart of this function.

这是一个糟糕的函数。直到今天我还在做噩梦。


// this error could never happen

然后,客户打电话说他看到一条错误消息说"这个错误永远不会发生"


大学时代:

//why the f*** we have to move this here to make it work

当我们和教授一起复习的时候,它在印刷资料中被突出了。

原因是:一些与缓冲区溢出相关的严重错误,影响了代码中其他位置的文件处理程序中不相关的变量。移动变量将使它再次工作。


// Sorry dirty code

//Dear future me. Please forgive me. 
//I can't even begin to express how sorry I am.  

我今天刚发现了这个:

//private instance variable for storing age
public static int age;

在drivers/net/sunhme.c (Linux内核)中:

/* Welcome to Sun Microsystems, can I take your order please? */
if(!hp->happy_flags & HFLAG_FENABLE)
        return happy_meal_bb_write(hp, tregs, reg, value);

/* Would you like fries with that? */
hme_write32(hp, &tregs->frame,
            (FRAME_WRITE | (hp->paddr << 23) |
             ((reg & 0xff) << 18) | (value & 0xffff)));
while(!(hme_read32(hp, &tregs->frame) & 0x10000) && --tries)
        udelay(20);

/* Anything else? */
if(!tries)
        printk(KERN_ERR "happy meal: Aieee, transceiver MIF write bolixed\n");

/* Fifty-two cents is your change, have a nice day. */

// Empty constructor to satisfy the stupid compiler
 Public ServletHandlerClass () { } 

catch (Exception ex)
{ 
    // just die already.
}

我们有一个文件,在它的一半,一个程序员试图弄清楚混乱的意义,设法将所有无意义的代码移到底部,并留下了这样的评论:

I have no idea what this stuff does below here.

另一名程序员留下了一系列嵌套的命名空间,这些命名空间的作用类似于“方向手册”,这样您就可以钻取想法中的名称空间并选择您的操作。


看这个:

'On Error Goto Hell.

BerkeleyDB

/*
 * Chaos reigns within.
 * Reflect, repent, and reboot.
 * Order shall return.
 */
return (DB_RUNRECOVERY);

 /**
   * Returns cookies according to the filters specified.
   * 
   * @return array  Cookies!  Nom nom nom nom nom.
   */
 public function data_getCookies($uid, $name) {

在facebook api的某个地方。


在一个艺术资产导出工具中,我偶然发现了一个从数字(阿拉伯)到罗马数字的完整转换器。它是这样的:

/*
//You can tell I was bored
//I wanted to do this for a long time
char* ConvertToRoman(int number, int base)
{
... whole code here
}
*/

编写这段代码的人的团队已经处理了很长时间,我猜这影响了他们的理智。


// Hack-er-ama

# Don use this. Never!

else
{
    //error situation
}

大约10年前,我从事图像处理工作,通过扫描显微镜视频帧来检测细胞运动。我当时在做一个特别复杂的工作,决定和朋友出去喝一杯。当我回到家时,我工作了一会儿,但没有太多,因为我喝醉了。第二天早上,我发现了一个10行完全混乱的函数,带有以下注释(显然是我自己写的):

/* Ah ah ah! You'll never understand why this one works. */

最奇怪的是,它竟然起作用了。


#pragma region Crap that is kept for temporary reasons

    //  Huge chunk of commented code

#pragma endregion

// If I from the future read this I'll back in time and kill myself. 

//marco 2007.1.23
//I didn't do it

好吧,这些是我的,所以WTF是我,正如CodingHorror所说:

//#region Code for weird cases - do you really want to know?

我曾经在一些ASP中留下了这样的评论:

' Commented out following code, don't delete for when [CustomerName] changes his mind

碰巧,[CustomerName]没有改变他的想法,但他确实有访问web服务器,他确实找到了那行…


设法把这个糟糕的双关语插入到我们的代码中

for (bo_thans = 0 ; bo_thans < MAX ; bo_thans++)
{
    if(rs == thing[bo_thans])
    {
       found = true;
    }
}

if(!found)
{
   /* Failed to find rs with bo_thans */
   ...
}

当我注释掉我认为不再有用的代码块,但我可能是错的(因此没有删除它们),我有时会在它们之前

// Wilted celery?

这个想法就像芹菜一样枯萎了,但你还是把它放回冰箱里。我只知道十年后会有人看到这些评论,说什么鬼?


// Keep prozac ready if things get ugly!

// now swap like a <explicative removed>

// haack, phil haack

and:

/* hack, hack, hack, hack, hack hack, hack, hack
 * hackity hack, oh wonderful hacks
 * wonderful hacks, oh wonderful hack, hack, hack
 * hack hack hack... and spam 
 */

编辑:刚刚在我的一些代码中发现了这个(项目希望保持匿名):

// yikes, we need to:
/*
 *       o
 *      -|-     < US CROSSING PLATFORM
 *       |\ 
 ************************************************
 *       |          ^ PLATFORM           |
 *       |                           T   |
 *       |                      TROLL^   |
 */
// right now:
/*
 *   o ./_  | 
 *  -|-[]\  |  (_'_) () (\) | ) \|/ (S) < WALL
 *   |\     |    ^ FRIENDLY MESSAGE FROM YOUR FRIENDS AT MICROSOFT
 *  ***********************************************
 *        | ^PLATFORM                       |
 *      ^ SPRAY CAN (IN HAND)
 */
public static class DefaultFonts
{
    public static string SansSerifPath
    {
        get { return @"C:\Windows\Fonts\arial.ttf"; }
    }
    public static string SerifPath
    {
        get { return @"C:\Windows\Fonts\times.ttf"; }
    }
    public static string MonospacePath
    {
        get { return @"C:\Windows\Fonts\courier.ttf"; }
    }
}

我好喜欢双关语。


map(TimeZoneId.Romance, "Romance Standard Time"); //LULZ.

/*
This isn't the right way to deal with this, but today is my last day, Ron
just spilled coffee on my desk, and I'm hungry, so this will have to do...
*/

return 12; // 12 is my lucky number

// This interface defines method signatures<br>
interface IWhatever { ... }

我曾经想出了一个我认为很优雅的解决方案来解决一个特别棘手的问题,现在回想起来,这有点令人费解,并且大量使用了宏编程。多年以后,我从一个维护程序员那里发现了这条评论

/*
    Description: The Total Perspective Vortex derives its picture of the
                 whole Universe  on the principle of extrapolated matter
                 analyses.

                 To  explain  -  since every piece of matter in the Universe
                 is in some way affected by every other piece of matter in
                 the  Universe,  it  is  in  theory possible to extrapolate
                 the whole of creation - every sun, every planet, their
                 orbits, their composition and their economic and social
                 history from, say, one small Macro.

                 The man who invented the Total Perspective Vortex did so
                 basically in order to annoy the IT department.

                 Steve Weet - for that was his name - was a dreamer, a
                 thinker, a speculative philosopher or, as some would have
                 it, a slacker.

                 And they would nag him incessantly about the utterly
                 inordinate amount of time he spent staring out into space,
                 or mulling over the mechanics of Chelsea FC, or doing
                 spectrographic analyses of macros.

                 "Have  some  sense  of  proportion!"  they would say,
                 sometimes as often as thirty-eight times in a single day.

                 And so he built the Total Perspective Vortex - just to show
                 them.

                 And into one end he plugged the whole of reality as
                 extrapolated  from one  macro, and into the other
                 end he plugged the IT department: so that when he turned it
                 on they saw in one instant the whole infinity of creation 
                 and theirselves in relation to it.

                 To  Steve Weet's horror, the shock completely annihilated '
                 their brains; but to his satisfaction he realized that he
                 had proved conclusively that if life is going to exist in a
                 Universe of this size, then the one thing it cannot afford
                 to have is a sense of proportion.

*/

一个承包商在申请一家英国银行。

// i don't know how this works but it does so i'll leave it here anyway

他还增加了BNP(英国极右翼政党)作为测试的虚拟客户之一…我们的顶头上司是亚裔。


多年前,我遇到了这样一个问题:

/***************************************************************************/
/*  deep wizardry. do not touch.                                           */
/*                                                                         */
/*  no seriously.  XXXXXX I'm looking at you. If you screw with this again */
/*  I will kill you with my swingline stapler.                             */
/*                                                                         */
/* ...                                                                     */

然后描述了一个特别复杂的算法。


// This is a walkaround for bug #7812

是我们的一个中国程序员写的,他的第一语言不是英语。

我真的很喜欢这个。我碰巧认为“walkaround”几乎比“workaround”更好。


<!-- Here it is -->

没有其他评论了。直到今天我都不知道“它”是什么。


这似乎阻止了白痴搞砸我的代码…

// Autogenerated, do not edit. All changes will be undone.

下面是我在不同时间放入代码中的一些代码。有些不是严格意义上的评论,但它们是相同的概念。

在一个跨平台项目中,只需要在一个平台上执行一些特殊代码:

//If defined, will include all the Windows-specific code.
#define LOSE

#ifdef LOSE
#include <windows.h> //WIN32. Duh.
#endif


---------------------------------------------------


//Stolen from other_project_name.cpp


---------------------------------------------------


/*
 * These comments have been lifted from propagate() and, though they no longer apply to the code, they may still be of value somewhere. Original tabbing and structural elements have been preserved.
 */
    //CAUTION: This has a major Bobby Tables risk. Even if a rulebuilder is used, there's still the risk of something getting corrupted in the database itself.
    //Reading text from anywhere and simply slotting it into an SQL statement is a major security risk. (With thanks to xkcd for the name "Bobby Tables".)
    //Requirement: Eliminate one Bobby Tables by changing [redacted] to be not just straight SQL.
[lots more comments that are not as funny]
/*
 * End of lifted comments. There should not be any executable code between these markers.
 */


---------------------------------------------------


        /*
        Okay. It's unrecognized. Why is this a fatal error? It's actually very closely akin to the miswart of botched #includes being a fatal. When writing a C/C++
        program, you need your headers, and if you don't have one, chances are there'll be a million cascaded errors; so by making "unable to open asdf.h" a fatal,
        the compiler suppresses all those errors about undefined symbols and potentially misspelled type names.
        */


---------------------------------------------------


    //If someone tries to import 'id' as a field name, it won't work. (We already have our own id.) But I think the probability is so low that I can afford to be funny.
    if (!stricmp(ptr,"id")) {warn(0,"Import","","'id' is a reserved word and cannot be used as a column name. (Try 'ego' or 'superego'.)"); return;}


---------------------------------------------------


//Need a place to squirrel away SQL statements somewhere
char *uts[1024]; //Unified Temporary Storage. (Why? Because I said so.)
int nuts=0; //What is it that squirrels keep? Ha!
int utsid[sizeof uts/sizeof *uts];


---------------------------------------------------


        /**************************************\
         * NOTE: This sets tilde.action. If a *
         * tilde header does not exist in the *
         * import file (not the _content_, if *
         * the entire column isn't there), it *
         * will duplicate down through all of *
         * the rows. This is fine for ~id, as *
         * that will never be changed; and if *
         * ~Quantity is blank, that throws an *
         * error in 'Add'. With ~Action, I am *
         * not so certain. I THINK it'd be OK *
         * to dup-down most of the time... if *
         * the user only ever imports Adds or *
         * Revises, but never both at once in *
         * a single import. So for safety, to *
         * allow a blank ~Action to revise OR *
         * add, I'm breaking the check out to *
         * a new variable - the curaction. In *
         * most cases, it won't be needed, so *
         * it's a waste; but it isn't like it *
         * has to copy the entire tilde.*, so *
         * it's only a small waste. So it can *
         * waste a register... big deal. OK ! *
        \**************************************/


---------------------------------------------------


            //if (!response) // we're going to crash
            //if (!items) // we're going to crash
            //TODO: Don't crash


---------------------------------------------------

我的很多评论都隐晦地提到了电影或音乐剧,但如果你不了解这部剧,它们就不会那么有趣了。


// (c) 2000 Applied Magic, Inc.
// Unauthorized use punishable by torture, mutilation, and vivisection.

啊,我一直很喜欢这个……


/**
 * If you don't understand this code, you should be flipping burgers instead.
 */

我曾经在一个项目中发现了这样的评论:

// Cabbage fart?

我不知道那是什么意思。还好我的魔方不在写它的人旁边。


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;
}

/* Look not upon this file lest your eyes be burnt from your head. */

我能说什么呢?我当时是实习生,夏天快结束了。我们可以说,我对我的文件责任缺乏认真的承诺。


// error codes
#define ERROR_SUCESS 0
#define ERROR_SUCCESS_IS_MISSPELLED 1

没有定义其他错误代码。


我刚刚在一些遗留代码中发现了这个..

'CANNOT JUST QUIT!

// This condition can't happen. Call the police or something.

//The following 1056 lines of code in this next method 
//is a line by line port from VB.NET to C#.
//I ported this code but did not write the original code.
//It remains to me a mystery as to what
//the business logic is trying to accomplish here other than to serve as
//some sort of a compensation shell game invented by a den of thieves.
//Oh well, everyone wants this stuff to work the same as before.
//I guess the devil you know is better than the devil you don't.

我所见过的最好的评论是

/* 
  There is no accounting for pointers 
*/

<cftry>
...code...
<cfcatch>
  <!--- Gobble --->
</cfcatch>
<cftry>

我公司的代码库里到处都是。它是ColdFusion,它会忽略错误。


On error resume next 'because nothing will ever go wrong!

var arbitraryNumber = 10;
//I don't know why. Just move on.

我没有这个来源的副本,但我一直记得它:

//如果你想不明白,就不要读这篇文章


def leppard
# what, i cant have my own convention?
end

来自Linux内核源代码:

linux /包括/ asm-i386 / hw_irq。h:

/*
 * subtle. orig_eax is used by the signal code to distinct between
 * system calls and interrupted 'random user-space'. Thus we have
 * to put a negative value into orig_eax here. (the problem is that
 * both system calls and IRQs want to have small integer numbers in
 * orig_eax, and the syscall code has won the optimization conflict ;)
 *
 * Subtle as a pigs ear.  VY
 */

double t = 0.0; /* that's generally my opinion of the diner, too. */

private static final Logger lager = new Logger();

从2004年的Windows泄露事件来看,

__inline BOOL
SearchOneDirectory(
                  IN  LPSTR Directory,
                  IN  LPSTR FileToFind,
                  IN  LPSTR SourceFullName,
                  IN  LPSTR SourceFilePart,
                  OUT PBOOL FoundInTree
                  )
{
    //
    // This was way too slow. Just say we didn't find the file.
    //
    *FoundInTree = FALSE;
    return(TRUE);
}

/*
* Wirzenius wrote this portably, Torvalds fucked it up :-)
*/

我一直很喜欢Paul DiLascia在他的文件头中写的:

// If this code works, it was written by Paul DiLascia. If not, I don't know
// who wrote it

$dnstime = time() + 60 * 60 * 24 * 7 * 2; //how long are you staying for vacation on mars? twooo weeeeeks. give dees people air

/**
 * Not even your mum thinks you're special if you call this method
 */    
onlyYourMumThinksYoureSpecialIfYouCallThisMethod() {...}

switch(value)
{
   [...]
default:
   ASSERT(**true**); // if this is triggered, something really bad is happening.
}

//        .==.        .==.          
//       //`^\\      //^`\\         
//      // ^ ^\(\__/)/^ ^^\\        
//     //^ ^^ ^/6  6\ ^^ ^ \\       
//    //^ ^^ ^/( .. )\^ ^ ^ \\      
//   // ^^ ^/\| v""v |/\^ ^ ^\\     
//  // ^^/\/ /  `~~`  \ \/\^ ^\\    
//  -----------------------------
/// HERE BE DRAGONS

我没有原始文件的权限,因为我已经不在那里工作了,但它和这张照片非常相似。它位于文件的顶部,总是会引起麻烦,我们必须修复,但不允许花时间真正修复。(大学政治)


//FIXME: fix this before the 1.0 release

他们在第4版


What do you think you're doing, Dave?

def format_ticket_content(text, recursive = true)
  if text.is_a?(TicketNote)
    note = text
    text = note.content
  else
    note = nil
  end

  ## Safety pig has arrived!
  text = h(text)
  ##                               _
  ##  _._ _..._ .-',     _.._(`))
  ## '-. `     '  /-._.-'    ',/
  ##    )         \            '.
  ##   / _    _    |             \
  ##  |  a    a    /              |
  ##  \   .-.                     ;  
  ##   '-('' ).-'       ,'       ;
  ##      '-;           |      .'
  ##         \           \    /
  ##         | 7  .__  _.-\   \
  ##         | |  |  ``/  /`  /
  ##        /,_|  |   /,_/   /
  ##           /,_/      '`-'
  ## 

摘自UNIX版本6源代码,大约1975年:

/* You are not expected to understand this. */

when :orientation
## Avoid matching gay people with straight people - they hate it, they do, they really do.
query_parameter = "(users.orientation = 'Bi' OR (users.orientation = 'Straight' AND users.gender IN ('#{user.opposite_genders.join('\',\'')}')) OR (users.orientation = 'Gay' AND users.gender IN ('#{user.same_genders.join('\',\'')}')))"

从一个约会网站…


// Replaces with spaces the braces in cases where braces in places cause stasis 
   $str = str_replace(array("\{","\}")," ",$str);

/* Here I sit, Joe broken hearted, came to do some sh*t, but only just started. */

关于一些繁重的正则表达式输入验证。


我在谷歌代码搜索上找到的

    // Constructs a tuple with 2 elements (fucking idiot, use std::pair instead!)
    template <typename T0,typename T1>
    inline tuple <T0,T1> make_tuple (const T0& t0,
            const T1& t1) {
            tuple <T0,T1> t;
            t.get<0>() = t0;
            t.get<1>() = t1;
            return t;
    }

我最喜欢的评论是我的一个同性恋朋友说的。他喜欢用VB标记他所有的TODO注释。净,

'TODO: Matt Damon

有时会提供额外的信息,但通常不是这样。


我的精选集:

// Thats the end of the While loop
// Clean up last row.  I really must program better than this.

// Note: You can't immediately tell if the line below works.

// Rounding - blech.  It's assumed that all .5s are rounded up.

// Sort out predictions first.  Seems like the right place for a prediction, 'first'.

// Let's interpret!

在一些非常蹩脚的vb代码(我知道这都是蹩脚的,但),我发现这是一个空的if控制块中的注释,它说:

If bFound Then
     'I love it when I write kick ass code like this
Else
  .
  .

#ifdef TRACE
#undef TRACE     /* All your trace are belong to us. */
#endif
#define TRACE ....

// Fuck.

,……

// This code worked before, but my cat decided to take a trip across my keyboard...

不记得我在哪里见过这些了

long time; /* know C */

and(在代码中创建某种UNIX守护进程):

/* Be a real daemon: fork myself and kill my parent */

整个函数非常棒(来自Linux的sunhme.c驱动程序,用于被Sun戏称为“快乐套餐”的网卡)。因为在那之前的卡片是“巨无霸”。明白了吗?明白了吗?)

static void happy_meal_tcvr_write(struct happy_meal *hp,
                              void __iomem *tregs, int reg,
                              unsigned short value)
{
    int tries = TCVR_WRITE_TRIES;

    ASD(("happy_meal_tcvr_write: reg=0x%02x value=%04x\n", reg, value));

    /* Welcome to Sun Microsystems, can I take your order please? */
    if (!(hp->happy_flags & HFLAG_FENABLE)) {
            happy_meal_bb_write(hp, tregs, reg, value);
            return;
    }

    /* Would you like fries with that? */
    hme_write32(hp, tregs + TCVR_FRAME,
                (FRAME_WRITE | (hp->paddr << 23) |
                 ((reg & 0xff) << 18) | (value & 0xffff)));
    while (!(hme_read32(hp, tregs + TCVR_FRAME) & 0x10000) && --tries)
            udelay(20);

    /* Anything else? */
    if (!tries)
            printk(KERN_ERR "happy meal: Aieee, transceiver MIF write bolixed\n");

    /* Fifty-two cents is your change, have a nice day. */

}


//我知道这很让人困惑,所以让我解释给你听。


I don't have the code to share, but imagine this scenario. About a month or two after our Linux Sys Admin left for greener pastures, I had the pleasure of opening a shell script he'd written. I can't recall why I needed to edit it, but that's not what matters. What's important is that the script was about 40 lines long. I scrolled past the commenting (of which there were 37 lines) to reach the actual working code (3 lines). The code was great, but I was curious - why 37 lines of commenting? So, I scrolled to the top and proceeded to read. To my surprise, the commenting was a rap about what the three lines of code did and how to change it. The best part - it was a partial rip off of Nothing But A G Thing by Dr. Dre and Snoop D O DOUBLE G. Thanks Brian!


// For the sins I am about to commit, may James Gosling forgive me

/* Jeez, this is an ugly mess */

...comment from the X11R6 internals source code circa 1991.

我在遗留代码中注意到的修改日志

05/17/99 d琼斯评论出来 血腥的auzies代码(02/19/99) k罗宾逊该死的德克萨斯人 不能正确拼写aussie(没有代码 改变-只是一个评论)


/*现在,让所有这些看 半得体的弱智步 哥哥 浏览器家族中的一员,互联网 该死的探险家*/


private int mousycounter = 0; //Not really a counter

http://fxr.watson.org/fxr/source/pci/if_rl.c 是好的来源。


在一个生成HTML的旧perl脚本中找到:

# I would be _very_ brain farting if I said this code didn't need reviewing.
# It will make babies cry, and hair grow on your back, so please don't use it

从/系统/图书馆/框架/ AppKit.framework /版本/ C /头/ NSTextView.h:

- (void)smartInsertForString:(NSString *)pasteString replacingRange:(NSRange)charRangeToReplace beforeString:(NSString **)beforeString afterString:(NSString **)afterString;
- (NSString *)smartInsertBeforeStringForString:(NSString *)pasteString replacingRange:(NSRange)charRangeToReplace;
- (NSString *)smartInsertAfterStringForString:(NSString *)pasteString replacingRange:(NSRange)charRangeToReplace;

/* Java note: The second and third methods are the primitives and are the 
methods exposed in Java.  The first method calls the other two.  All 
Objective-C code calls the first method.  In either Objective-C or Java any 
overriding should be done for the second and third methods, not the first 
method.  This will all work out correctly with the exception of existing code 
that overrides the first method.  Existing subclasses that do this will not 
have their implementations available to Java developers. Isn't Java wonderful? */

//Please comment on your source code

// TODO: not this

上面写了一个同事迫切需要优化的查询。替他说句话,当时我们几个月都是每周工作70个小时……


//Do not continue reading if you dont want to die.

这个差点要了我的命。


/*
    FIXME:  why the fuck did anyone ever think this kind of expensive iteration
                    was a good idea?

// if i ever see this again i'm going to start bringing guns to work

//If only humans could leave things be.

//Please do not edit this code, 
//if you do you wont go to jail, you wont go directly to jail, 
//you wont pass go, you wont collect 200 dollars

来自sendmail配置文件。一页又一页看起来就像线条噪音。我发现了这块宝石。

# insert this handy debugging line wherever you have problems
#R$*                $:$>99$1

int main(void)
/* Program starts here */

当我读到这篇关于我负责维护的项目的文章时,我哭了。

//Write Code Here

我仍然畏缩:)


当我在高中上计算机课的时候,我们在一个普通的教室里上课——没有电脑。我们所有的测试都是在纸上完成的,一张纸上有一节课。我们的老师是第一次用c++授课,偶尔会在黑板上切换到Pascal模式。这很尴尬,因为我们中很少有人对学习帕斯卡感兴趣。

对于比课堂作业更大的作业,我们会在家里做,并提交代码和输出打印结果来评分。在提交了一些代码+输出输出后,我们共同意识到老师实际上并没有阅读代码-只是打印输出。为了测试我们的理论,我在代码的第三页放了一条注释——就在一些类声明之间:

// If you are reading this, please place a checkmark here [  ]

当然,我把它拿回来的时候,前面有一个大大的蓝色“a”,没有任何标记。


一个名为monitoring.sh的文件的前两行:

#!/usr/bin/perl
# perl script disguised as a bash script

// The freshest corpse at the back please.
m_DeadCharacters.push_back( std::make_pair(character, 0.0f) );
// Get rid of the rotting surplus
while( m_DeadCharacters.size() > 3 )
    m_DeadCharacters.pop_front();

//ha, you thought I was lazy didnt ya?!

// this comment included for the benefit of anyone grepping for swearwords: shit.

// BEGIN HACK
...
// END HACK: I feel dirty.

/*
* TODO: Remove this function

function remove($customer_id)
    {
        $this->Customer->remove($id);
    }

*/

/*

 ____________________
/                    \
| Jean-Michel Bechet |
| 2002-2009          |
\___  _______________/
    |/
 (o_
 //\
 V_/_


*/

/*
* 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
*/

从我最近从事的一个非常可爱的项目(是的,我承认,其中一些是我的,但我不会告诉你是哪个):

if(FAILED(hr))
{
    char fuck[256];
    sprintf(fuck, "GetBuffer() fucking fucked the fuck: %d", hr);
    MessageBoxA(0, fuck, fuck, MB_OK | MB_ICONERROR);
    return;
}


// This is for Chris, since he gets all hot and horny over "uint" instead of "unsigned int"
// ... or maybe he's just a lazy fuck. Who knows!?
using Ogre::uint; 
// movable texts, fucktory
MovableObjectTextFactory* m_pMovableObjectTextFactory;


// diarrhea... shitting CR from the string. complete run...

他的意思是,他将字符串通过回车分开来呈现。

// unlock shit (duh, this comment is useless)
pixelBuffer->unlock();


// :HACK: remove me after demo is shipped
Of course, it's still in there ;)


// it's 4am and I can't think of a decent error message.
// my lead just fell asleep at his desk, so I can't ask him.
// [name] went home because he didn't want to get divorced.
// and so it's little ol' me, sitting here, comin up with an
// error message for something that should never ever happen.
ASSERT0(in_len == max_in, "http://www.youtube.com/watch?v=oHg5SJYRHA0"); 


// you want hungarian, you GET hungarian!
for(int fcknglpidxcntvrI = 0; fcknglpidxcntvrI &lt; len; fcknglpidxcntvrI++)


bool bKillSomethingAlive = false; // beating the dead horse instead

当然,我们也有很多有趣的表达“Hack”的方法:

// HACKOMATIC 
// HMM... HACKXOR?
// HACK'O'ROONY
// AR; yeah I know it's HACKsoup
// HACK SHOT! DOMINATING!
// HACK'KIDO
// HACKku. sepukku. harakiri. kamikaze. ninja.
// HACK'o'NEIL
// HACKsaw

#define FUCK_VS6_CANT_COMPILE_TEMPLATES_WITHOUT_HANDHOLDING ((float*)0)

... 

SetPinsFromChannels`<float`>(&pinbuf, streambuf, &inmapper, FUCK_VS6_CANT_COMPILE_TEMPLATES_WITHOUT_HANDHOLDING);

我在我发布的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.
*/

//这将为我们每个用户节省0.5秒,并取悦机器精神。

在很长的程序之前:)


// This part is more difficult

在方法的顶部。

大概有5行。

并不难。

这是唯一的评论。

在整个应用程序中。


从泄露的Win2K源代码:

//这次黑客入侵的规模堪比国家债务的规模。


我个人最喜欢的是打油诗形式的文档:

        Subclassing made Zope and TR
        much harder to work with by far.
            So before you inherit,
            be sure to declare it
        Adapter, not PyObject*

这可能会破坏这个笑话,但由于它有点晦涩,我将解释:

这里的TR指的是“扭曲的现实”。Zope 2和最初的扭曲。Reality包大量而不幸地使用了多重继承,这可能会使您在看到方法调用时难以理解发生了什么。Zope 3,扭曲自己,扭曲。现实的后继者(包括最近的假想)通常更倾向于组件组合。


来自:https://github.com/zepouet/xee - xcode 4.5 - / - blob/master/xeephotoshoploader.m # L108

// At this point, I'd like to take a moment to speak to you about the Adobe PSD
// format. PSD is not a good format. PSD is not even a bad format. Calling it
// such would be an insult to other bad formats, such as PCX or JPEG. No, PSD
// is an abysmal format. Having worked on this code for several weeks now, my
// hate for PSD has grown to a raging fire that burns with the fierce passion
// of a million suns.
//
// If there are two different ways of doing something, PSD will do both, in
// different places. It will then make up three more ways no sane human would
// think of, and do those too. PSD makes inconsistency an art form. Why, for
// instance, did it suddenly decide that *these* particular chunks should be
// aligned to four bytes, and that this alignement should *not* be included in
// the size? Other chunks in other places are either unaligned, or aligned with
// the alignment included in the size. Here, though, it is not included. Either
// one of these three behaviours would be fine. A sane format would pick one.
// PSD, of course, uses all three, and more.
//
// Trying to get data out of a PSD file is like trying to find something in the
// attic of your eccentric old uncle who died in a freak freshwater shark
// attack on his 58th birthday. That last detail may not be important for the
// purposes of the simile, but at this point I am spending a lot of time
// imagining amusing fates for the people responsible for this Rube Goldberg of
// a file format.
//
// Earlier, I tried to get a hold of the latest specs for the PSD file format.
// To do this, I had to apply to them for permission to apply to them to have
// them consider sending me this sacred tome. This would have involved faxing
// them a copy of some document or other, probably signed in blood. I can only
// imagine that they make this process so difficult because they are intensely
// ashamed of having created this abomination. I was naturally not gullible
// enough to go through with this procedure, but if I had done so, I would have
// printed out every single page of the spec, and set them all on fire. Were it
// within my power, I would gather every single copy of those specs, and launch
// them on a spaceship directly into the sun.
//
// PSD is not my favourite file format.

在调试别人的JavaScript时,我看到了下面的评论:

// Notice: I feel so dirty doing this, but it's the only way to make it cross browser.

但在阅读Scott Hanselmen的一篇文章时,我看到了下面的引用,它与我在代码中发现的注释非常吻合:

Every line of code you write that you feel gross about will ultimately come back to haunt you. Therefore, avoid writing code that makes you feel dirty.

这很有趣。


我最近看到了这个:

//你刚刚输了比赛

如果你不知道游戏是什么: http://en.wikipedia.org/wiki/The_Game_ (mind_game) (这很傻,但在某种程度上很有趣)


/**
 * This run through all the guipublisherbuyRecord , the records those have
 * diff. is buytotal and prior to buy isRecommendedBillingClickedWarning flag
 * is set if priously RB ran and this time not.
 * 
 * --What?
 * 
 * @return
 * @throws AppException
 */

写得很好的Lisp是最容易阅读的语言之一,我喜欢它。但是写得不好的Lisp可能是比糟糕的Java更糟糕的噩梦,等等。

在这里,我们需要创建一个“组文件”,如果一个原始文件有3个变体,后缀为a, b和c。我一直试图追踪一个奇怪的错误,我们得到了不必要的组文件……

  (let ((varianta (format nil "~aa" problem))
        (variantb (format nil "~ab" problem))
        (variantc (format nil "~ac" problem)))
    ;;if the A and B variants exist, create a group file
    ;;(why not just check for a? I don't know, this just feels right)
    (when (and (probe-file varianta)
               (probe-file variantb))
      ...)))

Bug: 1, Gut: 0。

显然,写这篇文章的人没有想到,也许检查所有三种变体是一个好主意。当然,这是我在最初编写这段代码十年之后(它比第一个SVN日志更早)最终追踪到的错误。


//我穿上长袍,戴上巫师帽……


从http://www.madore.org/ ~大卫/电脑/ callcc.html:

/* Yow!  DEMONS are flying through my NOSE! */

double penetration; // ouch

我们的DBA在第三方编写的3000行存储过程中发现了这一点。

/* IF DOLPHINS ARE SO SMART, HOW COME THEY LIVE IN IGLOOS? */

//没有评论


我看到一些旧的fortran代码:

     integer *4 one,two,three;

c    asssign one to 100 before entering the loop
     one=100;

// This should fix something that should never happen

// repopulate, slight hax (or strong assumptions :P) below

我的一个老老板总是说我们必须在内部使用我们自己的产品。“吃我们自己的狗粮……”

许多年后,我发现嵌入在一个临时同事所做的源代码中,他触及的每个函数都被标记为:

/* NOT FIT FOR HUMAN CONSUMPTION */

/**
 * As Gregor Samsa awoke one morning from uneasy dreams he found himself
 * transformed in his bed into a gigantic insect. He was lying on his hard,
 * as it were armour plated, back, and if he lifted his head a little he
 * could see his big, brown belly divided into stiff, arched segments, on
 * top of which the bed quilt could hardly keep in position and was about
 * to slide off completely. His numerous legs, which were pitifully thin
 * compared to the rest of his bulk, waved helplessly before his eyes.
 * "What has happened to me?", he thought. It was no dream....
 */
protected static String DEFAULT_TRANSLET_NAME = "GregorSamsa";

catch
{     
    // you’re fucked
    // write out the file somewhere and start screaming “Connection down! Connection down!”
}

//this is a crap way to do this but I ran out of patience

DelButton.click(); 

DataRow[] foundrows = FilterCalendarEntriesBecauseDotNETIsFuckedUp(tbtemp,CalDate);

不是注释,而是一个有趣的函数名


#定义TRUE FALSE //快乐的调试傻瓜


许多年前,我接受了这份工作,为一个真正运行的项目提供支持 在Z80上的时间和组装(有其他方法做Z80吗??) 不管怎样,原作者是一个叫摩西的尼日利亚人。也许我应该 就此止步。 不管怎样,代码中到处都是这样的:

XRA A    ;MT

我花了好长时间才弄明白这是什么。指令本身没有其他作用 比清除蓄能器。这是一种狡猾的方法,尽管我不确定是否有 不管是不是优势。你可以这样做:

LDA 0

但也许

XRA A

节省一个字节之类的。is所做的是排他的或者是累加器本身。 当然,结果总是零。

回到MT -空(明白吗?)

这是我遇到的最好的。


public function get state( /* of Palestine back */ ):Boolean

/**
 * Hexadecimal digit
 */
protected $version = -1;

else
{
    // rien, c'est parfait.
}

我发现了这个

// This is a kind of magic...

我经常发现这个

// fix it!

// TODO: Delete

// *** drunk -- fix later ***

直接的联系

更有趣的谷歌代码搜索…


我曾经在一个用Paradox 3.5 -编写的大型预算系统工作多年后接到一个客户的电话

“我们在调试中遇到了一些注释”-

// This shouldn't happen, if it does, then the bits that automagically 
// worked when I wrote it have stopped working

... !


// for 8 or 12 threads this does not affect much.
// Strange are the situations if not understood properly.
// Yoda strikes again

在多线程模块中!:)


// simply copied from another code

前段时间我看到:

raise InvalidChild() # e.g. no legs

这很奇怪,因为“inwalida”在波兰语中是残疾人的意思。愚蠢的我:)


我在一个充满显式怪异类型转换的函数中见过这段代码:

// Since today's CPUs are really fast, this is dedicated to those who said:
// " You can't use Moore's Law as an excuse to write bad software. "

代码太可怕了:)


'Major changes: Everthing! - Removed all Cornoud's code !

public GetRandomNumber()
{
    // Chosen by a fairly rolen dice
    return 12;
}

发现了一个复杂的代码-

//耶稣和这段代码有一个共同点:都是复活的


// Holy moses! I've never seen anything so ridiculous in all my life. 

// Why do we need to query the AlarmIDs table twice.

// Please tell me sir; I would really like to know. 

// This like all the other services have been mangled

// to the point where they are nearly impossible to determine what kind of side affects might occur.

// I am making the smallest changes I can to this code. 

// The GetAlarmId method gets the alarm id from the AlarmIDs table.

// Novel idea, why didn't we query for the values be get below all in the same place.

// This should be changed, but right now it will have to remain as is due to time constraints.

// This like all other services really don't do anything fantastically hard, but after the original coders got

// done with them; they are difficult to work with and have an acceptable comfort level.

// if the resultMap size is less than or equal to zero
// then the product is added
if (resultMap.size() <= 0)

v.bpc     := v.pc;  -- Remember to jump back
v.baccu   := accu;  -- Yo dawg, heard you like runing instructions
                    -- so I took backup of your accu so you can run
                    -- instructions while you run instructions.
v.flags.i := false; -- No more interupts

Re eating one's own dogfood: We have the same term in our workplace (granted, only because I introduced it). My code is peppered with comments that say "TODO" and indicate something that ought to be done eventually, but a comment saying "DOGFOOD" (both keywords are always at the beginning of the comment, in all caps) means something that must be done before this program can be used even internally. It's a handy thing to search for, as the word "dogfood" is never going to appear in a quoted string - if it does, I can always just say "dog-food" or something - so even a case-insensitive search will come up with the right results.

Regarding zeroing the accumulator: I've done exactly the same thing when programming an Intel 80x86 (I started on the 8086 and moved up from there into the modern Pentiums). XORing a register with itself is the quickest and tightest way to clear it. Using "MOV AX,0" requires three bytes (opcode and two bytes of literal 16-bit zero), whereas "XOR AX,AX" is only two; it's even more noticeable with the 386-and-higher extended registers, where "MOV EAX,0" requires five bytes (four bytes of 32-bit zero). My C/C++ compiler always zeroes registers this way, so I'd assume it's still the best way (although I haven't studied opcode timing tables in ages, and probably both XOR reg,reg and MOV reg,imm take one clock).


#!/usr/bin/sh
#       Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
#         All Rights Reserved

#       THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
#       The copyright notice above does not evidence any
#       actual or intended publication of such source code.

#ident  "@(#)false.sh   1.6     93/01/11 SMI"   /* SVr4.0 1.3   */
exit 255

从SunOS 5.9即Solaris 9获取(/usr/bin/false)


var something TBoolean; //Pickins

// somedev1 -  6/7/02 Adding temporary tracking of Login screen
// somedev2 -  5/22/07 Temporary my ass

%%return_median
hit_the_sweet_spot(Arg)->
.
.

首先,在一个大对象的更新的开始:

/*General note to all who tread in the <ObjectName>() code...
 * The SetOriginals() method from the BaseEntity class should be called (and only called) right after the Get() method
 * call as seen above.  Calling the SetOriginals method elsewhere will result in bugs and all kinds of other nasty suprises.
 */

然后在大约200行逻辑之后更新对象:

//Attempt to explain this confusing mess of code:
//First time you save an actual absence this is what happens:
//0. The first save saves to the <TableName> table (among other things). (Fig. A)
//1. The <CalculationMethod> method is called next which inserts to the <OtherTableName> table. 
//(This is the table that keeps track of credits to the case.) (Fig. B)
//2. So then you have to call <UpdateCalculations> to move the <TableName> records to the <ThirdTableName> table. (Fig. C)
//3. Then you go back and run calculations since you have the debits table (<ThirdTableName>) populated. (Fig D.)
//4. Then a final save to save the calculations back to the case. (Fig. E)
//Yeah, I know what you're thinking:  this sucks. 10/01/07 XXX

开发商是对的……这太糟糕了!


/*
after hours of consulting the tome of google
i have discovered that by the will of unknown forces
without the below line, IE7 believes that 6px = 12px
*/
font-size: 0px;

I was doing a database in Access, very simple thing - at least it was supposed to be at the start or I would have done it in Delphi. The client wanted to be able to get the customer info out of the database but they would not enter enough information to reliably identify the customer. I told them to use the phone number as the key as each customer (the way they worked, not for everyone) would have a different number. After a few frantic calls from them, (It's not working we can't enter the customer) I discovered that they were too lazy to look up the phone numbers from their old system and were trying to enter all the numbers they did not know as "n/a". In trying to sort this out for them I ended up with a lot of checking loops in the code and had the comment beside one outcome "This should never be reached if they do what they are supposed to do!!!!!!!!!"

他们还曾经问过我:“即使我们输入了错误的地址,我们如何才能找到正确的客户?”而这一切都是为了花生。


//Dave chapelle reports errors.
function reporterror() {
  davechapelle.trace("FUCK!");
}

// TODO: Finish.

// All this code is yours, except gedit()...attempt no modifications there.

回顾类中的旧代码很有趣……

    cardDeck.push_back(*(new card((rank)r, (suit)s)));  // Push each card onto the deck
                                                        // Temp. objects are overrated

在经历一些事情的时候,它让我希望我在凌晨4点随机编码的时候留下更多的评论……


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

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

我们只添加了美术内容,而不去管其他内容;另一名开发人员认为,用未来的自己给他发电子邮件(游戏邦注:比如《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


# There is a bug in the next line.  $searchParameters != {} will always return true, because {} is creating
# a new hash reference on the fly, and the inequality operater is comparing the memory location of it
# to the memory location of $searchParameters, and they will always be different. 
# This means that the following code will always get executed as long as $nodes is defined.
# I'm leaving it there because it has always been there, and although I'm sure it was originally meant to
# mean %$searchParameters (essentially "is this hash not empty"), I'm afraid to change it.
if ( $nodes && $searchParameters != {} )
{

//下面的代码需要被注释掉


这张图片来自图片浏览器Xee。

    // At this point, I'd like to take a moment to speak to you about the Adobe PSD format.
    // PSD is not a good format. PSD is not even a bad format. Calling it such would be an
    // insult to other bad formats, such as PCX or JPEG. No, PSD is an abysmal format. Having
    // worked on this code for several weeks now, my hate for PSD has grown to a raging fire
    // that burns with the fierce passion of a million suns.
    // If there are two different ways of doing something, PSD will do both, in different
    // places. It will then make up three more ways no sane human would think of, and do those
    // too. PSD makes inconsistency an art form. Why, for instance, did it suddenly decide
    // that *these* particular chunks should be aligned to four bytes, and that this alignement
    // should *not* be included in the size? Other chunks in other places are either unaligned,
    // or aligned with the alignment included in the size. Here, though, it is not included.
    // Either one of these three behaviours would be fine. A sane format would pick one. PSD,
    // of course, uses all three, and more.
    // Trying to get data out of a PSD file is like trying to find something in the attic of
    // your eccentric old uncle who died in a freak freshwater shark attack on his 58th
    // birthday. That last detail may not be important for the purposes of the simile, but
    // at this point I am spending a lot of time imagining amusing fates for the people
    // responsible for this Rube Goldberg of a file format.
    // Earlier, I tried to get a hold of the latest specs for the PSD file format. To do this,
    // I had to apply to them for permission to apply to them to have them consider sending
    // me this sacred tome. This would have involved faxing them a copy of some document or
    // other, probably signed in blood. I can only imagine that they make this process so
    // difficult because they are intensely ashamed of having created this abomination. I
    // was naturally not gullible enough to go through with this procedure, but if I had done
    // so, I would have printed out every single page of the spec, and set them all on fire.
    // Were it within my power, I would gather every single copy of those specs, and launch
    // them on a spaceship directly into the sun.
    //
    // PSD is not my favourite file format.

在PeopleSoft Financials PeopleCode的早期版本中:

/* I don't know how you can ever get here so I'll have to fix it later */

#如你所见:我注释了代码!


在中间几千行JScript文件后完全任意行…

// The world is a happy place.

long time; /* just seems that way */

  rescue
    # silently, we fail
    # many validations fade
    # like tear drops in rain
  end

这只是众多案例中的一个……


""".........................:~+?7$$$ZZZZZZZ$$$7I+=:,............................
........................~+7ZZZZZOZZOOZOZZOZOZOOZZZZZ7?~:........................
......................,~7$ZZOOOOOZOZOZOZZOOZZOZOOOOOZ$$I,.......................
...................,=I$OOZOZOZZOOOZZOZOOOOZOZZZOOZZZOZZOZI=:....................
.................:?$ZZOOZZOZOZZOOOZZZOOZOZOZZZZZZZOZZOZOOOZ$I~..................
................IZOOOZOOOZZZOZZZZOZZOZOOOOZOZZZOOZZZZOOZOZZZOZ7=................
...............~ZZOZZOZOOZOOZOZOZZOZOZOZZZZZOZOZZOZOOZOZZOOOOZZ7................
.............:IZOOZOZZZZOZOZZOZOOZOZOZOZZOZOOZOOOOZOZZZZZOZOZZOOI~..............
...........,+$ZOOZZOZOZOZOZOZZOZOZOOZZOZZOZZOZOOOOZOZZOZZOOZOOOOO$?:............
..........:IZZOOOZOZZZZOOZOOZOZOZZOZOZZZZOZOOZOZZOZOZOZOOOOOOOZZZOZ7~...........
..........+$OOZZZOZZOOZOOZZZZOZZOZOZZOZOOOZOZOZZOZOZOZOOOOOZ$$77I77$+:..........
........,?$OOZZZZZZZOZOOOZOZZOZZZOOZOZOOOOZOZZZOOZOOZOOO7?~:,.......,...........
........+ZOOZZZZZOZOOZOOZZZZOZZOOOZZZOZOZOOZZOZOZZZOOO$?........................
........$ZOZZZOZZZZOZOOZZZOZOZZOOOOOOOOOOOZOZOZZOZOO$?,.........................
.......:ZOOZOZOZZOOZZOZOZOZOOOZOOOOOOOOOOOOOOOZOZOOZI:..........................
.......+OOOZOOZOZOZOZZZOOZOOZOOO$I+=~:::~+I$OOOOOOZ?:........,:=,...............
......:7ZOOZOZZOOOZOZOZOOZOOZ$I=............:?$OOZ7:.......:IZOOZ?,.............
......=$OZOZOOZOOOOOZOZZOOZ7=,................:?O$+.......~7OOOOOZ+,............
.....,?$OOOOOZZZZOOOOOOZOZ?,....................ZZ=.......=$OOZOOZ+,............
.....:IZOZZ$777I7$ZOOOOOZ7~.....................$Z=.......~7OOOOO7=.............
.....:+?~:,.......,~IZOO7~........~+II?=........?$?,.......:I$ZZ?:..............
.....................+ZO=,......:IOOOOOZ:.......=7$~............................
.....................:IO~.......=OOZOZOO=,......~7O7~...........................
...........:~:.......:IO~.......+OOOOZOO=.......~78Z?,.................,:.......
..........:IZ7~......+ZO~.......:7OOOOO$,.......+$OOZ7=,.............:?$=.......
...........,,.....,=7ZOO+,.......,=II?=:........7OOOOOOZ=:,.....,:=I$ZOO=.......
....................,:+$7=.....................~OOOZZZOOOZZ$$7$$ZOOOOOOZ=.......
......................:?Z?,...................:?OZOOZOOZOOOOOOOOOOZOZOZO=.......
............,::,.......,OO7:................,+$OOZOZOOZOZZOZOZZOOZOZOZOO=.......
...........~$8OI........$OOZI~,.........,:=IZOOZOZOZOZOOOZOZOZOOOZZZOZOO=.......
...........:??=:.......:OOOOOZZ7+=~~==+?$ZOOOOZOOOZOZOZOOZOZOZZOZZOZOZZO=.......
............::,.......,+OOZOOOOO$7777$$ZOOOOOZOZZZZOZOZZZOOZOZZOOOZOOZOO=.......
.....................=7OOZOOZOOZOOOOOOOOOZZZOZOZZOZOZOZOOOZOZOZZOZOOZOOO=.......
................,:=I$OOOZZOOOZOOOOOZOZOZZZZZOOZZZOZOZZZOOZOOZOZOZOZOZOOZ=.......
...........:~+?7ZOOOOOOZZZOZOOZOZOOZOZOZZOZZOZOZZZZOZOZZOZOZOZZOZOOZOOOZ=.......
........$$ZOOOOOOOOZOZOZZZZOZOZOOOZZZOZZZOZOOZOZZZZZZZZOOOZOOZZZOZOOZOOZ=.......
.......~OOZOOZZOOZZZZZZOOZOZOZOZZOOZOOZZZOZZOZOZZOZZZOZOOOOOZOZOZOOZOOOZ=.......
.......~OOZOOZZOZZOZOZZOZZOZOOZOZOOZOZOZZOZOOZOZZOZOZOZOZOOZOZOOOZOOZOZO=.......
.......~OOZZZOZOOOZOZOZZOZOZOZOZOOZOOZOOOOZOZOOZOOOZOOOZOZZOZOZOOZZOOOOZ=.......
.......~OOZZOZOZZZOOZOOZOZOZOZZOZZZZOZZZZOZOZZOOOOZ$ZZZZZZOZZZOZZOZOZZZO=.......
.......~OOZZOO$??$OOZOOZZOOZOZOZ+~IZOOOZOZOOZZOOZI==IZOZZOZOOZOZZOZI~=7O=.......
.......~OOZO$I:..~IZZZOZOZOZOZ$+...=7ZOOZOOZZOZZ=,..,=$ZZOZZZZZOZI~...,?=.......
.......~OOOZI:....:IZOOOZZOOO$+:....~7ZOZOZOZOZ$,....,=$OOZOOOZOI~.....:~.......
.......~OZI~........~IZZZOZ$?:........=IOOZZZ$+,.......,$ZOOOZZ7................
.......=7~............~IOZI:............7ZO$+:..........,=7ZZ7=,................
.......,,...............=~...............~=:..............,~=...................
                                                               GlassGiant.com""" 
print "Hello World!"

//Maybe you should make anyone knows your code's purpose. 

我最喜欢的是已故的Paul DiLascia:

//作者:如果这段代码工作,它是由Paul DiLascia写的。如果不是,我就不知道是谁写的了。


/**
 * Happy Javadoc haiku:
 *
 * Without Javadoc
 * Builds break in Maven site stage
 * This fixes the build.
 */

在VB中使用分号。网

TextBox2.Visible = True';
For Each row In data.Tables(0).Rows
    If row("Customers.Id").ToString <> customerId Then
        customerId = row("Customers.ID").ToString';
        name = "Customer Name: " & row("Name").ToString & CrLf';
        address = "Address: " & row("Address").ToString & CrLf & CrLf';
        TextBox2.Text += name & address ';s
    End If';
Next';

//todo: never to be implemented

我们的团队,就在今晚,发布了一个新版本的CSS文件,删除了一个文件的注释,该文件的结构是这样的:

@charset "UTF-8";
/* Who knew comments here could COMPLETELY ruin our page in Safari? */
body {
        /* Really important stuff here */
        /* Of course, comment or not, this will all get ignored by Safari because 
           its the first rule after the comments which break everything.
           see http://www.w3.org/International/questions/qa-css-charset for the exact details!
        */
}

有趣的是,在网上你会发现人们的解决方案是输入一个虚假的元素作为字符集语句下面的第一条规则,然后被忽略,照常进行…

发人深省的问题:该把不评论的评论放在哪里?

旁注:我知道这是不需要的,因为头,元规则等。不幸的是,我们需要它作为一个catch all:(


    #Christmas tree initializer  
    toConnect = []  
    toRead =   [  ]  
    toWrite = [    ]   
    primes = [      ]  
    responses = {}  
    remaining = {}  

// some sport psychology
if (!focused)
    Focus();

这是显而易见的?

/** Logger */
private Logger logger = Logger.getLogger();

// now that's compact!
list->insert(list->end(),**pitch)->IdxOfSample=(pitch->pos-Offset)*SamplingRate;

在一个巨大的800行'switch'语句中,在中间的某处:

// Joe is sorry

几百行之后……

// Harry is sorry too

[vrk:Cloud ID="cTags" runat="server" DataTextField="Tag" DataWeightField="Total"
    Width="100%" DataHrefField="Tag" DataHrefFormatString="~/tags.aspx?tag={0}"]
[/vrk:Cloud]

[!--if anybody would like to change the control's color contact with FLORJON--]

从Python / ceval.c:

/* This is gonna seem *real weird*, but if you put some other code between
   PyEval_EvalFrame() and PyEval_EvalCodeEx() you will need to adjust
   the test in the if statements in Misc/gdbinit (pystack and pystackv). */

'Mind boggling, gibberish version of a SQL statement, but it work's, so dont touch it

//BELOW IS THE REAL CODE...JABRONI
        //
        // Yeah, but can you play the outtro to Bark At The Moon?
        //

        //|--------------------------------------------------|------------------------------------------------|
        //|--------------------------------------------------|------------------------------------------------|
        //|--17^16-16-16-17^16-17^16-16-16-17^16-17^16----16-|-19^16----16-19^16-19^16---16-19^16-19^16----17-|
        //|--------------------------------------------19----|-------17----------------17---------------17----|
        //|--------------------------------------------------|----------------------------------------------

这个注释位于一个包含接口的单元中,这些接口用于绑定主应用程序和各种第三方驱动程序之间的通信。

//**************************************
// Dear code maintainer:
//
// This source contains COM interfaces, not to be confused with interfaces 
// of any other sort, please do not just willy-nilly add additional methods 
// to these interfaces as they are truely immutable, unlike the interfaces 
// that other software vendors like Microsoft maintain.  IF you need to add 
// new functionality, then go thru the trouble of creating a NEW interface 
// and implement this functionality on only the objects you need.  
//
// While the money is good for fixing all of the problems caused by not 
// following the rules, I would rather work on things which actually have
// an impact on the future of the product rather than curse and yell 
// obsenities at the screen because someone didn't bother to understand the
// true meaning of IMMUTABLE.  
//**************************************

/*这是一个可怕的黑客攻击的副本——很多年前,遗留的PortfolioServer被修改为在“optionTrade”块中返回现金交易,因为客户端开发人员太懒了,没有正确地获取他们的xpath。他们的懒惰一直在回响,这意味着我们在这里需要一个类似的黑客……*/


//uncomment the following line if the program manager changes her mind again this week

public static final void attachListener(Object listener) {

/* ======================= */

// This does nothing, continue searching

/* ======================= */

...

与听众一起痛苦!


早在80年代早期,我在汇编器中看到了这个(引用于模糊的记忆):

I don't understand how the following bit works, but it worked in the program I stole it from.

Control + A,重写

这是在以前的项目中作为签入注释添加到源代码控制中的注释。


比起评论,我真的更喜欢oh_my_god标签…

    /*
     * IOC3 is fucked fucked beyond believe ...  Don't even give the
     * generic PCI code a chance to look at it for real ...
     */
    if (cf == (PCI_VENDOR_ID_SGI | (PCI_DEVICE_ID_SGI_IOC3 b_type0_cfg_dev[slot].f[fn].c[where ^ (4 - size)];

    if (size == 1)
        res = get_dbe(*value, (u8 *) addr);
    else if (size == 2)
        res = get_dbe(*value, (u16 *) addr);
    else
        res = get_dbe(*value, (u32 *) addr);

    return res ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;

oh_my_gawd:

    /*
     * IOC3 is fucked fucked beyond believe ...  Don't even give the
     * generic PCI code a chance to look at the wrong register.
     */
    if ((where >= 0x14 && where = 0x48)) {
        *value = 0;
        return PCIBIOS_SUCCESSFUL;
    }

//Time log says you've been here for 15 hours GO HOME, your code is hobo

/* Only break the connection if it actually exists. It is important to
 * check the timeslot saved in the SOURCE of the disconnect message. */

我写了这条评论,现在我不记得为什么它很重要了…


'I hate nested regions and will delete them along with any code found in them.

这是我们在大学宿舍使用的自定义DHCP服务器,根据它们是否注册/安装补丁和防病毒,将计算机放入“干净”或“脏”IP地址池:

public boolean getDirty (String MAC) // not as fun as it sounds

Tweet tweet = (Tweet) tweets.get(i); // Poetic.

下面的代码是在Python模拟教程中看到的。

# This is my rifle.
def rifle(type='hunting'):
    print('This is my (%s) rifle.' % type)

# This is my gun.
def gun(type='hand'):
    print('This is my (%s) gun.' % type)

# This is for fighting.
def fighting(type='illegal'):
    print('This is for (%s) fighting.' % type)

# This is for fun.
def fun(type='gaming'):
    print('This is for (%s) fun.' % type)

作者一定是《恶搞之家》的粉丝。^ _ ^


// TODO: what the hell is this all about?

然后一些代码被注释掉了。

这是在今天早些时候的工作代码中发现的。我不知道我该笑还是该哭……


我们有一个小组项目,使用最小-最大树创建一个Connect 4 AI。在我们的move-scoring函数中,我们让它为棋盘计算分数,在这段代码之上有这样的注释:

// This is kind of almost useless

但还有更好的。我们的导师给了我们一些他制作的粗糙AI的示例代码,并留下了很好的评论:

// We also add/subtract some points based on what's going on, on the bottom
// row. (I think this is retarded, but apparently when I coded this up 
// back in 1999 I didn't.)

我刚刚完成了一个日志框架(使用Trace,为什么没有这样的存在我不知道)。我做了一个继承自TraceListener的方便基类。它覆盖了所有的TraceListener方法,并将它们路由到一个方法中——因此有很多文档注释:

// TODO: Need some codemonkey to doc comment this class.

在我们的应用程序中第一次重新编译FreeTextBox3,因为我们需要IE8支持…看看我发现了什么

// IE7 update. this is still bad code, but IE8 is probably a long way off :)

好吧,这是我刚刚提到的一个问题:

/* Every time I re-visit this function, I feel like
 * I need to take a shower.
 *
 * Don't get too used to this function, its days are
 * numbered.
 */

有人可以创建像greatcodecomments.com这样的网站,然后赚点钱。然而,那个人不是我。


// need a coffee to fix this.

在一堆糟糕的剪切和粘贴源代码的内容管理web应用程序:

// load image 1 - JPEG 240x320
img = f1.getImage();
if (check(img))
{
   load(img, Constants.JPEG_240x320);
}

// load image 2 - JPEG 128x128
img = f2.getImage();
if (check(img))
{
   load(img, Constants.JPEG_128x128);
}

...

// load image 13 - GIF 256x256
img = f13.getImage();
if (check(img))
{
   load(img, Constants.GIF256x256);
}

// loaded all of the f**king images

注:大致翻译自意大利语:-)


//I'm sorry, but our princess is in another castle.

//too much log will kill you

这个评论是我自己写的,当降低一些日志的优先级时,否则会写数百MB的垃圾,严重削弱应用程序的性能。


在makefile中找到这个

# ===== Never edit below this line. Ever. Or I'll kick your ass. ====

//
//3.4  JeK  My manager promised me a lap dance if I can fix this release
//3.5  JeK  Still waiting for that dance from my manager
//3.6  JeK  My manager got changed, the new manager is hairy, dont want the dance anymore
//3.7  Jek  Got that dance, yuck!
//

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

来自嵌入式系统中的电池监测模块:

// batmon.c drives the rastamobile

从技术上讲,这不是一个评论,而是在凌晨2点左右编写的代码:

consent = False

... 该变量永远不会再次使用,并且出现在套接字的监听循环的开始。


// The following array may contain either TexturedObjects or ColoredObjects.
// I know, it sucks.

// Singleton object. Leave $me alone.
private static $me;

我最喜欢的是这样的

 # commented out
 ...
 ### end of the formerly uncommented #2001-02-22 John Doe

// no comments for you
// it was hard to write
// so it should be hard to read

// woot, global var. I havent done this for a long time.

// *** AAAAAHAHAHAH!!  What is this??


$you = live("free") or die("hard");


# dont question, i just felt like throwing some globals in
# this is actually quite pointless as youll soon see

稍后在代码中

#draw the circles (complicated)...dont question

更晚…

# complicated process of drawing the circles in a
# somewhat symmetrical, 3-d pattern
# dont question again

甚至以后……

# will determine if user clicks on die
# i determined these values...dont worry about them

TextBox1.Text = TextBox1.Text; //Point less yes, who writes this crap?

public boolean isDirty() {
    //Why do you always go out and
    return dirty;
}

在编写MAPPER应用程序时,我们有一些标准,其中之一就是在整个套件中使用的标准变量列表。其中一个“V43”总是用来表示姓氏。所以,想象一下,当我被要求修复一大块MAPPER代码中唯一的注释是:

Here V43 contains the Surname