您遇到的源代码中最好的评论是什么?

What is the best comment in source code you have ever encountered?

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


我是这个特别是有罪的,嵌入的非建设性的评论,代码为最小诗和笑话我的项目(通常是足够的,虽然我没有任何直接的进攻意识到删除之前释放的代码)。这是一个我喜欢的particulary,放远不远,唐氏的"上帝":设计对象

1
2
3
4
5
6
7
8
/**
* 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.
*/

我很抱歉!!!!!!!!!!!!!!!!!!!!!!我也不能帮助自己……!

和另一个,这我承认我以前发布的T真的走进荒野I AM tempted,虽然这样做在一个非常直观的类:无

1
2
3
4
5
6
7
8
9
10
//
// 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
//


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

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

1
stop(); // Hammertime!


这似乎阻止了白痴破坏我的密码…

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

24


1
2
3
// 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.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//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;
        }
    }
}

更新:《原创作者的代码有outed himself所以务必给信用在它是正当的。但麦金利离开公司后我与shortly开始,和更多的关于他万能码,诠释了一些背景和一些更多的"跆拳道"这wrote理查德。 </P >


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

1
// drunk, fix later

真希望我开玩笑。我知道编写代码的开发人员,我认为他是字面意思。


1
// Magic. Do not touch.



#define TRUE FALSE
//Happy debugging suckers


1
// I'm sorry.


1
return 1; # returns 1


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

后面是四个嵌套for循环


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


当被问及"最佳评论"时,我们都会以最糟糕的评论来回答这个问题。


1
long john; // silver


1
2
3
Catch (Exception e) {
 //who cares?
}


1
2
3
4
5
6
/**
 * Always returns true.
 */
public boolean isAvailable() {
    return false;
}

不依赖于的评论……


1
2
3
4
5
6
7
8
/*
 * 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.
 */

1
2
3
4
5
try {

} finally { // should never happen

}

发件人:https://github.com/zepouet/xee-xcode-4.5/blob/master/xeephotoshopoloader.m l108

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// 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.

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


1
2
3
4
5
6
7
    #Christmas tree initializer  
    toConnect = []  
    toRead =   [  ]  
    toWrite = [    ]  
    primes = [      ]  
    responses = {}  
    remaining = {}


大约在一个30页的XSLT中间

1
<!-- Here be dragons  -->


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


在一个完全没有任何评论2000线法 </P >

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
  {
    while (.. ){
      if (..){
          }
      for (.. ){
          }
         .... (just putting in the control flow here, imagine another few hundred ifs)
      if(..)   {
            if(..)     {
                   if(..)   {
                ...
                (another few hundred brackets)
                       }
                  }
         } //endif

(实际上所有的brackets grepped敲一天刚到,看它是怎么叫,鸭,SANS Formatting,有这样的: </P >

1
{{{{}}{}{}{}{}}{{}{{}{}{}{}{}{}{{}{}}{}{}{{}{}{}{}{}{}{}{}{}{}{}{{}}}{{}{{}}{{{}}}{{}{}{}{}{}{}{}{{}}{}{{{}}{}{{}{}}{{{}}{}{}{}{}}{{}}}{}{{}{}{}{{}{{}}{}}{{}}}{{}}{{}}{{}}{}{{}}{{}}{{}}{{}{}{}}{}{}{{{}}{{}}}{}{}{}{}}{{{}{{}{}{}{{}{}{}{}{}{}}{}}{{}}{{}{}}}{{}}{{}}}{{}}{{}}{}{}{}{}{{}}{{}{}{}{}}}}{}{}}{{}{{{}{}{}{}}}}{{}{{{}}}}{{}{{{}{{}}{}{{}}{}{{}{}}{{}}{}{{}}}{{}}}}{{}{}{}{}{}{{{}    {{{{}}{}{}{}{}}{{}{{}{}{}{}{}{}{{}{}}{}{}{{}{}{}{}{}{}{}{}{}{}{}{{}}}{{}{{}}{{{}}}{{}{}{}{}{}{}{}{{}}{}{{{}}{}{{}{}}{{{}}{}{}{}{}}{{}}}{}{{}{}{}{{}{{}}{}}{{}}}{{}}{{}}{{}}{}{{}}{{}}{{}}{{}{}{}}{}{}{{{}}{{}}}{}{}{}{}}{{{}{{}{}{}{{}{}{}{}{}{}}{}}{{}}{{}{}}}{{}}{{}}}{{}}{{}}{}{}{}{}{{}}{{}{}{}{}}}}{}{}}{{}{{{}{}{}{}}}}{{}{{{}}}}{{}{{{}{{}}{}{{}}{}{{}{}}{{}}{}{{}}}{{}}}}{{}{}{}{}{}{{{}{}{{}}{}}}{}}{{}}{{}{}}{{}{{}{{}}}}{{{}{{{}}}}}{{{{{}}}}}{}{}{}{{{{}}}{}{}}{{}{{}}}}{}{{}}{}}}{}}{{}}{{}{}}{{}{{}{{}}}}{{{}{{{}}}}}{{{{{}}}}}{}{}{}{{{{}}}{}{}}{{}{{}}}}

"endif上表现出方位线800) </P >


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


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


1
double penetration; // ouch

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


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

x = -x;

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


其中最经典的是皮埃尔·德·费马对他著名的"最后定理"所作的评论:"这一页的页边太小,写不下证明。"

在找到证据之前花了350多年时间…

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

Cubum autem in duos cubos, aut
quadratoquadratum in duos
quadratoquadratos, et generaliter
nullam in infinitum ultra quadratum
potestatem in duos eiusdem nominis fas
est dividere cuius rei demonstrationem
mirabilem sane detexi. Hanc marginis
exiguitas non caperet.

…并翻译成英文:

(It is impossible to separate a cube
into two cubes, or a fourth power into
two fourth powers, or in general, any
power higher than the second into two
like powers. I have discovered a truly
marvellous proof of this, which this
margin is too narrow to contain.)


从Java 1.2 SWIVITULTION:

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


1
# To understand recursion, see the bottom of this file

在文件底部:

1
# To understand recursion, see the top of this file

这是一个活生生的证据,在生产代码中,我们团队的微观管理效果:

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

…其次是不太理想的代码,这是由我们敬爱的技术总监构想的,他非常喜欢将代码和编码指导原则强加于开发人员的喉咙中(*)。

当然,当项目负责人搜索一个bug的原因,发现它在"不太理想的代码"中时,他并不觉得好笑…

当然,我提到了强大的vb国王…如果你想评估强大的vb国王的全部力量,你可以阅读以下文章:你被迫遵循的最奇怪的编码标准规则是什么?…


我经历了一次睡眠不足的编码过程,开始只写一些来自搏击俱乐部的评论。

几年后,我还在翻阅代码,发现了一条让我发笑的评论。他们中的大多数只是随机的想法。不过,我还是保持了我的评论与行的比例非常好!

1
2
3
4
5
// This shouldn't happen. The only way this can happen is if the
// <wyn>JFileChooser</wyn> has returned a <wyn>File</wyn> 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.
1
2
3
4
5
6
7
8
9
10
 /**
   * 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() {


许多年前(约1994)是工作在一个Oracle的PRO*C应用一个多民族的大软件公司,你将听到一些大学。该应用程序是在大量的工作是(一)Oracle应用和他们的有A型是抢劫,隔夜tidying DPS数据和做所有的大学calculations聚集体。每一次做的任何事情都是必要的作为一个批量作业,它有shoved变成这样的功能,作为你可以想象它became绝对monstrosity西安。这是notable也为小的数,这是因为它有这样一个庞大的计划。 </P >

一个确实的,它是有remains上最好的孩子的评论中看到有过对跆拳道的纯粹性。我想找到一个错误-这是一个功能hundreds线长和右部的中间部是《只评论的功能: </P >

1
/* I did this the other way */

至今日仍然在网络上最好的孩子有过评论中看到。 </P >


1
/* Please work */


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

我今天才找到这个:

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

1
/* You are not meant to understand this */


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

这是在一部法典,是集technically没有固定的问题,但它是意味着打破了3对其他事情……………… </P >


1
2
3
// no comments for you
// it was hard to write
// so it should be hard to read


1
/* Halley's comment */


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

1
// I have to find a better job


我们的DBA在第三方编写的3000行存储过程中间发现了这个问题。

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

在线的JS代码:

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/* 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参考指南中的声音功能)


…或死/婊子


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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* 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. */

我个人最喜欢的

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


在线研究:初始化链表

1
last = first; /* Biblical reference */

succint和hilarious。


有人抱怨说"最好"的评论会带来最坏的评论。imho,他们更有趣,所以"更好",但这里是我读过的最真诚的评论:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
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).
*/

1
2
3
if(m_measures =/*=*/ --index)
{
    ....


1
2
3
4
5
6
7
8
9
10
11
12
13
14
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++评论


1
2
3
4
5
6
/*
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

1
  mov si, pCard      ; captain?


1
2
3
4
5
6
7
8
9
10
// 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 */
}


从2004年的Windows泄漏中,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
__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);
}


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

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

退出但不使用goto语句标号

1
ICantBelieveImUsingAGoto:


我看到有人这样评论:"S码

1
// This comment is self explanatory.

我想他说的意思是"变"的错误一但有趣的评论……在智囊团的循环逻辑,写作和futility)它。


1
2
3
4
class Act //That's me!!!
{

}


1
2
3
4
5
6
7
8
9
10
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!!!
}

下一个到一个局部变量,不得不请申报护照刚刚到一定到一个库函数: </P >

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


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


1
2
3
4
public boolean isDirty() {
    //Why do you always go out and
    return dirty;
}

1
2
3
4
 * ...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...


从第三次地震的震源中,我偶然在Slashdot随机发布的帖子中发现了这一点。文件的完整来源可以在这里找到。这是一种计算平方反比的特别快速的方法。关于最好的评论?可以肯定,这是一个常见的问题,但考虑到它是连接到行,做魔术是什么使它伟大。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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;
}


最初的厄运有一个引擎,静止的墙壁不能移动;结果是所有的门都垂直打开;任何东西都不能水平移动。当源代码被释放后,我突然大笑起来,当时我正在查看代码,在处理门的源文件中看到了这个,在一大块注释掉的代码的开头:

1
2
3
4
5
6
7
8
// 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)
//


1
2
3
4
// 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 removed"。


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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  .__  _.-\   \
  ##         | |  |  ``/  /`  /
  ##        /,_|  |   /,_/   /
  ##           /,_/      '`-'
  ##

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

1
// TODO: Fix this.  Fix what?

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

当我读到那篇文章的时候,我还是有点咯咯笑…


1
2
3
Repeat
    ...
Until (JesusChristsReturn) ' Not sure


离开上一份工作后,我在源代码中嵌入了一些ASCII艺术…

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
                                      ,_-=(!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
MN%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`                
                                       '''''


1
2
3
4
5
6
/*
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;

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

1
long time; /* know C */

和(在创建某种Unix守护进程的代码中):

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


在顶部的一头文件: </P >

1
2
3
4
5
6
7
8
9
/* 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.
 */

"某某项目"(name变)是一ordeal七年。这是货物的书面评论是由一stalwart灵魂的人是非常involved从开始到结束的通。 </P >


1
// Catching exceptions is for communists

来自迈克·邓肯在sqlite上的页面。


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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* 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
");

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


1
2
3
4
5
6
//
//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!
//

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
    /* 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.
   */


我在一个php cms上添加了一条评论,这是我之前正在研究的。

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


有一次我在另一个讨论中看到这样的事情:

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

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


一个典型的例子说明了为什么你不应该进行软件开发:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
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; }
    }
}


1
2
// 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.

在大学的一次家庭作业中,一位教师特别坚持要对我们的代码进行评论:

1
//I wonder if she actually reads these.

当作业被退回时,用红笔在评论"是的,我愿意"。


泄露的Windows 2000源代码:

!!!!!!!IF YOU CHANGE TABS TO SPACES, YOU WILL BE KILLED!!!!!!! *
!!!!!!!!!!!!!!DOING SO FUCKS THE BUILD
PROCESS!!!!!!!!!!!!!!!! *
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

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


1
2
3
4
// 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

我一直很喜欢保罗·迪拉斯基在他的文件头上写的:

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


1
// human madable inconvenient. Way too sucks.

我仍然不完全理解它的含义,但是我发现它对于很多代码都是非常正确的。


从嵌入式系统中的电池监视器模块:

1
// batmon.c drives the rastamobile


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

未定义其他错误代码。


从泄露的win2k源代码:


// The magnitude of this hack compares favorably with that of the national debt.


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

注意以上代码中的错误;我只是证明了它是正确的,没有试过。


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


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


1
2
3
4
5
//There can Only Be one HIGHLAN....err..Singleton
public class SomeSingleton
{
...
}


// I put on my robe and wizard hat...


1
2
3
4
// 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.

在Linux 1.0内核调度程序(sched.c)上:

Dijkstra probably hates me.

1
2
3
4
5
6
7
8
9
10
11
12
13
/*
 *  '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)

(…)


1
//uncomment the following line if the program manager changes her mind again this week


1
//Abandon all hope ye who enter beyond this point


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

对于那些出于某种特殊原因而不知道民进党的人来说,当你全神贯注于学习新事物时,你大脑中的那部分就会亮起来。


1
using namespace std;            // So sue me


1
//I'm sorry, but our princess is in another castle.


SQLite源文件顶部:

1
2
3
4
5
6
7
8
9
10
/*

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

*/


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


1
//ALL YOUR BASE ARE BELONG TO US

我认为我的老板...it白手起家的人有hacked。他不知道的笑话。 </P >


大约10年前,我在图像处理,扫描显微镜视频帧,以检测细胞运动。我在一个特殊的复杂的功能工作,决定出去和朋友喝一杯。当我回到家的时候,我工作了一点,但不是太多,因为我喝醉了。第二天早上,我发现一个10行的函数完全混乱了,下面的评论(显然是我的另一个人写的):

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

最奇怪的是它甚至起作用了。


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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* 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.
*/

//You are not expected to understand this </P >

经典。 </P >


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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*@                                    /\  /\
 * @                                  /  \/  \                        ----- |   | ----      |---\ |    | /--\  --- |   |  ---- /--\ /--\
 *  @                                /        --                        |   |   | |         |   / |    | |      |  |\  |  |    |    |
 *   \---\                          /           \                       |   |---| ----      |--/  |    |  \     |  | \ |  ----  \    \
 *    |   \------------------------/       /-\    \                     |   |   | |         |  \  |    |   -\   |  |  \|  |      -\   -\
 *    |                                    \-/     \                    |   |   | ----      |---/  \--/  \--/  --- |   \  ---- \--/ \--/
 *     \                                             ------O
 *      \                                                 /                 --- |   | ----  /--\        |--\   /--\   /--\
 *       |    |                    |    |                /                   |  |\  | |    |    |       |   | |    | |
 *       |    |                    |    |-----    -------                    |  | \ | ---- |    |       |   | |    | | /-\
 *       |    |\                  /|    |     \  WWWWWW/                     |  |  \| |    |    |       |   | |    | |    |
 *       |    | \                / |    |      \-------                     --- |   \ |     \--/        |--/   \--/   \--/
 *       |    |  \--------------/  |    |
 *      /     |                   /     |
 *      \      \                  \      \
 *       \-----/                   \-----/
 */

简单但有效的评论,before a小于安全缺口在一些C + +代码 </P >

1
// yikes


我在这一个上更多的超过一个occasion,当有做某种非明显简化到一个数学公式,我不觉得自己像documenting: </P >

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


在一个巨大的800行"switch"语句中,在中间的某个位置:

1
// Joe is sorry

几百行之后…

1
// Harry is sorry too

.class {border:1px solid gold;} /* I pitty the fool */


1
// Caveat implementor

从Netscape Web浏览器的Unix风格源代码中,大约1997年:

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

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


这是我曾经必须支持的实际代码。在努力理解AstaSaysgoogo和AstaSaysgaagaa的逻辑之后(在那里更多的AstaTempvars被声明和使用),我准备放弃。我终于抬头看了看"@作者"的评论,整个事情开始变得有意义了。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*

* @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...";
    }
}

我改变了作者的真实姓名,以避免我卷入任何争议等。


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


1
'NO COMMENT

1
long time; /* just seems that way */


1
2
3
4
aComment = 'this is not aComment' # this is aComment
class T(object):
    def f(this):
        this is not aComment


这个注释位于一个包含接口的单元中,用于绑定主应用程序和各种第三方驱动程序之间的通信。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//**************************************
// 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.  
//**************************************

1
-- Comment this later

这是一个在线4000 + 2线PL / SQL调用。和只读的评论。4年后,程序被开发的,不允许冲来。 </P >


有一次,我想到了一个特别棘手的问题的优雅解决方案,回想起来,它有点让人头脑发热,而且大量使用了宏程序。几年后,我从一个维护程序员那里找到了这个评论。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
    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.

*/

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

1
// and there is where the dragon lives

接下来是一个功能,4个人花了一天时间来理解它在做什么。最后我们意识到它甚至不用,什么也不做。


保护的罪恶值已改变

这是通过一个落后的承包商谁已经工作在一块的邮件登录负责测试代码。我们只是想为我们disbelief在它和它是有效的登录到他的个人帐户;我们的历史和检查双合有两次检查,编辑它的代码添加到一个与第二,在评论它。

我们由独立的艺术品和左休息;它的另一个有趣的发展将决定他未来的邮件发送从他的自我(办公室和病房)说了两周的几乎全是在日常的电子邮件登录停止工作。

1
2
3
4
5
6
7
8
9
10
11
12
'    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 ="[email protected]"
'Private TEST_Password As String ="Humsal892"
'Private TEST_Server As String ="imap.secureserver.net"

我最喜欢的部分,因为它是不是他是他离开它,或是accidently现场签到——但那是他当他回来就在凸轮commented它,而不是它的代码。我们将永远不会有原来的版本,如果我们看着不知道它在那里:D


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

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


我经常看到这个:

1
// TODO make this work

说明显的?

1
2
/** Logger */
private Logger logger = Logger.getLogger();

1
2
3
<wyn>
$you = live("free") or die("hard");
</wyn>


从谷歌代码项目:

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

几年前写Perl时,我在顶部和底部添加了以下注释:

1
2
3
4
5
# <magic type="voodoo">

...

# </magic>

下一个看它的人对Perl并不感兴趣,他花了一段时间在文档中搜索"magic"和"voodoo"做了什么。从那以后,我尝试添加更多有用的评论…


1
2
3
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('\',\'')}')))"

从约会网站…


1
2
3
4
5
6
7
8
9
//        .==.        .==.          
//       //`^\\      //^`\\        
//      // ^ ^\(\__/)/^ ^^\\        
//     //^ ^^ ^/6  6\ ^^ ^ \\      
//    //^ ^^ ^/( .. )\^ ^ ^ \\      
//   // ^^ ^/\| v""v |/\^ ^ ^\\    
//  // ^^/\/ /  `~~`  \ \/\^ ^\\    
//  -----------------------------
/// HERE BE DRAGONS

我无法访问原始文件,因为我不再在那里工作,但它与此图片非常相似。这是在一个文件的顶部总是造成麻烦,我们不得不修复,但不允许花时间真正修复。(大学政治学)


1
2
3
4
5
6
7
8
//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.

问:"在源代码中,您遇到过最好的注释是什么?"

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

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


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//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


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

在Joomla模块中找到。


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/// <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
}


1
2
3
4
5
6
//Woulda
if(x) {}
//Shoulda
else if(y) {}
//Coulda
else {}


不知道是有趣还是悲伤……但我和一个实习生一起工作时,有一块宝石可以计算出每单位的价格。

1
2
3
4
5
6
7
8
9
10
11
12
...

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

...


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

生产源代码:

1
// Remove this if you wanna be fired


我的一位老老板一直在讲我们如何在内部使用自己的产品,即"吃自己的狗食……"

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

1
/* NOT FIT FOR HUMAN CONSUMPTION */

1
2
3
4
5
6
7
//open lid


//take sh!t


//close lid

文件打开、数据转储、文件关闭的注释…


1
2
3
4
5
public GetRandomNumber()
{
    // Chosen by a fairly rolen dice
    return 12;
}

很久以前我遇到过这个:

1
2
3
4
5
6
7
/***************************************************************************/
/*  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.                             */
/*                                                                         */
/* ...                                                                     */

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


经典ASP:

1
2
3
4
5
'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))


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


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

啊,我一直爱着那个…


几小时前,在是在:

1
raise InvalidChild() # e.g. no legs

这是部分> < grotesque由于"inwalida"在波兰,均值与残疾的人。/部分> <我傻了:)


最好的一个,所以父亲: </P >

1
"This code makes baby Jesus very sad!".

这是个refering字符串iniciatilization呢: </P >

1
2
3
4
String blankSpaces="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+ //100 whitespaces
                  "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+ //200 Whitespaces
                   ...
                  "                                       " //100 whitespaces

好的,你的想法的山羊。 </P >


诚实的神:

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

我告诉心理医生至少要做一些异常处理。这就是我在每次DB呼叫中得到的回报……

1
2
3
Catch (Exception e) {
    //eat it
}

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

1
stepOff(); //bitch

我最喜欢的评论是:

1
2
3
4
5
6
//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。


当我为路透社工作的时候,我们的一个饲料处理工人的评论让一些人认为全能者在帮助我们……

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

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


我最喜欢的是已故伟大的保罗·迪亚斯西亚:

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


1
// This should fix something that should never happen

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

1
2
3
4
5
6
7
/* 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. */


// Houston, we have a problem


1
//  Hey, your shoe's untied!

通过dubious进入一些代码,这样的代码内。

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

最后,

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


All bugs added by David S. Miller


/*And now, getting all of that to look
half decent in the retarded step
brother
of the browser family, Internet
Fucking Explorer */


1
2
3
// some sport psychology
if (!focused)
    Focus();

1
2
3
4
5
6
7
8
# 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 != {} )
{

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

05/17/99 D JONES COMMENT OUT THE
BLOODY AUZIES CODE (02/19/99)

05/17/99 K ROBINSON BLOODY TEXAN
CAN'T SPELL AUSSIE CORRECTLY (NO CODE
CHANGE - JUST A COMMENT)


早在80年代初,我在汇编程序中就遇到了这个问题(引用了昏暗的记忆):

1
I don't understand how the following bit works, but it worked in the program I stole it from.


1
// This is a walkaround for bug #7812

作者是我们的一位中国程序员,他的母语不是英语。

我真的很喜欢这个。我恰好认为"变通"这个词比"变通"好得多。


1
//todo: never to be implemented

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


在vb.net中使用分号

1
2
3
4
5
6
7
8
9
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';


从Apache Xalan的源代码:

1
2
3
4
5
6
7
8
9
10
11
/**
 * 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";

进一步的阅读在线每日WTF。


一些源代码中的德语注释,由机器翻译或非常疲倦的human+google

1
; Rechnen ja ; have faith in yes

我猜原来的意思是"假设这里是真的"…但自从我把它当作我一生的座右铭。


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


1
2
3
4
5
6
7
8
9
10
//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----|
        //|--------------------------------------------------|----------------------------------------------


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

在Facebook API的某个地方。


一些来自Linux内核:

1
2
3
4
/* 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.
*/

-

24

-

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

1
Tweet tweet = (Tweet) tweets.get(i); // Poetic.

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

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

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


我在python 2.5的包"twisted"中找到了这个(文件在第371行是tcp.py)

1
2
3
# 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))

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

1
i++; // increment variable i


我相信JBoss有一句话是这样写的

1
return null; //Not really null

我一直喜欢这句话。


这一个来自图像浏览器XEE。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
    // 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.

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

从经典的虔诚的Usenet: </P >

Deep inside the Teradyne hardware modeler code is a routine that feeds a
whole bunch of hex numbers into a SYS$QIO call. The only comment is
'Weird magic happens here'.


有一次,我问一个同事如何使用我们的内部框架做一些事情(完全忘记了什么,一些模糊的技术调用)。他说:"简单,看这里",然后在他的编辑器中打开一个.java文件,在几页代码中间显示这个评论:

1
// HERE

我刚检查过,评论还在这个文件中:)


在头一个代码文件heavily由村的每一个人在开发团队: </P >

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

好的旧的弗兰德斯。 </P >


展览A:

1
return 0; // Happy ending

展品乙:

1
2
3
4
5
6
7
8
9
10
11
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
);


// This will save us ~0.5 sec for every user and please the machine spirits.

在很长的程序之前:)


1
2
3
4
5
6
7
/**
 * Happy Javadoc haiku:
 *
 * Without Javadoc
 * Builds break in Maven site stage
 * This fixes the build.
 */

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


1
// this error could never happen

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


1
2
3
4
else
{
    // rien, c'est parfait.
}

24


1
2
3
4
5
  rescue
    # silently, we fail
    # many validations fade
    # like tear drops in rain
  end

这只是众多…


在makefile中找到这个

1
# ===== Never edit below this line. Ever. Or I'll kick your ass. ====

1
2
3
4
5
/**---------START-----------**/

  //  IMPLEMENTATION GOES HERE

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

但没有代码;


我最喜欢的评论一直被我的一个同性恋朋友使用。他喜欢在vb.net中将他所有的todo评论标记为

1
'TODO: Matt Damon

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


我想我有这样的经历:

1
2
3
4
5
6
if (case1) { // trivial
...
}
else { // we are screwed
 /* fill in later */
}

好吧,所以我可能用了一个比螺旋更有力的词


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

对于比课堂作业更大的作业,我们会在家里完成,并提交代码+输出打印件进行评分。在提交了一些代码+输出打印输出之后,我们共同意识到老师实际上并不是在阅读代码——只是打印输出。为了测试我们的理论,我在代码的第3页上的一些类声明之间添加了一条注释:

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

当然,我拿回来的时候,前面有一个蓝色的"A",没有找到对勾。


1
2
3
// BEGIN HACK
...
// END HACK: I feel dirty.


1
// Hard to explain

最后也被打破了。难怪很难解释


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

1
' RIP LVB

(明白了吗?)


事实上,前几天看到了这一点,当时有一段时间赶在最后期限的时候写了一些代码。

1
//This was clearly written under duress

1
2
// 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次这样的评论…


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

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


1
2
// Singleton object. Leave $me alone.
private static $me;


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

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


1
// need a coffee to fix this.

好吧,这是我刚承诺的:

1
2
3
4
5
6
/* 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之类的网站,赚些钱。然而,那个人不是我。


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

1
2
3
4
// 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

这实际上是"在我身边,当我执行A病毒的原型车为实际的代码: </P >

1
// Abandon all hope you who needs to debug this

是的,有人比我实际上smarter重构的代码afterwards(它不得不有一个很好的结局)。 </P >


1
2
/* 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版本…


Linux的评论

有很好的heaps)………………………

这些都是在Linux上

http:/ / / / / LWN.net 1998年f-word.html 1015号

我最喜欢的:

1
2
3
4
5
./arch/sparc/kernel/ptrace.c
/* Fuck me gently with a chainsaw... */

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


"这永远不会发生"。

最后一句名言我的朋友…


1
2
3
4
5
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

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

第一次提交(在测试人员返回结果后,其他几十个测试人员进行以下操作):

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

第二承诺:

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

第三:

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

第四:

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

第五:

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

是的,我厌倦了"修正错误"。


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

在XSLT文件的头中:

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


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

1
// The world is a happy place.

我不太清楚,但我的想法是这样的:

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

这是肮脏的代码;)


我曾经参与过一个项目,在那里我发现了以下评论:

1
// Cabbage fart?

我不知道这是什么意思。很高兴我的立方体不在写它的人旁边。


我喜欢GNUbinutils中的一些评论。这一个来自bfd som.c:

1
2
3
4
5
6
/* 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.  */

这也是:

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

1
2
3
4
/* 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.  */

另一个:

1
2
/* 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. ... */

来自气体:

1
2
3
4
/* 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.  */


我猜它是病毒性的,我在一个守护进程(Linux)中发现了以下内容,阻止OOM杀手选择它:

1
2
3
/*
 * Don't OOM me, bro!
 */

这是在mlockall()之后,为防止进程交换,评论道:

1
2
3
/*
 * Don't swap me, bro!
 */

// Whoever put this here is an idiot...this doesn't work at all !

但代码仍然存在…


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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
        /************************************************************
        *                                                           *
        *  .=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-.       *
        *   |                     ______                     |      *
        *   |                  .-"     "-.                  |      *
        *   |                 /            \                 |      *
        *   |     _          |              |          _     |      *
        *   |    ( \         |,  .-.  .-.  ,|         / )    |      *
        *   |     >"=._     | )(__/  \__)( |     _.=" <     |      *
        *   |    (_/"=._"=._ |/     /\     \| _.="_.="\_)    |      *
        *   |          "=._"(_     ^^     _)"_.="           |      *
        *   |              "=\__|IIIIII|__/="               |      *
        *   |              _.="| \IIIIII/ |"=._              |      *
        *   |    _     _.="_.="\          /"=._"=._     _    |      *
        *   |   ( \_.="_.="     `--------`    "=._"=._/ )   |      *
        *   |    > _.="                           "=._ <    |      *
        *   |   (_/                                    \_)   |      *
        *   |                                                |      *
        *   '-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='      *
        *                                                           *
        *      LASCIATE OGNI SPERANZA, VOI CH'ENTRATE               *
        *************************************************************/

1
THIS PROGRAM HAS CODE THAT DOES NOT MEET STANDARDS

这是每一个评论冰进近程序,在这里我们有……………… </P >


在卢卡斯的"电脑游戏"的源代码中可以看到"Eidolon"(这是Wierd和Wacky自己的权利)。

1
// He's dead, Jim!

从一个看了Python的小伙子那里:

1
2
> // And now, for something completely
> // different:

class theLarch{


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


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

1
2
3
4
5
6
// fix for groupid > 9
// if groupid ever gets to 100 everything will break (again)

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

此注释来自我必须调试的旧项目:

1
//Haleluya i can go home!

在JUnit API中找到:

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


1
// TODO - Comment this function


今天刚添加了这个:

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

从Unix版本6的源代码中,大约在1975年:

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

1
// Fuck.

那……

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


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


不是注释,而是属性

1
[ThereBeDragons]

我在IHttphandler的实现中看到过一个

1
2
3
4
5
//What is this?
public bool IsReusable
{
    get{return false;}
}

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

还有:

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

这是我自己的代码,但它仍然很有趣,我想我也可以把它放上去,因为它在公共SVN中。

1
2
3
4
// 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;


在调试其他人的javascript时,我看到了以下注释:

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

但是当我读到斯科特·汉塞尔曼的一篇文章时,我发现下面的引述与我在代码中发现的评论非常吻合:

1
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.

这很有趣:


1
// TODO: Implement this function!


1
/* My lawyer told me not to reveal */

1
2
3
4
5
6
7
8
9
10
11
12
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;
}


然我在这一个测试在真正简单的C++程序中类的大学。

我是commenting类。

在析构函数。

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


这是我最喜欢的评论。

1
2
/// 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

稍后在文件中我们会有更多的乐趣,比如

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

再后来

1
if( where == null)//be nice


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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*

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


*/

1
// This part is more difficult

在方法的顶部。

大约5行长。

也不是很难。

这是唯一的评论。

在整个应用程序中。


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


1
// TODO: Finish.

1
// Bad Christian, No cookie

此上下文中的cookie未引用浏览器cookie


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

这是一个犯规行为。我一直做噩梦。


我在谷歌代码搜索中找到这个

1
2
3
4
5
6
7
8
9
    // 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;
    }

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

24


在一家大型投资银行,需要记录所有应用程序中断并发表评论,我看到

1
2
3
4
5
6
7
Without a crash

Or mighty bang

The sync disk

Did it's process hang


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

1
// TODO: not this

由一位同事在一个急需优化的查询上写的。在他的辩护中,我们几个月来每周工作70小时…


1
2
3
4
5
6
7
8
9
10
/**
 * 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
 */


好吧,这些是我的,所以wtf就是我,正如coding恐怖所说:

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

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

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

碰巧,[客户名称]没有改变主意,但他确实可以访问Web服务器,而且他确实找到了那条线…


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

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


1
2
3
4
5
6
 // WARNING!!!
 // Very perversive code ahead!

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

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

1
i++; //increment i


不是什么评论:

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

可悲的是,没有评论,pscript5.dll真的爆炸了…


一个有趣的打字错误,非常合适:

assert(0); // should never shit this point


在LKM中:

1
2
3
4
5
6
7
8
9
10
/*
* Dear Richard Stallman,
*
* This one's for you.
*
* Sincerely,
* Me
*
*/
MODULE_LICENSE("GPL" );

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

直接链接

更多的乐趣与谷歌代码搜索。


我最近看到了:

// you just lost the game

如果你不知道游戏是什么:http://en.wikipedia.org/wiki/the-game(mind-game)(这很愚蠢,但在某种程度上很有趣)


在为某个芬兰移动网络设备制造商工作时,我在硬件抽象层中发现了100多次出现芬兰语单词"puukko"。

"puukko"是一种万能刀,每个芬兰人的工具箱里或房子周围都有这种刀。它被用于从播种土豆到执行计算机维修(我的观察)的所有工作。我相信在这种情况下,它是芬兰语中"hack"这个词的等价物。

我的芬兰同事否认了这一点,并说这更像是"手术/干预"…我几乎相信他们,直到我找到评论:

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

在我见过这个代码在一个全功能的casts显奇怪:

1
2
// 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."

这是horrendous代码:)


在一个文件中5000多行代码中很少有注释我和那个为他的编码风格辩护的编码员有一个争论…无可奉告!没有评论;-)(或很少)遗憾的是,这是生产代码。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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++;
    }

我喜欢这个开关!

1
2
3
4
5
6
7
8
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"的注释。

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

720是什么?


1
2
3
4
catch (Exception ex)
{
    // just die already.
}


在应用程序中首次重新编译FreeTextBox3,因为我们需要IE8支持…看看我发现了什么:

1
// IE7 update. this is still bad code, but IE8 is probably a long way off :)


1
2
# dont question, i just felt like throwing some globals in
# this is actually quite pointless as youll soon see

代码后面的部分

1
#draw the circles (complicated)...dont question

甚至更晚…

1
2
3
# complicated process of drawing the circles in a
# somewhat symmetrical, 3-d pattern
# dont question again

甚至以后…

1
2
# will determine if user clicks on die
# i determined these values...dont worry about them

1
// insert comment here

我在重新使用一个PHP类时发现了这个问题,我在相当长的一段时间前就写了这个类。我仍然记不起去那里的东西,我仍然没有找到它的用处…事实上,我甚至记不起我在写这篇评论;所以当我发现它时,我真的大笑起来。

1
2
3
4
5
6
7
8
9
10
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;
}

1
2
3
4
<!-- 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) -->


1
// *** AAAAAHAHAHAH!!  What is this??


从单元测试类:C大调#

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#region quis custodiet ipsos custodes?

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

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

#endregion

我不再有确切的代码包了,但我清楚地记得这个评论。

1
2
3
4
// 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.


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

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

整个功能非常好(来自linux sunhme.c驱动程序,对于被sun昵称为"快乐大餐"的网卡而言)。因为之前的那张牌是"巨无霸"。了解了?明白了吗?)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
", 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
");

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

}


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

1
// zzzzZZZZzzzz....


这是一个自定义的DHCP服务器,我们在一所大学的宿舍中使用它来将计算机放入"干净"或"脏"的IP地址池,这取决于它们是否注册/安装了补丁和防病毒软件:

1
public boolean getDirty (String MAC) // not as fun as it sounds

Control+A,重写

这是作为签入注释添加到上一个项目的源代码管理中的注释。


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

1
# Don use this. Never!


1
// TODO: what the hell is this all about?

然后一些注释掉了代码。

这是我们今天早些时候在工作中的代码中发现的。我不知道我该笑还是该哭…


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

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


# as you can see: I comment the code!


// no comment


在给一个朋友看了这篇来自"编码恐怖"的帖子几个小时后,我看到了他对代码的评论:

// MrValdez is a violent Psychopath. Don't piss him off.


我曾经研究过Windows3.0的源代码。(不是,作为一名微软员工,我很快就要添加!)在那里,我遇到了一个文件加载程序,它多次重新进入,并有一个讨厌的双关语的例子(只是为了展示作者有多聪明)。

这种混乱的可重入代码是用英特尔汇编JMP指令(在C代码的中间)执行的,该指令的标签是"we_are_not_in_kansas_any_more_toto"


刚从大学毕业,我就急于把手弄脏。我的第一个任务是…"请为我注释此代码"。

混蛋。

过了一会儿,我就厌倦了…

1
2
3
4
5
6
7
// 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]

// This is confusing, I KNOW, so let me explain it to you.


1
2
3
4
5
6
7
8
9
10
11
/**
 * 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";


//Iterate by one
$i++;

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


1
2
3
4
5
catch
{    
    // you’re fucked
    // write out the file somewhere and start screaming"Connection down! Connection down!"
}

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

I feel so dirty doing this but the guy wanted it in .NET


在名为"bar"的类(该类是一个具有描述性名称的UI控件)中,类头:

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

Remove()法:

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

更糟糕的是,它是一个业务合作伙伴从生成的文档中指出的。更糟糕的是,这些可能是最接近有用文档的东西了。


在发现了这个: </P >

1
I'm not sure what I did

许多年前,我接受了这份工作,为一个真正的项目提供支持。在Z80上进行组装(还有其他方法吗??)不管怎样,最初的作者是一个叫摩西的尼日利亚人。也许我应该停在那儿。总之,分散在整个代码中的是:

1
XRA A    ;MT

我花了一段时间才弄明白这是什么。指令本身不起作用而不是清除蓄能器。虽然我不确定是否有是否有利。你只需做:

24

但也许

1
XRA A

保存字节或其他内容。所做的是排他或蓄能器本身。当然,结果总是零。

回到山上-空的(明白吗?)

这是我遇到的最好的。


很久以前,我遇到过一些连接脚本,虽然我不记得语法,但我确实记得这些注释,因为我是一个粉红的Floyd迷。

1
2
3
4
//Attempt Handshake: Hello? This is London calling. Are we reaching you?


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

来自C

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#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

1
// woot, global var. I havent done this for a long time.

我最喜欢的就是这样

1
2
3
 # commented out
 ...
 ### end of the formerly uncommented #2001-02-22 John Doe

在内容管理Web应用程序的一堆糟糕剪切和粘贴的源代码中:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// 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

注:大致翻译自意大利语:—)


/* This is a replica of a horrible hack - many moons ago, the legacy PortfolioServer was modified to return cash trades in an"optionTrade" block, because the client side developer was too lazy to get their XPaths right. Their laziness echoes through the ages, and means we need a similar hack here...*/


1
// This code sucks.


1
2
3
4
5
6
7
8
9
10
11
12
{
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]
}

我个人最喜欢的是利默里克格式的文档:

1
2
3
4
5
        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"指的是"扭曲的现实"。Zope2和最初的twisted.reality包广泛而不幸地使用了多重继承,这可能使您在看到方法调用时很难理解发生了什么。Zope3,扭曲了自己,而twisted.reality的继承者(包括最新的,虚构的)通常喜欢组件组成。


我们有一个小组项目来创建一个连接4人工智能使用最小最大树。在我们的move-scoring函数中,我们让它计算一个董事会的分数,在代码块上方有这样的注释:

1
// This is kind of almost useless

但它会变得更好。我们的指导老师给了我们一些他制作的原始人工智能的样本代码,他留下了一个很好的评论:

1
2
3
// 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.)


我没有要共享的代码,但是想象一下这个场景。大约在Linux系统管理员离开去更绿的牧场一到两个月后,我很高兴打开了他编写的shell脚本。我想不起来我为什么要编辑它,但这并不重要。重要的是剧本大约有40行长。我滚动浏览注释(其中有37行)以获得实际工作代码(3行)。代码很好,但我很好奇——为什么有37行评论?所以,我滚动到顶部开始阅读。令我惊讶的是,这三行代码所做的以及如何修改它的评论是一种说辞。最棒的部分——这是Dre和Snoop博士对G的部分抄袭。谢谢Brian!


1
//Time log says you've been here for 15 hours GO HOME, your code is hobo


1
2
3
4
5
6
7
8
9
/*
* TODO: Remove this function

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

*/


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
""".........................:~+?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!"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
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;
}

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

1
2
3
4
5
6
7
8
9
10
11
12
13
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 */
   ...
}


我只是在自己的代码中碰到了这个问题。它位于用于类别选择的Magento管理模板中:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
        /*
         * 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?
        }

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


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

This can't be a bug in my code. I coded it very carefully.


1
// nobody read comments!


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

1
2
3
4
5
6
7
8
9
/**
*@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中):

1
2
3
/*
 * A virgin directory (no blushing please).
 */

在freebsd内核源代码树中(甚至之前,返回到4.xbsd)


来自申请英国银行的承包商。

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

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


1
<!-- Here it is -->

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


这一发现的只是一些我们在PHP代码

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

如何有用的是自我解释,luckily美元


1
2
3
4
5
6
try {
   doSomething();
} catch(err) {
   // Die quietly
   alert(err);
}


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

1
2
3
4
5
6
7
8
/*
** 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.
*/


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


我看到这一次。

1
//this used to be a comment

Beware of bugs in the above code; I have only proved it correct, not tried it.

那个是唐纳德·克努斯写的。


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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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...

他指的是,他用马车把绳子劈开,然后返回来分开渲染。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// 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

当然,我们还收集了一些有趣的方法来表达"黑客"的意思:

1
2
3
4
5
6
7
8
9
// 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

这个对其他人来说很有趣,但对我来说就不那么有趣了。我从一个自己继承代码的开发人员那里继承了代码(即ASP)。第一个程序员创建了一些非常难以理解的代码。第二个开发者添加了如下评论(隐藏姓名以保护不那么无辜的人):

1
2
3
4
5
6
'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代码。

…是客户向我强调了这一评论。


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

哪里生气=喝醉了


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


1
What do you think you're doing, Dave?


1
2
3
4
5
6
/*
* 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
*/


柏克莱数据库

1
2
3
4
5
6
/*
 * Chaos reigns within.
 * Reflect, repent, and reboot.
 * Order shall return.
 */
return (DB_RUNRECOVERY);


看到这个:

1
'On Error Goto Hell.


1
//FIXME: fix this before the 1.0 release

他们在第四版


1
var something TBoolean; //Pickins


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


1
2
3
4
5
6
7
8
9
/* 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。每次读到这篇文章,我都忍不住笑。


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

从JPGRAPH


1
2
3
4
5
6
7
8
9
public static final void attachListener(Object listener) {

/* ======================= */

// This does nothing, continue searching

/* ======================= */

...

听者很痛苦!


1
2
/* Only break the connection if it actually exists. It is important to
 * check the timeslot saved in the SOURCE of the disconnect message. */

我写了这个评论,现在我记不起为什么它很重要了…


24

当降低某些日志的优先级时,我自己写了这个注释,否则这些日志将写入数百MB的垃圾,严重影响应用程序的性能。


1
2
3
4
5
6
7
8
9
10
11
12
BEGIN.
// Here might be dragons
.
.
 IF...
 // Beware of the Jabberwocky
 .//user the force, luke
 .
 .
 ENDIF.
.
END.

1
2
3
4
5
6
7
8
9
10
#!/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

将由从5.9(又名Solaris 9 / usr /斌/假)


我没有第一手遇到这个问题,但这是一个很好的故事(见我的评论中的解释):

1
#define MSGTAG_B33R     0x723 /* RIPLVB */

从旧Perl CGI脚本:

1
# This is convoluted and evil, sorry.

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


在相当长且复杂的while循环集和if块的末尾,有问题的开发人员插入了这个最后的注释:

1
2
3
4
else
{
    // wobbly wilson said this would *never* happen!!
}

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


1
// this is really complicated

没有其他评论


对于一个项目,我们将pwlib作为依赖项,当时它的freebsd端口有点混乱,所以我必须从源代码手工构建它。它没有马上解决,我不得不研究代码;有一些复杂的类层次结构,其中部分代码是由宏生成的,父类calss声明以

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

几年前我在一个.h文件里看到的东西。

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

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

1
2
3
4
5
-- 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


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

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

1
2
3
4
5
//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


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

代码中有一个方法可以执行一些日历计算。它有些破损,由于一些不幸的情况,不得不笨拙地处理日光节约。

我们必须修理好几次,而且每一次,我们都会在几个月后发现一些破损的东西。

在花了一整天的时间对其进行修复和分析之后,我将代码放入了源代码管理中,并添加了一条这样的注释:

1
2
3
4
5
6
// 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}

最终,我的团队被外包了。有几天,我想知道这个代码怎么了:)


我在一个COBOL程序中看到的东西,吓得我瘫痪了。

1
* All comments pertain to the lines which follow.

这是什么意思?

  • 有人对评论很不满意,不得不写一篇元评论?

  • 有人习惯于把评论放在相关代码下面,并被告知把评论放在上面?那是怎么发生的?


  • 就在今晚,我们的团队发布了一个新版本的CSS文件,它删除了一个文件中的注释,该文件的结构如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    @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!
            */
    }

    有趣的是,在网络上,你会发现人们的解决方案只是输入一个伪造的元素,作为charset语句下面的第一个规则,被忽略并按正常方式继续……

    思考的食物:你把评论放在哪里不评论?

    旁注:我知道由于标题、元规则等原因,不需要这样做。不幸的是,我们需要它作为全部捕获:(


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


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


    1
    2
    3
    4
    5
    #define FUCK_VS6_CANT_COMPILE_TEMPLATES_WITHOUT_HANDHOLDING ((float*)0)

    ...

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


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

    1
    // echt halmaal gek - no way!

    (它的意思是"真的很愚蠢"…这对我们也没有帮助)


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


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

    我刚在.NET的自定义Linq提供程序中找到了这个:

    1
    2
    3
    //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.

    这一个

    1
    2
    3
    //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!

    我也发现了这个…只是越来越好了

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
      //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

    这一个

    1
    //Compile that mutherf-ker, invoke it, and get the resulting hash

    1
    private static final Logger lager = new Logger();

    1
    2
    3
    4
    5
    6
    7
    8
    try
    {
    ...
    }
    catch(Exception ex)
    {
    //if this happens the world is going to end...
    }

    现在猜猜发生了什么…


    javascript函数的第一行:

    1
    // this part is more difficult

    世界跆拳道联盟?


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

    这一发现的类的前面。之后是什么(朴素)试图实现一个ORM。我仍然不明白为什么他写的那个。


    1
    2
    3
    4
    5
    6
    7
    8
    //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. :-)


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

    那是20世纪90年代中期,我正在进行一次大规模的迁移:小型软件供应商、大型客户机和巨大的压力。我们有很多改变门柱的东西;这个项目很难控制。我是关键的开发人员,但对系统来说是新手,另一个开发人员是供应商的所有者/创始人。

    在几个月的时间里,业主/创办人没有完全确定最后期限,也没有完全满足客户的要求,之后,他们又引进了另一个远程工作的开发人员。(我要冒险说,新开发人员的技能和经验比我少。)

    好吧,新来的家伙对我已经研究过的代码做了一些修改,然后一两个月后我又回到了代码的同一个区域,有一些我以前没见过的变量。名字像StupidMark

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

    在我当时的观点中,新的家伙的代码并没有让我们更接近一个可交付产品,这使得侮辱刺痛了一点。


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

    1
    2
    3
    4
    5
    6
    /**
    *  Do not use, ever - left in place for testing purposes
    */
    function  I_David_WillHuntYouDownAndHurtYou_Badly_IfIFindThisUsedAnyWhereInTheAppLibrary(){
    ...
    }

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

    我写的另一篇小篇小说是为一个数据供应商设计的自动下载器,详细描述了我多么讨厌这个供应商,并尽可能地假设他们的基础设施的批处理系统是由沙鼠运行的,在轮子上运行,在轮子旋转了这么多次之后,下一个排队的任务就会开始。它是在添加额外异常处理的6个月过程中编写的,Estoric检查(如果我们有768个字节的字符,这意味着对它们的数据库的查询超时,空格是空的失败打印语句的结果)。


    1
    // haack, phil haack

    还有:

    1
    2
    3
    4
    5
    /* 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
     */

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

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    // 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"; }
        }
    }

    我是多么喜欢双关语。


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

    当我在一个项目上读到这篇文章时,我哭了。

    1
    //Write Code Here

    我仍然畏缩:)


    1
    // good luck!


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

    1
    2
    3
    4
    5
    // 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();

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

    我发现在一个复杂的代码

    这是耶稣和/代码有一件事是:在普通的两个resurrected


    一旦我找到这个:

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

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

    1
    // simply copied from another code

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

    在一个多threading模块!:)


    在一次有一个叫"客户年后做一个大的预算制度写在悖论3.5

    "我们来了一位在大学commenting这是IP的DEBUG"

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

    …………………!!!!!!!


    在发现这一个或

    1
    // fix it!

    我发现在这

    1
    // This is a kind of magic...


    我国政府用企业级制度评析

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

    好的Ole Rh…..公司Prez/首席开发人员


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

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


    在一个艺术资产导出工具中,我偶然发现了一个完整的从阿拉伯数字到罗马数字的翻译程序。看起来像这样:

    1
    2
    3
    4
    5
    6
    7
    8
    /*
    //You can tell I was bored
    //I wanted to do this for a long time
    char* ConvertToRoman(int number, int base)
    {
    ... whole code here
    }
    */

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


    1
    // TODO: Delete

    1983年在一些COBOL中看到:

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

    1
    Get This hack!

    在一个assembler码线,售后部评论页面的代码。 </P >


    大约在搭便车的导游游戏是新的时候,我有一个案例,我在那里测试一些东西是否可以滚动,以及用户是否试图滚动,使用一种限制可变长度的语言。所以:

    24


    我所看到的最好的评论是

    1
    2
    3
    /*
      There is no accounting for pointers
    */


    1
    // The hackiest hack that ever did hack

    它在WordPress博客引擎中(wp-admin/includes/user.php——如果有人真的想看到黑客的话)。


    1
    2
    // The following array may contain either TexturedObjects or ColoredObjects.
    // I know, it sucks.

    我刚刚完成了一个日志框架(它使用跟踪,我不知道为什么会有这样的东西存在)。我创建了一个从TraceListener继承的方便基类。它覆盖了所有的traceListener方法,并将它们路由到一个方法中,因此有很多文档注释:

    1
    // TODO: Need some codemonkey to doc comment this class.

    下面的代码出现在针对Python的模拟教程中。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    # 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)

    作者一定是个家庭成员的粉丝。^ ^ ^


    1
    'I hate nested regions and will delete them along with any code found in them.


    在早期版本的PeopleSoft Financials PeopleCode中:

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


    来自python/ceval.c:

    1
    2
    3
    /* 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). */

    1
    2
    3
    4
    %%return_median
    hit_the_sweet_spot(Arg)->
    .
    .


    1
    2
    // now that's compact!
    list->insert(list->end(),**pitch)->IdxOfSample=(pitch->pos-Offset)*SamplingRate;


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

    1
    2
    3
    4
    5
    '""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    '
    '  NOTE: DON'T SCREW WITH THIS CODE UNLESS YOU REALLY UNDERSTAND IT!
    '
    '""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""


    24


    //The below code needs to be commented out.


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

    来自旧Netscape Mozilla代码的经典。我个人喜欢

    just can't fuck around. Oh, also moving memory would doom us anyway, and
    it'll all just be too damn hard to figure out. So, I give up, the Mac just
    completely utterly sucks complete rocks

    但是还有很多其他有趣的。


    回到大学:

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

    当我们和教授一起复习的时候,它在一份印刷品中被突出显示出来。

    原因:一些与缓冲区溢出有关的非常讨厌的bug,它影响了一个不相关的变量,在代码的另一个地方有一个文件处理程序。移动变量将使其再次工作。


    刚刚在一些操作脚本中发现了这个,我必须更新…

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

    ……


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

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


    24


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

    这一个差点就杀了我。


    丹尼斯里奇(有一些页面是在Unix上的古


    24


    1
    // 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个因素…(是的,我必须调试并更改这段代码,然后写了注释,但是我没有写原始代码)。;


    http://fxr.watson.org/fxr/source/pci/if-rl.c是好东西的来源。


    从sendmail配置文件。在一页又一页的看似简单的线条噪音之后。我找到了这个宝石。

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

    1
    2
    3
    /* Jeez, this is an ugly mess */

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

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

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


    从Joomla!源码:

    1
    // this is daggy??


    在一些非常蹩脚的VB代码中(我知道这都是蹩脚的,但是),我在一个空的if控制块中发现了这样一个注释,它表示如下内容:

    1
    2
    3
    4
    5
    If bFound Then
         'I love it when I write kick ass code like this
    Else
      .
      .

    我最伟大的作品汇编:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    // 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!


    在加州的SJ,在拍卖业的早期,我和一个叫里克·多林的人一起工作。当你一整天都在玩牌的时候,他会给编纂者回信。他的一条错误信息是

    Too Many Errors... Make fewer!


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


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


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


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

    我只是检查,这在其他的一天……

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

    在(……""=="专有的东西后我能’t")。我喜欢我的sternly - worded预警单元。


    1
    -- Beyond this point, there'll be dragons

    我发现它的时间更多的用在pleasingly illustrative ^ ^


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


    1
    2
    3
    4
    else
    {
        //error situation
    }


    来自/system/library/frameworks/appkit.framework/versions/c/headers/nstextview.h:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    - (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? */

    1
    2
    3
    4
    5
    [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--]

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

    它是在consisted Bunch of触发器在数据库将被添加到使它的后续工作流规则。

    在一个触发器的东西,有人在微软写的:沿着线

    1
    //Determine if the database has been"Grizzlified"

    (内部名称为"灰熊"的产品,所以我认为这是有趣的)。


    消毒:

    1
    2
    3
    //Forward declarations:

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

    1
    /* Hammer Time! */

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


    我真的很喜欢"哦,我的"gawd标签,而不是评论…

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
        /*
         * 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;
        }

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

    DelButton.click();

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


    在emole的preferences.cpp中,在强制最小上传速度限制与下载速度限制成比例的方法中:

    1
    2
    3
    4
    5
    6
    7
    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);
    }


    我继承了一个项目,HAAD已经交付给客户,没有任何UAT。它被踢到了栅栏上,要求的是钱。

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

    许多系统调用都被忘记了。

    当我上船时,密码上镶嵌着这样的宝石:

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

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

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

    编写代码的混蛋们仍然在团队中,根本不关心交付的垃圾!


    在编写映射器应用程序时,我们有一些标准,其中之一就是在整个套件中使用了一个标准变量列表。其中之一-"v43"总是用来表示姓氏。所以想象一下,当我被要求修复的一大块神秘的映射器代码中唯一的注释是:

    1
    Here V43 contains the Surname


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

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

    代码以迂回的方式将空值逐行转换为零长度的字符串,因为愚蠢的程序员不知道空值是什么,而且从未听说过nz()函数。


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

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


    技术上不是评论,而是在凌晨2点左右对某个东西进行编码:

    1
    consent = False

    …该变量永远不会再次使用,并出现在套接字的侦听循环的开头。


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


    在拉丁美洲,Abandon hope all ye who enter here来自但丁的"神曲"。


    靠近装置顶部:

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

    1
    // GK Experimental

    (GK是编码员的首字母)

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

    这是一个很好的标志,当你在调试期间点击它时,你可能会在接下来的几个小时里忙着修复黑客。;


    1
    TextBox1.Text = TextBox1.Text; //Point less yes, who writes this crap?

    // Description : !!! TODO


    1
    2
    // This interface defines method signatures
    interface IWhatever { ... }


    从Joomla!源码:

    1
    // fudge the group stuff

    我今天早上在vb.net上遇到的一个很好的,笑了…

    1
    2
    3
    4
    5
    6
    7
    ''' <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

    我刚注意到自己在写这个

    1
    // not brilliant solution, but fair enough heh.

    1
    2
    3
    4
    5
    #pragma region Crap that is kept for temporary reasons

        //  Huge chunk of commented code

    #pragma endregion


    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    // 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.

    从Linux内核源代码:

    linux/include/asm-i386/hw_irq.h:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    /*
     * 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
     */

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


    在生成HTML的旧Perl脚本中找到:

    1
    2
    # 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

    1
    // Sorry dirty code


    以下是4个,没有顺序:

    1
    2
    3
    4
    5
    6
    7
    8
    // Father, forgive me, for I am sinning

    // heaven help me

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

    // what, me worry?

    我刚刚发表了以下评论:

    1
    // this control (Resistance) is FUTILE!


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


    我在自动化构建中处理的一个大型项目使用了StyleCop和FxCop,它使用规则防止人们使用未注释的字段、方法、属性等签入代码。

    有人因为必须添加诸如"获取或设置全名"之类的注释而非常恼火。为了自我记录诸如全名之类的属性,他们努力编写宏来绕过规则。

    宏为方法、属性等插入了XML摘要标记,其中一个不显示unicode字符作为标记内容,这将愚弄构建规则,同时也对他盲目坚持为其注释内容的做法造成了轻微的打击…

    …至少在他们引入另一个规则来检查注释中的Unicode字符之前。


    在20世纪80年代初的某个时候,我们正在为pl/i中的实用程序编写财务建模代码。一个客户打电话给我们,一条评论后代码就爆炸了。

    1
    /* Honest this works */

    那家伙拿了我们的标准金融方程组,做了大约15页代数,把一堆代码组合成一个方程。三里岛之后,公用事业公司不得不以巨大的成本注销核电站,由于一个固定的15号箱(整数)溢出,方程式失败了,如果代数没有发生的话,这个溢出就不会发生。


    当我在评论我认为不再有用的代码块时,但我可能错了(因此不删除它们),我有时会在它们前面加上

    1
    // Wilted celery?

    这个想法是,这就像芹菜枯萎了,但你还是把它放回冰箱。我只知道10年后会有其他人发现这些评论并说wtf?


    曾经有一个程序员为我工作过,他在代码中添加了"风格"注释,在代码中他编纂了关于特定实现细节的内部辩论,并在他被否决某个特定的编码决定时进行了离别。

    实例:

    风格"这是可以论证的,哪个更好,但我传递的是图像处理,而不是简单的'传递缩放值以使调用代码更简单(通过'几个声明语句)。或者,我可以传递这些数据'直接来自调用代码的成员,但这将违反封装。

    风格正如我在其他地方所做的,我将登记我的官方抗议(只需给我'要填写的表单。)有关实现批注序列化的'一个属性而不是一对加载/保存方法。同样,这可能是"风格问题,争议很大。


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

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

    在那之前,我确信我们已经摆脱了这种"有趣的东西",并且我们正在以正确的和思想上正确的方式做这些事情……


    1
    2
    3
    4
    5
    // 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

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

    //如果你找不到,就不应该读这个


    以下是我在不同时间放入代码的一些代码。有些不是技术上的评论,但它们是相同的概念。

    在只需要在一个平台上使用一些特殊代码的跨平台项目中:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    //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


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

    我的很多评论都包含了对电影或音乐剧的模糊引用,但如果你不了解这部剧,它们就不会那么有趣了。


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

    那就是工作保障。


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

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


    从http://www.madore.org/~david/computers/callcc.html:

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


    我们有一个文件在文件的一半下面,一个程序员试图弄清楚混乱的情况,设法把所有无意义的代码移到了底部,并留下了如下的注释:

    1
    I have no idea what this stuff does below here.

    另一个程序员留下了一系列嵌套的名称空间,这些名称空间的行为就像是一本"单向书",这样您就可以深入到这个想法中的名称空间中并选择您的操作。


    1
    2
    3
    4
    /**
     * Hexadecimal digit
     */
    protected $version = -1;

    开始的第一个更新两个巨大的对象:

    1
    2
    3
    4
    /*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行逻辑更新的对象:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    //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

    我和开发者的权利。这sucked硬!


    1
    2
    3
    4
    5
    6
    <cftry>
    ...code...
    <cfcatch>
      <!--- Gobble --->
    </cfcatch>
    <cftry>

    它遍布我公司的代码库。这是ColdFusion,它只是忽略了错误。


    我看到的一些旧的Fortran代码:

    1
    2
    3
    4
         integer *4 one,two,three;

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

    1
    // Hack-er-ama


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

    随后不久:

    1
    // TODO: end this lunacy


    再食一自己的狗食:我们有相同的术语在我们的工作场所(发放,只因为introduced它)。我的代码peppered与冰的评论,说"待办事项"和表示的东西,应该是好的,但是一个eventually评论说,"狗食"两个关键词,我是如何开始的评论,在全CAPS)均值的东西,必须完成之前,这个程序可以被用来internally平衡。这是一个方便的搜索工具,如Word的"狗食"两个appear冰永远不会在一个上市的字符串。如果是我,我只是说"狗食"或什么的,那么即使病例钝感来搜索将IP权利与结果。

    对"归零法:accumulator到底在做什么事的时候一样的编程方式(Intel 80x86开始在8086 IP和从那里搬到《现代奔腾)。xoring A寄存器和它是quickest和tightest清楚它的方式。使用MOV AX,requires 0"三个字节(字节的操作码和两部文学的16位无尽头"),XOR AX AX,唯一的"双冰;它的乐趣与平衡noticeable 386和高扩展的注册表,在"mov eax,requires五0"四个字节(字节)32位零)。我的C / C + +编译器总是zeroes注册表的这种方式,所以我还是assume'它的最好的方式(尽管在花园里的桌子studied码定时的年龄,和我们的两个异或REG REG REG和MOV,IMM拿一个时钟)。


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

    在这里,我们需要创建一个"组文件",如果有一个原始文件的3个变体,命名为后缀A、B和C。我一直试图跟踪一个奇怪的错误,在那里我们得到了不必要的组文件…

    1
    2
    3
    4
    5
    6
    7
    8
      (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))
          ...)))

    错误:1,肠道:0。

    显然,写这篇文章的人并没有想到,检查这三种变体可能是个好主意。当然,这就是我在这段代码最初编写10年后(它早于第一个SVN日志)追踪到的错误。


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

    该流程中的问题是在一些遗留代码服务


    MiFavE是一个用Java编写的学校项目的一些业务逻辑中的变量名。

    1
    int StupidJava = -1;

    这是一个旧的IOCCC获奖条目,我必须下载整个获奖者档案——一个冗长的1.4米——在找到它之前我记错了几个短语。

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

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

    没有推测皮棉产量的价格。

    好奇的是,那个入口就在这里。


    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    // 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
    }

    我做的一个数据库的访问,很简单——至少不应该是在开始和我做了它在Delphi。客户想要的是能够把客户信息数据库吗?但是,他们将没有足够的信息reliably回车确定两个客户。他们两个在海关AA使用电话号码是关键为每个客户(他们工作的方式,不是每个人都会有一个不同的)号码。之后的几frantic(从他们的保证金,它不工作,我们不能进入客户)发现,他们是太懒惰的两种面貌的IP电话系统的数字是从他们的老鸭是想进入全是为他们做不知道,作为"n/a"。这两个品种在想他们中的开口端的IP -是在代码检查回路和仇恨的结果中有一个"本应该永远是reached如果他们做什么,他们都应该做的!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"

    他们也曾经问我"怎么能找到我们的客户,即使我们把在错误的地址吗?"和所有的花生。


    1
    // now swap like a <explicative removed>


    我刚在一些旧代码中找到这个。

    1
    'CANNOT JUST QUIT!

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

    后来找老代码从类冰淇淋的乐趣……

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

    当持续通一些事情,但我希望它在左4有趣的评论是当我是黑客一起随机码……


    24