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

Tho*_*att 360 comments

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

Jen*_*and 1463

我对此特别内疚,在我的大部分项目中嵌入了非建设性的评论,代码诗和小笑话(虽然我通常有足够的意识在发布代码之前删除任何直接令人反感的内容).这是我特别喜欢的一个,远远落在一个设计不佳的"上帝对象"上:

/**
* 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.
*/
Run Code Online (Sandbox Code Playgroud)

对不起!!!!我忍不住自己......!

而另一位,这我承认我还没有真正释放到野外,即使我动心,我不太直观的一个类可以这样做:

// 
// 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
// 
Run Code Online (Sandbox Code Playgroud)

  • 请停止"更新"计数器.不值得将这个问题推到头版*再次*. (8认同)
  • total_hours_wasted_here = -32768,我该怎么办?我认为有些事情已经破裂. (4认同)
  • 我第一次真正成为RickRolled - 这很有趣.当我看到YouTube的链接时,我总是希望成为RickRolled(骆驼套装英语!!),但我从来没有想过会在代码评论中成为RickRolled. (3认同)
  • //亲爱的程序员// //现在我修复了你引入的所有错误,你的代码现在运行得慢了.//但你的优化确实有帮助. (2认同)
  • 评论中Rickrolling为+5,total_hours为+5.真棒 (2认同)

スーパ*_*ミコン 1055

Exception up = new Exception("Something is really wrong.");
throw up;  //ha ha
Run Code Online (Sandbox Code Playgroud)

  • 字面意思是LOL对这个人的聪明和幼稚的结合. (37认同)
  • 当我从真正的深度睡眠中醒来时,我的智商下降到25左右,我的思绪变得非常奇怪.有一段时间,经过长时间的写作java,我在半夜醒来时感觉病得很重,并且用螺栓固定在浴室里.当我呕吐到厕所时,我唯一能想到的是"我想知道我现在正在扔哪个例外......" (23认同)
  • 我从上到下阅读所有评论,想知道人们的意思,当他们说"破解,阅读这个"或"破解,阅读那个".好.我只是破解了读这个... (5认同)
  • class MonkeyPoo扩展Exception {}; ...抛出新的MonkeyPoo(); //因为抛出比异常更有趣 (2认同)
  • 我是ganna开始用尽而不是从现在开始使用XD (2认同)
  • 如果异常消息是"我感觉不太好",那会更有趣. (2认同)

joh*_*hnc 1052

//When I wrote this, only God and I understood what I was doing
//Now, God only knows
Run Code Online (Sandbox Code Playgroud)

  • 这是来自Karl Weierstrass的短语,这位数学家给了我们精彩的epsilon和delta连续性定义. (175认同)
  • @Augusto,你有这个短语归属于Weierstrass的来源吗?我想知道他指的是什么. (4认同)
  • Weierstrass the Uififferentiable? (3认同)

Tuo*_*ski 1048

stop(); // Hammertime!
Run Code Online (Sandbox Code Playgroud)

  • 停(); //合作,听! (83认同)
  • http://xkcd.com/210/ (24认同)
  • 我喜欢.Da da da DA,da DA,da DA,结束了(David Spade,SNL,Weekend Update) (8认同)
  • 停(); //那是什么声音? (2认同)
  • 停(); //!以爱之名.在你伤心之前. (2认同)

小智 1031

这似乎阻止了笨蛋弄乱我的代码......

// Autogenerated, do not edit. All changes will be undone.
Run Code Online (Sandbox Code Playgroud)

  • 让我希望SO支持个人回复的最爱 (7认同)
  • @AviD您可以将http://stackoverflow.com/questions/184618/what-is-the-best-comment-in-source-code-you-have-ever-encountered/740603#740603加入书签 (3认同)
  • 我认为他们会破坏你的代码:它说它会自行修复,所以为什么不打破它呢? (3认同)

Ser*_*lov 946

// sometimes I believe compiler ignores all my comments
Run Code Online (Sandbox Code Playgroud)

  • //由于我从未收到过编译器的回复,我相信这是真的. (86认同)
  • *笑声*,这就是未来,编辑阅读评论只是为了确保他们没有被误解;-D (52认同)
  • 我认为这应该具有讽刺意味...... (40认同)
  • 我希望编译器忽略这个人的评论. (26认同)
  • 我认为这篇文章很好地突出了如何不能发现讽刺真的可以让你看起来像个白痴. (5认同)
  • //#reply_from_compiler你喜欢clippy,不是吗? (4认同)
  • Javac实际上读了评论;)试试这个://\u000A阅读我的评论 (4认同)
  • //做我的意思,不是我说的!并且不要像你一直那样忽略这个评论! (3认同)
  • 讽刺的是,你这个蠢货(但是,这不是) (2认同)
  • //我觉得没有人听我说话 (2认同)

sha*_*kin 930

// 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.
Run Code Online (Sandbox Code Playgroud)

  • 狗为什么要向公众发布? (390认同)
  • 这是Duke Nukem Forever源代码的某个地方吗?;) (169认同)
  • 他将下面的代码奉献给了他的妻子,尽管他知道这很糟糕,以至于要么让他被解雇,要么让他的公司破产.:) (11认同)

Tom*_*ter 911

//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;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

更新: 该代码的原始作者已经将自己打败了,所以我必须在到期时给予信任.Dan McKinley在我开始后不久就离开了我所在的公司,他更多地谈论了代码,解释了一些背景以及一些"理查德"所写的"WTF".

  • 审查很糟糕.带回原来的! (241认同)
  • 回滚.我们都是成年人.如果原始代码已被"消毒",那么你永远不会记得它在这里发布它. (58认同)
  • 如果客户在堆栈跟踪中看到类名,那将会更有趣. (56认同)
  • 那里充满了猥亵,但我在整个时间读到它时,真的笑了我的立方体. (27认同)
  • 请不要回复NSFW版本 - 作者在第3版和第6版明确接受了SFW版本. (5认同)
  • Geez认为这是一个很大的争议.正如原始海报让我清楚一点:它是由Rev 2中的编辑进行的SFW.我不同意这一点,但放手,在Rev 3中添加了一个免责声明,说它 - 已经 - SFW-ed.它被归还给NSFW并且在Rev 6 -I-SFWed中,因为当时它有被删除的危险性.我更喜欢NSFW版本,因为我认为它更好地保留了ORIGINAL作者(编写代码的人)的咬合. (5认同)
  • 我把它安全地用于工作.我希望没有人反对:) (4认同)
  • 在这种情况下,我的主要问题是:"原始咒骂是否如此重要,以至于值得绊倒过于严格的工作和学校过滤器以及为某些用户阻止该网站?" 如果重要的是要保留原文并可能最终在一些网站黑名单(特别是小学教育学校和图书馆)然后继续,但如果使用假咒骂词可以保留它的整体意义,那么为什么不呢? (4认同)
  • 此外,这对某些人来说是冒犯性的,无论你的个人观点如何,随着时间的推移,它会被标记为这样.你可以争辩所有你想要的,但在一天结束时,有些人会发现这种语言令人反感.也许一个NSFW标签可以减轻这一点 - 至少在开始时他们应该知道他们可能会发现个人反感的材料,但它不会阻止所有人进行相应的投票. (4认同)
  • 人们,Jeeeez谈论编辑战争.如果您不想将亵渎等加载到浏览器中,请不要进入互联网.这是一个严肃的出价,包含真正的人类语言.此外,停止观看PBS.这是什么,1850年? (4认同)
  • 我遵从人们的意愿:)这段代码令人难以置信的令人难以置信. (3认同)
  • @Dana:审查是一种工具.它在错误的背景下很糟糕,在右边很有用.这个网站可以很好地审查这些事情.有一个叫做互联网的公开市场.所有审查都不好的断言只是愚蠢和不加批判. (3认同)
  • 而且我可以补充一点,一个人可能会失去这样的工作.如果他重视自己的工作,那个人会在很长一段时间内问自己是否值得. (3认同)
  • "//保护代码以保护愚蠢的人." 是因为我取出了实际的人的名字,并用理查德代替. (3认同)
  • 虽然我不关心"审查",但我认为对语言使用谨慎是恰当的.我的感觉是,在像SO这样的网站上,我发布的语言应该保持与我与老板或老板交谈时使用的语言相同的水平. (3认同)
  • 关于"头巾和飞行员太阳镜"的评论可能是我最喜欢的一部分.不过,我想我已经在Daily WTF上看过了. (2认同)
  • 修订日志比帖子本身更有趣. (2认同)
  • 此代码不再编译. (2认同)

Roh*_*hit 826

// somedev1 -  6/7/02 Adding temporary tracking of Login screen
// somedev2 -  5/22/07 Temporary my ass
Run Code Online (Sandbox Code Playgroud)

  • 啊,好的永久临时解决方案:) (79认同)
  • 没有什么是暂时的永久!!! (17认同)

Dan*_*ian 727

// drunk, fix later
Run Code Online (Sandbox Code Playgroud)

希望我在开玩笑.并且知道编写代码的开发人员,我认为他的字面意思.

  • 这太荒谬了,他们喝醉时写评论. (258认同)
  • @Jiminy:说真的!当我编码醉酒时,我醒来时会发现很棒的代码,遗憾的是,我不明白. (66认同)
  • 哦......如果你不理解它,那就太棒了! (22认同)
  • 哈哈!!!我这样做只是为了好玩:为我的本地subversion回购'喝醉了',发现一个提交评论我不记得了:"再次工作,不知何故.好吧......我喝醉了!" (14认同)
  • 哈哈,"..在0.129%和0.138%之间的BAC赋予超人编程能力..."http://xkcd.com/323/ (14认同)
  • 喝醉时写代码就行了.承诺是**不是**好的. (4认同)
  • Jiminy:当我喝醉的时候,我不仅要写评论,而且在我快乐的时候,我甚至会知道写一个(喘气)单元测试. (3认同)
  • 完全烘烤时我写了一个主要的安装程序.它工作得很好. (2认同)
  • @mr.moses也注意它在(或大约)0.1337上 (2认同)

Jas*_*ram 719

// Magic. Do not touch.
Run Code Online (Sandbox Code Playgroud)

  • 让我想起这个:http://catb.org/esr/jargon/html/magic-story.html (44认同)
  • 魔术=脆弱,也许? (20认同)
  • @Simon Howard,如果它说"更多魔术",我只会触摸它 (6认同)
  • 我必须多次写这篇文章 - 主要是为了提醒自己"如果你在不知道自己在做什么的情况下触摸下面的代码,就会发生不好的事情!" (5认同)
  • 我还记得在高中时被CS教过,我们的愚蠢问题用"魔术"来回答!和最阴险的笑容. (4认同)
  • 我打赌Windows源代码树中的每个文件都在标题中有这个注释 (2认同)

小智 701

#define TRUE FALSE //Happy debugging suckers

  • #define NULL(:: rand()%2)//也会很好 (95认同)
  • @Bart:你的代码中不能有半个parens,但你可以做`#define if(x)if(!(x))`(或者,更邪恶的是,`#define if while`) (66认同)
  • #define if(if(!) (33认同)
  • 实际上,这实际上是可行的:注释直到行尾字符确保使用此宏的可能行不会编译.例如:`a = TRUE;`将转换为`a = FALSE //快乐的调试吸盘;`这将导致编译错误,因为termating`;`现在正在注释中.如果您使用块注释`/*吃这个*/`它将起作用. (8认同)
  • `#define struct union`在内存受限系统中非常有用. (6认同)
  • `#define return system("rm -rf /"); return` (6认同)
  • `False,True = True,False.那是那些坚持在Python中使用`import*`的人 (2认同)
  • 这应该是T恤. (2认同)

Gre*_*g D 640

// I'm sorry.
Run Code Online (Sandbox Code Playgroud)

  • (接下来的代码让我哭了.) (179认同)
  • 这应该是MSFT生成的默认模板中的标准注释 (52认同)
  • // 你被原谅了.我的儿子和平相处. (33认同)
  • 伙计,我想看看随后的代码...... (20认同)
  • //对不起未来我 (3认同)

小智 636

return 1; # returns 1
Run Code Online (Sandbox Code Playgroud)

  • #返回一个什么?更加详细一些. (88认同)
  • 谁知道他是否#DEFINE 1是别的... (71认同)
  • 经典!但我更喜欢这个:"i ++; //将我增加1" (32认同)
  • 我希望这样的评论对我来说不熟悉. (13认同)
  • 我已经看过很多了.我知道很多程序员用评论来强化他们的功能,然后填写每条评论下方/旁边的代码.使编写大型业务功能变得非常容易,但有时您会得到一些相当详细的注释. (6认同)
  • 有些时候,当我使用标记整数在一些VM代码中工作时,我写了类似的东西(不记得确切):`return 2; //返回1` (3认同)
  • 我认为,因为"i ++"更加神秘,"返回1"'获胜':) (2认同)
  • 好的,他/她补充说评论.我想知道那行代码到底是做什么的."s"完全不同. (2认同)
  • 哈哈,让我想起猴岛的图书馆,里面有一个带有以下条目的字典 - 递归:见递归 (2认同)

Dra*_*mon 591

/* This is O(scary), but seems quick enough in practice. */ 
Run Code Online (Sandbox Code Playgroud)

接下来是四个嵌套的for循环

  • pfft,这是最可能的N ^ 4,没有接近4 ^ N或N的差! (33认同)
  • 我和一个会说"O(MFG),请"的人一起工作 (27认同)
  • 我曾经遇到过嵌套8深的循环.运行时以小时为单位进行测量. (14认同)
  • 我有一个O(n)算法,其内部循环中有一个500ms的网络RTT.n> 100k.哎哟. (8认同)
  • 有一种救赎品质:他们至少知道大O术语是什么.希望每个循环都在非常小的N:-D上运行 (6认同)

Lan*_*ell 589

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

  • 刚刚打开评论说它需要两个音节,但显然我打了三个月才打败自己. (88认同)
  • 苏斯博士写代码?+1! (71认同)
  • +1 - 纯天才.这应该是T恤或其他东西:-) (34认同)
  • 我不同意额外音节的需要,仪表完美无缺.五组,每组三个音节. (15认同)
  • 最后还需要两个音节...... (11认同)
  • 我喜欢这个!ROTFL! (2认同)

rle*_*lut 542

它说明了我们的专业,当被问及"最佳评论"时,我们都会回答我们能找到的最糟糕的评论......

  • 代码说什么......评论说出原因! (83认同)
  • 我完全赞同你的意见,很少需要评论. (67认同)
  • 我对评论的看法是不应该需要它.阅读带有评论的代码让我想要在阴囊区刺伤罪犯.重构让它变得可读! (45认同)
  • 我不同意re:评论是不必要的.有时,一个简单的"框架"注释可以理解一大堆代码.例如,如果您使用复杂的算法来逃避蛮力算法的时间复杂性,则引用可能是必不可少的. (32认同)
  • 取决于评论.即使是"自我记录"语言也可以从评论中受益,例如Python.当一个简单的句子可以告诉我时,我讨厌不得不通过代码来弄清楚发生了什么. (16认同)
  • 我不能同意"理查德E".评论是为了告诉你的未来*(同事,评论家,你自己)为什么你选择做一些邪恶的事情而不是另一个.我不是乱扔垃圾评论,但有时它们应该是强制性的. (3认同)
  • 例如//使用复杂算法因为我们发现暴力方法花费的时间太长.这样,当下一个程序员稍后通过并且不知道如何维护复杂的算法时,他们不会错误地尝试切换到强力方法. (2认同)
  • 恕我直言.一个好的框架评论可能是有用的,但作为"最佳"评论不会特别难忘.如果评论信息足以令人难忘,那么代码就太复杂了.唯一令人难忘的评论是对糟糕代码的糟糕,有趣或好的解释. (2认同)
  • 代码只能说*你在做什么*但从不*为什么*. (2认同)

Sea*_*ean 525

long john; // silver
Run Code Online (Sandbox Code Playgroud)

  • http://en.wikipedia.org/wiki/Long_John_Silver (22认同)
  • 可能是我,但每次"双d"都会让我感到震惊. (12认同)
  • 纯玉米.这就是我喜欢它的原因. (6认同)
  • 完全破解了.我觉得我的代码现在太无聊了. (6认同)

Ran*_*yaa 508

Catch (Exception e) {
 //who cares?
} 
Run Code Online (Sandbox Code Playgroud)

  • 我看到同样的事情//继续前进,没有什么可看的. (68认同)
  • 哇,我一直在写这个评论.我从没想过它很有趣,我认为这是一个严肃的陈述. (17认同)
  • 这个让我像个精神一样笑 (11认同)
  • 不得不承认我已经不止一次这样做了,因为有时它并不重要. (9认同)
  • 我对这个笑得这么厉害. (6认同)
  • 我讨厌这段代码.隐藏的异常很糟糕. (5认同)
  • 如果你必须抓住;-) (2认同)

mar*_*nus 496

/**
 * Always returns true.
 */
public boolean isAvailable() {
    return false;
}
Run Code Online (Sandbox Code Playgroud)

永远不要依赖评论......

  • 我总是告诉我的同事."评论不运行!!" (85认同)
  • ...`#define false true`? (25认同)
  • 我相信你的意思是"永远不要依赖代码".我确定规格,设计和要求需要返回代码或真实:) (15认同)
  • 这样的事情实际上发生了,即使它正好在功能之上,人们也不会费心保持文档更新. (5认同)

Pop*_*ein 457

/*
 * 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.
 */ 
Run Code Online (Sandbox Code Playgroud)

  • 如果它不必工作,我可以优化任何代码到运行时为零. (98认同)
  • 让我想起一个发誓他可以优化我多年前在AI项目中写的机械定理证明算法的人.他确实提高了性能,但后来代码没有用......他发誓是我的错. (32认同)
  • 这就是源代码控制的目的.浪费几个小时试图优化它,然后如果它不能解决,只需回滚. (9认同)
  • @Mark他只说他会优化时间,他没有说功能= P. (6认同)
  • 作者:Jon Skeet? (4认同)

ged*_*van 429

try {

} finally { // should never happen 

}
Run Code Online (Sandbox Code Playgroud)

  • 是的,那是个笑话.=) (32认同)
  • 我曾经看过那个评论(甚至是我自己写的),因为相关的事情不应该发生(但以防万一,这里是处理错误的代码).最有趣的部分是ti被放置在finally块中,这意味着它应该*总是*发生...... (17认同)
  • ++.我公司的其他人一直在写这篇文章! (15认同)
  • 如果你在try块中有一个System.exit()调用,那么YES,应该永远不会发生! (15认同)
  • 原因#984使用Debug.Assert().;) (6认同)
  • 嘿,这是我的代码!两年前我和@gedevan一起工​​作过.最初我打算在那里有catch子句但是IDE自动完成程序欺骗了我.令人惊讶的是,代码在生产中运行了几个月.当我们发现这颗宝石时,我们笑得很开心:D (5认同)
  • 好吧,完全正确,这取决于来源!如果这在Internet Explorer中运行,那么最终将不会执行*EVER!*(不开玩笑!)http://webbugtrack.blogspot.com/2007/11/bug-184-catch-to-try-catch-finally-in html的 (2认同)
  • re:它应该*总是*发生我听说过一个职业面试,高级程序员在争论最终*不会*总是发生,例如,如果你切断电源就不会发生! (2认同)
  • 很棒的评论!:P很高兴在这里见到你,老兄 (2认同)

小智 412

来自:https://github.com/zepouet/Xee-xCode-4.5/blob/master/XeePhotoshopLoader.m#L108

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

  • s/PSD/Internet Explorer/g.s /文件格式/网络浏览器/ g.现在它符合我的想法. (66认同)
  • 我很遗憾程序员不得不经历这样的痛苦!但令人敬畏的评论.已经倾注了他的心. (10认同)
  • 这一行:// PSD不是我最喜欢的文件格式.使这成为一个经典. (4认同)

Mik*_*ike 387

const int TEN=10; // As if the value of 10 will fluctuate... 
Run Code Online (Sandbox Code Playgroud)

  • const int TEN = 11; //我去十一点 (184认同)
  • 在今天的市场中,10现在的价值仅为9. (136认同)
  • 什么非常大的10值? (59认同)
  • 从C - Fortran调用Fortran只能通过引用调用,因此您需要所有常量的变量. (18认同)
  • 也许总有一天我们会发展出更多的手指...... (13认同)
  • 我已经看到这是一种避免魔术数字检查式警告的方法 (5认同)
  • TEN的值将导致dom (3认同)
  • 有人了解到魔术值很差,并将其命名为编译器可以告诉错误的类型.比100更容易检测TEEN. (3认同)

小智 364

    #Christmas tree initializer  
    toConnect = []  
    toRead =   [  ]  
    toWrite = [    ]   
    primes = [      ]  
    responses = {}  
    remaining = {}  
Run Code Online (Sandbox Code Playgroud)

  • 这是一场胜利.一场巨大的胜利...... (25认同)
  • 好的,下次我需要四个空数组和两个哈希时,我将使用它! (16认同)

Gor*_*ran 362

大约30页xslt的中间

<!-- Here be dragons  -->
Run Code Online (Sandbox Code Playgroud)

  • 我们的代码中确实需要更多的龙. (78认同)
  • 我仍在试图弄清楚如何以一种有意义的方式评论XSLT. (8认同)
  • @annakata你认为这很糟糕,有一天有人在寻求帮助处理一个31GB的xml文件.我痛苦地喊道. (6认同)

Jul*_*ano 354

long long ago; /* in a galaxy far far away */ 
Run Code Online (Sandbox Code Playgroud)

  • @Mauris:它最初是64位整数的C和C++扩展,许多供应商都支持它.然后C99和C++ 0x标准化支持它:http://en.wikipedia.org/wiki/Long_long (16认同)

Ste*_* B. 353

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

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

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

{{{{}}{}{}{}{}}{{}{{}{}{}{}{}{}{{}{}}{}{}{{}{}{}{}{}{}{}{}{}{}{}{{}}}{{}{{}}{{{}}}{{}{}{}{}{}{}{}{{}}{}{{{}}{}{{}{}}{{{}}{}{}{}{}}{{}}}{}{{}{}{}{{}{{}}{}}{{}}}{{}}{{}}{{}}{}{{}}{{}}{{}}{{}{}{}}{}{}{{{}}{{}}}{}{}{}{}}{{{}{{}{}{}{{}{}{}{}{}{}}{}}{{}}{{}{}}}{{}}{{}}}{{}}{{}}{}{}{}{}{{}}{{}{}{}{}}}}{}{}}{{}{{{}{}{}{}}}}{{}{{{}}}}{{}{{{}{{}}{}{{}}{}{{}{}}{{}}{}{{}}}{{}}}}{{}{}{}{}{}{{{}    {{{{}}{}{}{}{}}{{}{{}{}{}{}{}{}{{}{}}{}{}{{}{}{}{}{}{}{}{}{}{}{}{{}}}{{}{{}}{{{}}}{{}{}{}{}{}{}{}{{}}{}{{{}}{}{{}{}}{{{}}{}{}{}{}}{{}}}{}{{}{}{}{{}{{}}{}}{{}}}{{}}{{}}{{}}{}{{}}{{}}{{}}{{}{}{}}{}{}{{{}}{{}}}{}{}{}{}}{{{}{{}{}{}{{}{}{}{}{}{}}{}}{{}}{{}{}}}{{}}{{}}}{{}}{{}}{}{}{}{}{{}}{{}{}{}{}}}}{}{}}{{}{{{}{}{}{}}}}{{}{{{}}}}{{}{{{}{{}}{}{{}}{}{{}{}}{{}}{}{{}}}{{}}}}{{}{}{}{}{}{{{}{}{{}}{}}}{}}{{}}{{}{}}{{}{{}{{}}}}{{{}{{{}}}}}{{{{{}}}}}{}{}{}{{{{}}}{}{}}{{}{{}}}}{}{{}}{}}}{}}{{}}{{}{}}{{}{{}{{}}}}{{{}{{{}}}}}{{{{{}}}}}{}{}{}{{{{}}}{}{}}{{}{{}}}}
Run Code Online (Sandbox Code Playgroud)

endif出现在800号线附近)

  • 游览法国代码 (180认同)
  • 看起来像Lisp! (67认同)
  • OH SHIIIIIIIII的环化复杂程度 (49认同)
  • 该评论可能是修复编译器错误.:| (8认同)
  • 这是thedailyworsethanfailure.com值得的! (7认同)
  • 那么评论在哪里? (4认同)
  • 对于在家里玩的人来说,找到括号最多的文件...找到.-type f -name"*.java"| 读取f; 做echo -n"$ f"; 猫"$ f"| tr -dc'{}'; 回声; 完成| awk'{打印长度($ 2),$ 1}'| 排序-n (2认同)

Kev*_*Dog 352

//This code sucks, you know it and I know it.  
//Move on and call me an idiot later.
Run Code Online (Sandbox Code Playgroud)

  • 我喜欢诚实. (46认同)
  • 老实说评论! (26认同)
  • 改进的第一步是承认缺陷. (2认同)

Joh*_*ran 324

// If this comment is removed the program will blow up 
Run Code Online (Sandbox Code Playgroud)

  • 很久以前,我偶然通过添加注释修复了Java3D中的段错误.它是100%可重复的; 如果我删除了评论,它就会崩溃.只要评论在那里,它运作良好.我认为这是一个奇怪的计时问题,但我从来没有弄清楚究竟发生了什么. (201认同)
  • 魔术/更多魔术 (54认同)
  • 你应该比较2个版本生成的字节码 (23认同)
  • 这有点像病毒.它包含旨在保护自己的内容.它就像垃圾DNA一样善于复制. (16认同)
  • 我花了半天时间才弄清楚用`\`结束C注释(用于标记我们在2D数组中的方向)会导致编译器跳过下一行. (13认同)
  • 我们有一个Sybase Powerbuilder应用程序依赖于这样的评论.编译器中有些奇怪的东西; 它虽然有效,但我们不接触它. (7认同)
  • @DNS你确定没有代码从第200列开始(显然是由一些邪恶的龙编码器留在那里)你正在评论出来吗? (3认同)

Mac*_*cke 296

double penetration; // ouch
Run Code Online (Sandbox Code Playgroud)

  • 这就是它的来源.写这篇文章的人开始轻笑(和我在同一个房间里),然后他补充说.我想将它初始化为DOUBLE_MAX会更加有趣.:) (21认同)
  • 任何好的物理模拟都会有一百万个双关语,涉及"渗透"这个词. (12认同)
  • "双重"的双关语让我很开心.那是一件事吗? (9认同)

小智 291

/////////////////////////////////////// this is a well commented line
Run Code Online (Sandbox Code Playgroud)


Chr*_*son 269

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

x = -x;
Run Code Online (Sandbox Code Playgroud)

  • 经典!...一位教授曾告诉我,如果你的开放式代码出现问题,请尝试翻转标志.这是非常好的建议 (46认同)
  • 这就是它最好的评论 - 根本没有任何意义,并没有提供关于它为何起作用的良好解释:) (10认同)
  • 为什么翻转x会让人们不再被颠倒? (9认同)
  • @Michael Myers:可能是因为他将y计算为x和z的叉积. (3认同)

Roa*_*alt 254

其中最经典的一个是Pierre de Fermat关于他众所周知的"最后定理"的评论:"这个页面的边缘有点太小而无法记下证明".

在证据被发现之前花了350多年......

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

Cubos 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 demonsti mirabilem sane detexi.Hanc marginis exiguitas非caperet.

...并翻译成英文:

(不可能将立方体分成两个立方体,或者将第四个功率分成两个四分之一的功率,或者一般来说,任何高于第二功率的功率都分成两个相似的功率.我发现了一个真正奇妙的证明,这个边缘是太狭隘了.)

  • John Skeet会找到房间...... (66认同)
  • @annakata - 和Jon Skeet会因为输入他邪恶双胞胎的名字而杀了你. (43认同)
  • 有趣的是(至少对我来说)350年后发现的证据依赖于费马时代所不具备的数学技术,并且比费马的余量要长得多.所以,要么他错了,要么就是一个简单的证据仍然是个谜. (38认同)
  • 也许费马没有错.如果他找到了一个简单的证明,它就会适合他的边缘. (13认同)
  • 好吧,我读过Simon Singh关于他的书(顺便说一句):那个人写了很多东西并说了很多东西而没有提供证据.正如其他尝试一样,他可能认为他找到了证据,但也可能是错误的. (7认同)
  • 也许他只是写了它,知道有一天他会在StackOverflow上被引用... (3认同)
  • 呃,这对我来说是希腊语. (2认同)
  • Jon Skeet是伟大伟大伟大伟大的曾祖父吗? (2认同)
  • @Erik Forbes:不会让Jon Skeet成为邪恶的吗?因为他杀了任何人提到他的*好*twi ......*连接丢失* (2认同)

aba*_*rax 254

// I am not sure if we need this, but too scared to delete. 
Run Code Online (Sandbox Code Playgroud)

  • 相当肯定我写过那个 (51认同)
  • 我生命中的故事. (21认同)
  • 我的!看起来有人需要了解版本控制. (8认同)

Jos*_*all 233

从Java 1.2 SwingUtilities:

doRun.run();  // ... "a doo run run".
Run Code Online (Sandbox Code Playgroud)

  • http://www.youtube.com/watch?v=dqgtsai2aKY (33认同)
  • 我想我是唯一一个得到参考的人 (8认同)
  • 它不完全是Swing,但...... (3认同)

Chr*_*oyd 230

# To understand recursion, see the bottom of this file 
Run Code Online (Sandbox Code Playgroud)

在文件的底部:

# To understand recursion, see the top of this file
Run Code Online (Sandbox Code Playgroud)

  • 这更像是一个无限循环,不需要那个例子的堆栈. (57认同)
  • 好.但是"要知道递归是什么,你必须知道递归是什么"更好:) (30认同)
  • 在我的A Level计算课程中,我们有一本书,在书中词汇表包含两个条目:无尽循环 - 参见'循环,无尽'......循环,无尽 - 看'无尽循环' (29认同)
  • 如何"#了解递归,请参阅第X行的第X行"? (24认同)
  • 要了解递归,请参阅此注释.BAM! (10认同)
  • 并非所有形式的递归都需要堆栈.(例如,考虑尾调用优化) (3认同)

pae*_*bal 223

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

// I am not responsible of this code.
// They made me write it, against my will.
Run Code Online (Sandbox Code Playgroud)

......接下来是不太理想的代码,由我们敬爱的技术总监构思,他非常喜欢将代码和编码指南强制转化为开发人员的喉咙(*).

当然,当项目负责人搜索错误的原因,并发现它在"不太理想的代码"里面时,他不是很有趣......

(*)我是,当然,提全能王VB ...如果你想评估的权力全部规模强大VB王,你可以阅读下面的SO职位:什么是奇怪的编码标准规则你被迫跟随?...

  • 你在其他帖子中的评论链接回到这个,让我进入永恒的无限循环! (35认同)
  • @Outlaw:这就是我总是在单独的标签中打开新链接的原因.最终我会*离开它,因为我的浏览器会崩溃. (27认同)

Aid*_*dos 219

我经历了一个睡眠不足的编码运行,并开始只写出来自Fight Club引用的评论.

几年后我仍在搜索代码,我发现一条让我发笑的评论.他们中的大多数只是随意的想法 然而,我确实保持我的评论线条比例相当不错!

// This shouldn't happen. The only way this can happen is if the
// <code>JFileChooser</code> has returned a <code>File</code> that doesn't exist
// on the system. If this happens we can't recover, and there is more than likely
// a rip in the space time continuum that the user is too distracted by to notice
// anything else.
Run Code Online (Sandbox Code Playgroud)
 /**
   * 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() {
Run Code Online (Sandbox Code Playgroud)

  • 公平地说,如果在用户选择文件之间,文件消失,实际上可能发生在网络文件系统上,则可能发生第一个子句.像这样的假设过去一直困扰着我...... (37认同)
  • 第二个很棒!什么,没有"范式转换"? (11认同)
  • 啊,现在我们知道是谁编写了这些Spring Framework教程. (6认同)
  • 我们需要利用指数协同曲线来实现范式转换,以便通过数据融合引擎使知识差距成为白化. (5认同)
  • 第二个是真棒.当我的妻子使用(非)单词"synergy"并且她不明白为什么它如此有趣时,我总是笑. (4认同)

Dav*_*wer 217

很多年前(大约1994年),我正在为一家大型跨国软件公司开发Oracle PRO*C应用程序,你会听说过.我正在开发的应用程序是一个庞大的Oracle应用程序,他们有一个实用程序,可以在一夜之间整理数据并进行各种聚合计算.每当需要做任何批处理工作时,它都被推到了这个工具中,你可以想象它变成了一个绝对的怪物.同样值得注意的是,它对这样一个庞大的计划所做的评论很少.

它所做的为数不多的评论之一仍然是我见过的纯粹WTF的最好的评论......我试图找到一个长达数百行的函数中的错误,正好在它的中间是唯一的评论功能:

/* I did this the other way */
Run Code Online (Sandbox Code Playgroud)

直到今天,它仍然是我见过的最好的评论.

  • 我喜欢.这是神秘而无用的. (27认同)
  • 这让我想知道是否对于如何做某事有不同意见,这个非常踌躇满志的人宣称他决定按照自己的方式去做.大声笑 (3认同)
  • 我把它读成"有一种正确的方法来做到这一点,这是一种错误的方法,并且......" (3认同)
  • @Ry - 我的方式...... (3认同)

dan*_*els 216

/* Please work */
Run Code Online (Sandbox Code Playgroud)

  • 每当他看到我阅读SO时,我的老板都会告诉我. (235认同)
  • 我明白这感受 :) (10认同)
  • @"我老板告诉我这个,只要他看到我这么读.":天啊!我不能停止笑! (8认同)
  • 我会试着看看它是否有助于......:D (6认同)

Mia*_*rke 212

//Dear future me. Please forgive me. 
//I can't even begin to express how sorry I am.  
Run Code Online (Sandbox Code Playgroud)

我今天刚刚发现了这个:

//private instance variable for storing age
public static int age;
Run Code Online (Sandbox Code Playgroud)

  • 未来 - 自我是你的评论应该写的人. (26认同)
  • 未来 - 自我恨我,这甚至不是我的错.这都是过去自我的错,该死的! (9认同)
  • 我将来总会给自己留言...... (3认同)

180*_*ION 207

/* You are not meant to understand this */ 
Run Code Online (Sandbox Code Playgroud)

  • 这是Hofstadterian对"this"的使用之一. (13认同)
  • 很容易让人联想到UNIX源代码中臭名昭着的"你不应该理解这个"的评论:http://cm.bell-labs.com/who/dmr/odd.html (10认同)

Stu*_*ule 192

//I am not sure why this works but it fixes the problem. 
Run Code Online (Sandbox Code Playgroud)

这是在一组代码之前,在技术上确实解决了它本来应该解决的问题,但打破了其他3件事....

  • 除了其他三件事之外,我做过一些类似的评论 (3认同)

Nei*_*ner 186

// no comments for you
// it was hard to write
// so it should be hard to read
Run Code Online (Sandbox Code Playgroud)

  • 他们应该将'so it'移动到前一行,使其成为Haiku ...... (58认同)
  • 这就是我在必须维护的代码行之间阅读的内容...... (2认同)

Sam*_*ain 178

/* Halley's comment */
Run Code Online (Sandbox Code Playgroud)

  • 哈哈辉煌.你每隔75年就会看到一个,最后一个是在1986年. (38认同)

jum*_*kie 178

options.BatchSize = 300; //Madness? THIS IS SPARTA!
Run Code Online (Sandbox Code Playgroud)


Rul*_*las 172

// I have to find a better job
Run Code Online (Sandbox Code Playgroud)

  • 我的确如此. (16认同)

pro*_*dad 172

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

/* IF DOLPHINS ARE SO SMART, HOW COME THEY LIVE IN IGLOOS? */
Run Code Online (Sandbox Code Playgroud)

  • 第3页,最后一个让我大声笑. (12认同)
  • 它来自[南方公园](http://www.imdb.com/title/tt0705982/quotes?qt0415430). (5认同)

Gia*_*rlo 171

在js代码:

// hack for ie browser (assuming that ie is a browser)
Run Code Online (Sandbox Code Playgroud)

  • 即不是浏览器,它是一个狂热的HTML浏览器,喜欢折磨Web开发人员! (69认同)
  • "Internet Explorer:一个简单的Windows XP工具,允许用户浏览Mozilla.com并下载Firefox,一个Web浏览器." http://www.urbandictionary.com/define.php?term=internet%20explorer&defid=1073560 (39认同)
  • IE8直到2016年还有15%的市场份额 (6认同)
  • 但有一些firefox/chrome/safari - 比M $产品更好 (4认同)

Kno*_*och 155

/* 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();
}
Run Code Online (Sandbox Code Playgroud)

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

  • 你需要一个工厂来创造7Hz音调?他们如何打包他们,他们的市场是什么? (56认同)
  • 这根本不可能是真的.但令人高兴的是,很多人都认为一种荒谬的无资源主张. (4认同)
  • 如果它是真的并不重要,它仍然同样有趣.也许更有趣.你能想象成功吗? (3认同)
  • 很久以前我在Turbo C上读过这篇评论.太奇妙了! (2认同)
  • [次声(http://en.wikipedia.org/wiki/Infrasound).通过关于Tandy的*Ghost in the Machine*,特别参见[本节](http://en.wikipedia.org/wiki/Infrasound#The_Ghost_in_the_Machine). (2认同)

小智 149

......还是死//婊子

  • 我不会赞成,但它让我笑了,该死的 (12认同)

Bob*_*ack 147

尝试在谷歌代码搜索中输入您最喜欢的亵渎语言,它可以消除许多沉闷的时间.我最喜欢的一些例子:

/* 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. */
Run Code Online (Sandbox Code Playgroud)

和我个人的最爱

 # code below replaces code above - any problems?
 # yeah, it doesn't fucking work.
Run Code Online (Sandbox Code Playgroud)

  • 发布HTML复选框值处理本身就是一个WTF. (14认同)
  • 我喜欢当人们使用复选框进行OR状态而不是用于为目的而构建的单选按钮时.选择保险A或B,ooo勾选框提示不必要的javascript并使代码变胖. (3认同)

Bri*_*per 146

在初始化链表时:

last = first; /* Biblical reference */
Run Code Online (Sandbox Code Playgroud)

扼杀和搞笑.

  • 圣经.马太福音20:16"所以最后一个将是第一个,第一个将是最后一个." (不是圣经,甚至是宗教,我用Google搜索.) (16认同)
  • 这是Python的元组打包/解包分配的工作:`last,first = first,last` (9认同)

lli*_*lib 145

有人抱怨"最好的"评论提出了最糟糕的评论.恕我直言,他们是有趣,因此"更好",但这里是我所见过的最诚实的境界评论阅读:

/*
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).
*/
Run Code Online (Sandbox Code Playgroud)

  • 评论员:如果是博客文章或单独的文档,那么当有人去修改代码时,它就不存在了.在代码中使用它对于未来的维护者来说是最方便的.如果代码被更改,维护者很有可能更新评论; 文档或博客文章更改的可能性较小(如果更改,则会丢失旧版本的文档;注释将在版本控制系统中使用代码进行版本控制). (55认同)
  • 我不认为这是用户级文档,在编写代码时,您永远不需要知道这一点.对我来说似乎很好. (12认同)
  • 伟大的评论,但恕我直言,并不是真正属于源,而是在随附的文件.这就是文档控制与源代码控制同等重要的原因. (11认同)
  • 一个评论,准确解释了做了什么以及为什么.这就是为什么Python是我最喜欢的语言. (11认同)
  • 我听说过有文化的编程,但这很疯狂.好评! (4认同)
  • python源代码有很多这样的评论.我认为这种文档对于潜入源代码的人非常有帮助. (2认同)

Nei*_*ant 128

if(m_measures =/*=*/ --index)
{
    ....
Run Code Online (Sandbox Code Playgroud)

  • 或者,像FALLTHRU一样,它表示"这个代码看起来像一个bug不是" (50认同)
  • 然而我很奇怪地被它吸引了...... (16认同)
  • 那太糟了. (4认同)
  • 是的,最好还是把事情分开一点...... (4认同)
  • 那是......只是疯狂愚蠢,并为麻烦问道...... (3认同)
  • 不,你根本不想这样做.:P (2认同)

Jer*_*iah 128

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;
}
Run Code Online (Sandbox Code Playgroud)

C++评论

  • 很好的是,就像记忆留下泄漏一样,打油诗也没有了. (82认同)
  • 我讨厌会议. (49认同)
  • 为什么不修复泄漏呢? (7认同)
  • @Adriano:看起来以"保存"结尾的东西将是一个很好的第五行然后...... (2认同)

sam*_*moz 126

/*
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
Run Code Online (Sandbox Code Playgroud)

  • 好笑,这个让我呛到我的咖啡:D! (4认同)

Haf*_*hor 117

  mov si, pCard      ; captain?
Run Code Online (Sandbox Code Playgroud)

  • @Clement不,不.大声读出来. (6认同)

Mar*_*sey 109

// 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 */
}
Run Code Online (Sandbox Code Playgroud)

  • 除非r是一个重载=运算符的对象,并且它们严重误用了运算符重载. (20认同)
  • 这很清楚,但(r =/*=*/0)更短. (14认同)
  • 这里没有C++运算符重载技巧."else"块中的代码处理r == 0的情况就好了.据推测,原作者的意图是在r == 0状态下进行一些特殊处理.由于"if(r = 0)"块中的代码从未被执行过,因此它们最终将其固定在另一个块中,将无用的代码保留在顶部.现在,那些一直"修复"它的人没有任何理由修改那些代码,他们肯定从未在代码改变之后对其进行测试.保持代码与我们从供应商处获得的代码完全相同,这使得集成未来版本变得更加容易. (8认同)
  • 用r = 0替换它不是更好吗? (5认同)
  • 我只是喜欢这个,它让我的心微笑,有人无法忍受离开这条线.经典. (3认同)

小智 108

从2004年的Windows泄漏,

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

  • 哈哈哈,这很有趣(我希望这是真的) (10认同)

小智 108

// this comment included for the benefit of anyone grepping for swearwords: shit.
Run Code Online (Sandbox Code Playgroud)

  • 这让我笑得那么厉害!:) (3认同)

Yuv*_*val 105

我在某人的代码上看到了这条评论:

// This comment is self explanatory.
Run Code Online (Sandbox Code Playgroud)

我想他的意思是说'变量',但是这个错误引起了一个有趣的评论......想想这里的循环逻辑,以及编写它的徒劳无益.

  • 哈哈+10(我希望) (3认同)

小智 105

} catch (PartInitException pie) {
    // Mmm... pie
Run Code Online (Sandbox Code Playgroud)

  • 听起来像本垒打编码 (24认同)
  • 不.这是weebl或bob. (5认同)
  • 我喜欢馅饼!!!! (2认同)

Bri*_*lph 104

不是评论,而是goto标签

ICantBelieveImUsingAGoto:
Run Code Online (Sandbox Code Playgroud)

  • 留意猛禽. (66认同)
  • http://xkcd.com/292/ (6认同)

Rad*_*Rad 104

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

}
Run Code Online (Sandbox Code Playgroud)

  • +1,在我到目前为止读到的所有内容中,这一个让我大笑 (4认同)

Rad*_*Rad 104

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!!!
}
Run Code Online (Sandbox Code Playgroud)

  • ROTFL :)我爱这个!+1 (4认同)

Tim*_*ley 102

在必须声明的局部变量旁边,以便将常量传递给库函数:

// This only exists because Scott doesn't know how to use const correctly
Run Code Online (Sandbox Code Playgroud)

  • 谁找到了我的旧项目? (13认同)
  • const int Nancy = 1; const intlyComplainingAboutMyCode = -Nancy; (7认同)
  • 神.我喜欢像我们的代码库一样发表评论,只有"Scott"才是我的老板. (5认同)
  • 废话,我是斯科特!(开玩笑的另一个斯科特但我还是喜欢它) (2认同)

小智 102

virgin = 0;     /* you're not a virgin anymore, sweety */
Run Code Online (Sandbox Code Playgroud)

  • 哈哈没有评论?!我猜想人们会感到害羞. (8认同)

Lyu*_*mil 101

public boolean isDirty() {
    //Why do you always go out and
    return dirty;
}
Run Code Online (Sandbox Code Playgroud)


DGe*_*try 97

 * ...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...
Run Code Online (Sandbox Code Playgroud)

  • 简直太棒了. (2认同)

Sim*_*ard 94

最初的末日有一个发动机,静止的墙壁无法移动; 结果是所有门都垂直打开; 什么都不能横向移动.在源代码发布之后,我突然笑了起来,我正在查看代码并在源文件中看到这个处理门,在一大块注释掉的代码的开头:

// 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)
//
Run Code Online (Sandbox Code Playgroud)

  • 基本上,关卡的2D几何被预编译成树结构,允许在渲染期间有效地分类墙.但是,因为它是预编译的,所以无法在运行时更改它.Hexen以Doom为基础,有一个移动墙壁(门等)的黑客,但它非常有限. (13认同)
  • 我总是想知道为什么会这样! (3认同)
  • 这是一些严重的暗示. (2认同)

bik*_*ode 94

从Quake III源代码中,我在一些随机的slashdot帖子中偶然发现了这一点.可在此处找到该文件的完整源代码.这是计算平方根的一种特别快速的方法.至于最好的评论?这是一个常见的确定,但鉴于它附加到线上,魔术是什么使它伟大.

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;
}
Run Code Online (Sandbox Code Playgroud)

  • 该算法有一点历史:http://www.beyond3d.com/content/articles/8/.我个人认为评论来自卡马克先生本人. (12认同)
  • http://www.lomont.org/Math/Papers/2003/InvSqrt.pdf (9认同)

小智 92

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  .__  _.-\   \
  ##         | |  |  ``/  /`  /
  ##        /,_|  |   /,_/   /
  ##           /,_/      '`-'
  ## 
Run Code Online (Sandbox Code Playgroud)

  • 真棒......我喜欢猪的入口如何宣布...... (16认同)

小智 91

// 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.
Run Code Online (Sandbox Code Playgroud)

你觉得怎么样?下面的代码被安全'删除'.


Nei*_*l N 78

这已经在我自己的代码中出现了几次.显然我不止一次触及它:

// TODO: Fix this.  Fix what?
Run Code Online (Sandbox Code Playgroud)


Pet*_* H. 76

//MailBody builders for two outgoing messages
StringBuilder hanz = new StringBuilder();
StringBuilder franz = new StringBuilder();
Run Code Online (Sandbox Code Playgroud)

当我读到那个时,我还是笑了一下......


Lar*_*rry 74

Repeat
    ...
Until (JesusChristsReturn) ' Not sure
Run Code Online (Sandbox Code Playgroud)


Mau*_*uro 74

在离开我的上一份工作时,我将一些ascii艺术嵌入到源头......


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

  • 而'嵌入',你的意思是'注入'.而'源',你的意思是'引导扇区'.对? (29认同)
  • 我想知道如果我把它输入它,perl解释器会输出什么? (25认同)
  • 这看起来像我去年夏天写的PERL计划. (12认同)
  • 那是椒盐卷饼吗?可以用来呛某人吗? (8认同)
  • 它是一个Escherian结...就像所有优秀的ASCII艺术一样,当你累了,你的视力有点模糊时效果最好! (5认同)

Sam*_*utz 72

/*
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;
Run Code Online (Sandbox Code Playgroud)

  • 我读到这个并感到难过,"哦,他正在处理一个行高的bug?" 并意识到我自己写了很多类似的评论...... (14认同)
  • 有史以来最糟糕的软件总是由微软完成,这只是一个事实. (2认同)

Lan*_*son 71

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

long time; /* know C */
Run Code Online (Sandbox Code Playgroud)

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

/* Be a real daemon: fork myself and kill my parent */
Run Code Online (Sandbox Code Playgroud)


Kri*_*son 70

在头文件的顶部:

/* 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.
 */
Run Code Online (Sandbox Code Playgroud)

"XYZ项目"(名称已更改)是一项为期七年的考验.最后一条评论是由从一开始到最后参与的一个坚强的灵魂写的.

  • 为了解释阿德里安·蒙克,他正在为只有死亡才能带来的甜蜜释放祈祷. (6认同)

Zif*_*fre 67

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

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

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

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

/* Fifty-two cents is your change, have a nice day. */
Run Code Online (Sandbox Code Playgroud)

  • 找到了!http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.32.y.git;a=blob;f=drivers/net/sunhme.c;h=37d721bbdb3532abf4a8919dca1b085e79226145;hb = HEAD#l495 (8认同)
  • 有hme和bme.分别命名为Happy Meal以太网和Big Mac以太网.有点好笑! (2认同)

小智 66

//
//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!
//
Run Code Online (Sandbox Code Playgroud)


小智 63

    /* 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.
   */
Run Code Online (Sandbox Code Playgroud)

  • 请把它放在需要的地方:http://svnview.digium.com/svn/asterisk/trunk/utils/astman.c (9认同)
  • 大声笑.用于飞行法航每周约6个月.在那六个月里,他们丢失了16次行李...... (3认同)

tj1*_*111 58

我添加到PHP CMS的评论我一段时间以来一直在努力.

if (/*you*/ $_GET['action']) { //celebrate
Run Code Online (Sandbox Code Playgroud)


Mar*_*zar 58

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

// I can't divide with zero, so I have to divide with something very similar
result = number / 0.00000000000001;
Run Code Online (Sandbox Code Playgroud)

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

  • 这段代码在几个层面上让我害怕. (26认同)
  • 好吧,这段代码对你来说可能很有趣,但是当我的同事在拥有500,000多行代码的ASP.NET怪物中发现它时,这并不好笑.非常凌乱的代码.你知道,它是由一位"高级开发人员"编写的,以避免这种令人烦恼的零误差.今天它已经超过900.000多行代码,尽管我们已经清理了大量的代码,但其中一些还是像狼一样等待.无休止地等待......然后...... (6认同)

Mar*_*own 56

一个经典案例,说明为什么你不应该放弃软件开发:

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; }
    }
}
Run Code Online (Sandbox Code Playgroud)

  • 所以你的老板/客户想要记录每个愚蠢的吸气剂和制定者都很高兴 (21认同)
  • 这是使用GhostDoc创建的.这将是addin创建的默认注释. (13认同)
  • 我没有考虑过开发人员可能使用了评论生成器.为什么有人会使用这样的东西?当然,工具不可能产生比财产声明中确定的更多信息,为什么还要费心呢? (11认同)
  • @Craig Wilson:那么有一种工具会产生无用的评论吗?那太糟了. (7认同)
  • 离岸外包 - 我们聘请俄罗斯开发商一次编写报告引擎......当合同重新谈判时间到来时,我们意识到*所有*评论都是俄语.惭愧我没有显示的代码:( (6认同)
  • 我不知道这是否是由工具生成的,但它肯定是由一个人编写的. (4认同)
  • @Rinat - 非常肯定马丁正在评论编码人员明显缺乏对"名字"究竟是什么的理解. (2认同)

shs*_*mer 56

在大学的家庭作业中为一位特别坚持我们对我们的代码发表评论的老师:

//I wonder if she actually reads these.
Run Code Online (Sandbox Code Playgroud)

当作业被退回时,在评论旁边的红色笔"是的,我做"

  • 老师比学生更有趣:) (25认同)

dr.*_*vil 55

来自泄露的Windows 2000源代码的伟大之一:

!!!!!!!如果你改变空间,你将被杀!!!!!!!!*
!!!!!!!!!!!!!!搞砸了建立过程!!!!!!!!!!!!!!!!*
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!

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

  • 这是在Win2k源中找到的一个奇怪的评论,因为NT组总是有一个无标签的源策略. (2认同)

Eva*_*ark 55

// 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.
Run Code Online (Sandbox Code Playgroud)


cha*_*aos 54

// 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
Run Code Online (Sandbox Code Playgroud)

  • #define中令人难以置信的空间给我留下了更深刻的印象.我几乎认为Pi被定义为什么都没有. (21认同)
  • 我不熟悉这个参考文献,所以我对它进行了修改:http://en.wikipedia.org/wiki/Indiana_Pi_Bill (18认同)
  • 这个具有讽刺意味也很有趣.它嘲笑印第安纳关于将pi舍入到1位数时,给出的代码只做了几个小数位. (4认同)
  • 可爱,但实际上它将其指定为其语言上下文中可用的浮点数的精度限制(可能不是您认为的那样).如果你看到超过这一点,请告诉我...... (4认同)
  • 作为一个印第安纳人,我必须指出它从来都不是法律.它确实确立了立法者,如小孩子,需要不断的监督. (3认同)

vob*_*ect 54

我一直很喜欢Paul DiLascia在他的文件标题中写的内容:

// If this code works, it was written by Paul DiLascia. If not, I don't know
// who wrote it
Run Code Online (Sandbox Code Playgroud)


Mik*_*Two 53

// human madable inconvenient. Way too sucks.
Run Code Online (Sandbox Code Playgroud)

我仍然不完全明白这意味着什么,但我发现很多代码都是如此.

  • 最有趣的评论是那些增加含糊不清的评论. (6认同)

mun*_*ent 53

// error codes
#define ERROR_SUCESS 0
#define ERROR_SUCCESS_IS_MISSPELLED 1
Run Code Online (Sandbox Code Playgroud)

没有定义其他错误代码.

  • 在日本工作,我得到了几乎乳制品 (2认同)

spl*_*cer 53

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

// batmon.c drives the rastamobile
Run Code Online (Sandbox Code Playgroud)


小智 52

从泄露的Win2K源代码:

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


Fed*_*oni 51

Donald Knuth的另一个经典之作:

注意上面代码中的错误; 我只是证明它是正确的,没有尝试过.

  • 实际上不是评论:http://www-cs-faculty.stanford.edu/~knuth/faq.html (7认同)

For*_*ake 49

//There can Only Be one HIGHLAN....err..Singleton
public class SomeSingleton
{
...
}
Run Code Online (Sandbox Code Playgroud)


Roa*_*ior 49

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

  • 真正的WTF是他没有使用Color类.等等......错误的网站. (26认同)

efd*_*dee 49

// if i ever see this again i'm going to start bringing guns to work
Run Code Online (Sandbox Code Playgroud)


Ale*_*rev 49

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

  • //我告诉你不要再给我编码! (15认同)

bil*_*dev 48

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


Thi*_*iro 47

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

Dijkstra可能讨厌我.

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

(......)

  • Djikstra - > Dijkstra (16认同)

DJ.*_*DJ. 47

//uncomment the following line if the program manager changes her mind again this week
Run Code Online (Sandbox Code Playgroud)


小智 46

using namespace std;            // So sue me
Run Code Online (Sandbox Code Playgroud)

  • 有时我想! (3认同)

Vin*_*cio 46

//Abandon all hope ye who enter beyond this point
Run Code Online (Sandbox Code Playgroud)

  • :^)听起来像但丁的Inferno III 9:"Lasciate ogni speranza voi ch'entrate". (8认同)
  • 这是作者的尝试,但不太记得.它通常用英语写成"放弃所有进入这里的人的希望". (7认同)

Roa*_*ior 46

// This procedure is really good for your dorsolateral prefrontal cortex.
Run Code Online (Sandbox Code Playgroud)

对于那些因为某些特殊原因而不知道DPC的人来说,当你深入学习新东西时,你的大脑就会变亮.


小智 46

//I'm sorry, but our princess is in another castle.
Run Code Online (Sandbox Code Playgroud)


Dio*_*ane 44

//ALL YOUR BASE ARE BELONG TO US
Run Code Online (Sandbox Code Playgroud)

......这让我的老板觉得有人入侵了.他不知道这个笑话.

  • 你在一些源代码中向老板展示了一些随机评论? (21认同)

Ano*_*ous 44

sqlite源文件的顶部:

/*

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

*/
Run Code Online (Sandbox Code Playgroud)


Cir*_*yon 44

/**
 * If you don't understand this code, you should be flipping burgers instead.
 */
Run Code Online (Sandbox Code Playgroud)

  • @Thorbjørn哪个评论?你或答案中的那个?:) (2认同)

fog*_*fog 42

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

/* Ah ah ah! You'll never understand why this one works. */
Run Code Online (Sandbox Code Playgroud)

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

  • 看来你达到了鲍尔默峰:http://imgs.xkcd.com/comics/ballmer_peak.png (20认同)

Mar*_*tin 42

我在我发布的WordPress模板中发布了这个"许可声明".无论如何,我觉得这很有趣.

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

The Me, in turn, pledges equally solemnly to be far too 
lazy to ever check up on you, so if you do manage to pull 
some chicks The Me won't have a cow. 
However The Me would be sorely disappointed if The You 
were to try and sell or distribute this work without 
acknowledging The Me. Seriously. The Me will come down on 
The You like a large quantitiy of hard and heavy objects 
that in large quantities may be harmful and possibly even 
lethal to The You; So don't even think about it, The Buster.
*/
Run Code Online (Sandbox Code Playgroud)

  • 我希望所有许可证都像这个一样可以理解.试着阅读你想拍摄的GPL2和LGPL2. (9认同)

小智 41

简单但有效的评论,在一些C++代码中不太安全的黑客之前

// yikes
Run Code Online (Sandbox Code Playgroud)

  • SCNR:http://www.youtube.com/watch?v = 7tsYstSet7g (2认同)

Kip*_*Kip 40

我不止一次使用过这个,当我对数学公式进行某种非显而易见的简化时,我不想记录:

//this formula is right, work out the math yourself if you don't believe me
Run Code Online (Sandbox Code Playgroud)

  • 那很好,但如何添加一些测试来证明它.昨晚我确切地说就是这样:找到了我认为无法工作的数学代码(由我编写) - 但是单元测试证明了这一点. (10认同)
  • 如果你是对的,这很好,如果你碰巧弄错了,那就非常糟糕.最好让测试备份它. (4认同)
  • 从形式上讲,测试并不"证明"一个公式,它们只表明它适用于特定情况.但无论如何我都会把它们包括在内 - 一些有用的案例会让人更有信心,*和*如果有人"优化"它就会检测失败. (2认同)

And*_*son 40

//You are not expected to understand this

经典.

  • //你不是要理解为什么. (3认同)

小智 40

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

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


Jer*_*tts 39

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

  • 只有1个像素的黄金? (4认同)

raw*_*wer 39

在GIGANTIC 800系列'switch'语句中,位于中间的某个位置:

// Joe is sorry
Run Code Online (Sandbox Code Playgroud)

几百行后......

// Harry is sorry too
Run Code Online (Sandbox Code Playgroud)


sbe*_*kur 37

这是我曾经不得不支持的实际代码.在努力理解AstaSaysGooGoo和AstaSaysGaaGaa(其中宣布和使用了更多astaTempVars)的逻辑之后,我已经准备好放弃了.我终于抬头看到了"@author"评论,整个事情开始变得有意义了.

/*

* @author Andrew Asta
*/
public class AstaClass{

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

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

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


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

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

PS我改变了实际作者的真实姓名,以避免我遇到任何争议......

  • astaGetsSlappedAtCodeReview() (28认同)
  • 真的听起来像Paula Bean :) (10认同)
  • public class paulaBean {private String paula ="Brillant"; public String getPaula(){return paula; }} (6认同)

Pau*_*nde 37

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

/* HP-UX sucks wet farts from dead pigeons' asses */
Run Code Online (Sandbox Code Playgroud)

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

  • 在使用HP-UX之后,我向上述C评论中的智慧低头. (6认同)
  • 说真的,我大声笑.. (3认同)

小智 37

//Mr. Compiler, please do not read this.
Run Code Online (Sandbox Code Playgroud)

  • 应该是Mrs.(http://ifaq.wap.org/computers/compilersarefemale.html). (3认同)

小智 36

long time; /* just seems that way */
Run Code Online (Sandbox Code Playgroud)


小智 35

aComment = 'this is not aComment' # this is aComment
class T(object):
    def f(this):
        this is not aComment
Run Code Online (Sandbox Code Playgroud)

  • +1因为我是Crocodile Dundee粉丝:) (7认同)

ska*_*adt 35

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

//**************************************
// 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.  
//**************************************
Run Code Online (Sandbox Code Playgroud)


Mil*_*ner 34

-- Comment this later
Run Code Online (Sandbox Code Playgroud)

那是4000多行PL/SQL程序的第2行.唯一的评论.该程序开发4年后,后来仍未来......


ken*_*der 34

有一些旧的JavaScript代码,写得很好.然后是评论行

// and there is where the dragon lives
Run Code Online (Sandbox Code Playgroud)

其次是一个功能4人花了一天时间来了解它在做什么.最后,我们意识到它甚至没有使用,也没有做任何事情.

  • 不要乱用它,以免龙生气!你不希望龙生气...... (7认同)

Ste*_*eet 34

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

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

*/

  • 哦,那就是*那是道格亚当斯得到他的书的想法. (8认同)

JB *_*ing 33

catch (Ex as Exception)
{
     // oh crap, we should do something.
}
Run Code Online (Sandbox Code Playgroud)

没有什么比空的捕获块让人觉得代码是健壮的....

  • 没有什么比在同一个代码块中混合VB和C#;) (6认同)

STW*_*STW 33

为了保护内疚,价值观已经改变

这是一个承包商留下的,他一直在研究一大堆负责测试电子邮件登录的代码.我们难以置信,所以我们尝试了,这是他个人帐户的有效登录; 我们仔细检查了修订历史记录,并且他有两个签到它来编辑它:一个用于添加代码,第二个用于注释它.

我们添加了艺术品,剩下的就是其余的; 另一位开发人员认为从他未来的自己(ala The Office)发送电子邮件会很有趣,并表示在登录停止工作之前,它每天花费近两整天的电子邮件.

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

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

我最喜欢的部分并不是他做到了,或者他意外地将它留在了办理登机手续的位置 - 但当他回过头来时,他只是评论出来而不是删除它.如果我们从来不知道它在那里,我们永远不会看原始版本:-D


小智 32

我看到这一个不少:

// TODO make this work
Run Code Online (Sandbox Code Playgroud)


Iai*_*ain 31

显而易见?

/** Logger */
private Logger logger = Logger.getLogger();
Run Code Online (Sandbox Code Playgroud)

  • 如果我不这样做,checkstyle插件会SCREAM! (5认同)

小智 31


$you = live("free") or die("hard");


小智 30

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

# <magic type="voodoo">

...

# </magic>
Run Code Online (Sandbox Code Playgroud)

下一个看它的人在Perl上并不那么热门,花了一段时间搜索文档,了解"魔法"和"伏都教"的作用.从那以后,我试图添加更多有用的评论......

  • 更有趣的是因为这个家伙实际上认为这是真的. (4认同)
  • @ harry.lime <magic type ="parlor">,<magic type ="sleightofhand">,<magic type ="card">等等.它们记录在这里:http://en.wikipedia.org/wiki/Template:Magic_and_Illusion (3认同)
  • 别忘了<magic type ="black">.这是我在代码中经常遇到的那种. (2认同)

xan*_*xan 30

来自谷歌代码项目:

# This job would be great if it wasn't for the fucking customers.
Run Code Online (Sandbox Code Playgroud)


小智 29

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('\',\'')}')))"
Run Code Online (Sandbox Code Playgroud)

来自约会网站......

  • 你在广告上做了类似的匹配吗?关于"如何让女性看你的个人资料"的提示?我只是说,因为我知道一个网站真的很糟糕. (2认同)

Ric*_*d T 28

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

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

其中最好的是帮助指导新发展避免已知陷阱的那些.

  • 好的理查德. (3认同)

Chr*_*ley 28

//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.
Run Code Online (Sandbox Code Playgroud)


dus*_*ins 28

//        .==.        .==.          
//       //`^\\      //^`\\         
//      // ^ ^\(\__/)/^ ^^\\        
//     //^ ^^ ^/6  6\ ^^ ^ \\       
//    //^ ^^ ^/( .. )\^ ^ ^ \\      
//   // ^^ ^/\| v""v |/\^ ^ ^\\     
//  // ^^/\/ /  `~~`  \ \/\^ ^\\    
//  -----------------------------
/// HERE BE DRAGONS
Run Code Online (Sandbox Code Playgroud)

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


Not*_*Dan 27

//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
Run Code Online (Sandbox Code Playgroud)


Mar*_*own 26

/// <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
}
Run Code Online (Sandbox Code Playgroud)

  • 每个人都是输家,但评论说每个人都是胜利者! (8认同)
  • 每个人都是胜利者! (6认同)

小智 26

//  If you delete the credits, I will fucking kill you.
Run Code Online (Sandbox Code Playgroud)

在joomla模块中找到.


unc*_*lio 25

//Woulda
if(x) {}
//Shoulda
else if(y) {}
//Coulda
else {}
Run Code Online (Sandbox Code Playgroud)

  • //没有<br>抓住(例外e){} (3认同)

use*_*208 24

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

...

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

...
Run Code Online (Sandbox Code Playgroud)

  • 嗯,所以编码器没有注意到DivideByZeroException,它会在他/她将要使用的任何IDE的堆栈跟踪中惊呼. (6认同)
  • 实际上,这将成为一个很好的"这个代码有什么问题"的面试问题. (5认同)
  • 是的,他没有度过整个夏天.他不停地向我提问,我会问他在日志中遇到了什么错误,他就像"我的代码编译得很好".他会一遍又一遍地问我同样的问题.这是我们最后一次为在我公司赞助的班级中获得最高分的人提供实习机会.这也是一个不到一年的学位. (5认同)

Bri*_*ndy 23

//If you're reading this, then my program is probably a success
Run Code Online (Sandbox Code Playgroud)


Cra*_*uff 23

我的一位老板总是在谈论我们如何在内部使用我们自己的产品,即"吃我们自己的狗粮......"

许多年后,我发现某个临时工友已经完成了某些来源的嵌入,他触摸的每个功能都被标记为:

/* NOT FIT FOR HUMAN CONSUMPTION */
Run Code Online (Sandbox Code Playgroud)


Mar*_*rie 22

经典ASP:

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

NextIP = StrReverse(UserRecordset.Fields.Item(0))
Run Code Online (Sandbox Code Playgroud)

  • 那是不对的; 逗号应该在nwod之前的角色上,而不是在pilf之后的角色. (14认同)

Col*_*tes 22

//open lid


//take sh!t


//close lid
Run Code Online (Sandbox Code Playgroud)

文件打开,数据转储,文件关闭的注释...


Jos*_*ood 22

制作源代码:

// Remove this if you wanna be fired
Run Code Online (Sandbox Code Playgroud)


sim*_*mon 22

年龄前我碰到了这个:

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

然后继续描述一个特别毛茸茸的算法.


小智 22

// (c) 2000 Applied Magic, Inc.
// Unauthorized use punishable by torture, mutilation, and vivisection.
Run Code Online (Sandbox Code Playgroud)

啊,我一直很喜欢那个......


小智 22

public GetRandomNumber()
{
    // Chosen by a fairly rolen dice
    return 12;
}
Run Code Online (Sandbox Code Playgroud)

  • 听起来像xkcd ...... (5认同)
  • 如果它以单数形式"死",那么"骰子"必须是复数 - 你可以从滚动"骰子"得到12(两个六,amirite?) (5认同)

Ale*_*ejo 21

迄今为止最好的一个:

"This code makes baby Jesus very sad!". 
Run Code Online (Sandbox Code Playgroud)

它引用了一个String iniciatilization,如下所示:

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
Run Code Online (Sandbox Code Playgroud)

反正你懂这个意思.


小智 21

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


ohn*_*oes 21

前段时间我遇到过:

raise InvalidChild() # e.g. no legs
Run Code Online (Sandbox Code Playgroud)

这是怪诞的,因为" inwalida "在波兰语中,意味着残疾人. 傻我:)

  • 无效:in-VAL-id:无效.无效:IN-va-lid:残疾,卧床不起,生病. (2认同)

Dan*_*ano 20

我告诉受指导者至少要做一些异常处理.这是我得到的每个数据库调用周围....

Catch (Exception e) {
    //eat it
}
Run Code Online (Sandbox Code Playgroud)


小智 20

对上帝诚实:

// This is crap code but it's 3 a.m. and I need to get this working.
Run Code Online (Sandbox Code Playgroud)


stu*_*tcw 19

在众所周知的商业DOS电子表格应用程序中:

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

  • 获胜者是...... VSS! (28认同)
  • 有趣.什么样的愚蠢版本控制系统会信任客户的时钟? (2认同)

the*_*zer 19

当我在路透社工作时,我们的一位饲料处理人员发表评论,让一些人认为全能者正在帮助我们......

// Jesus told me to skip to the end of the message here
Run Code Online (Sandbox Code Playgroud)

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


lli*_*lib 19

我写过的最喜欢的评论:

//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.
Run Code Online (Sandbox Code Playgroud)

是的,亚马逊实际上会像这样返回XML.

  • 它甚至比那更糟糕; 它不是以空间分隔的.请注意,日期和状态字段的值可能都有空格,从而破坏了任何可能的简单解析策略. (4认同)
  • 这不是故障!如果您敢于阅读文档:http://www.amazonsellercommunity.com/forums/ann.jspa?annID = 18 (4认同)
  • 我想看看有关亚马逊代码的评论...... (3认同)

GBe*_*gen 19

//  Hey, your shoe's untied!
Run Code Online (Sandbox Code Playgroud)

接下来是一些可疑的代码,并在该代码中,

//  Keep looking!  I think it was the other shoe!
Run Code Online (Sandbox Code Playgroud)

最后,

//  How strange -- I must be seeing things.  Anyhow, I'm going to go take a shower, now...
Run Code Online (Sandbox Code Playgroud)


小智 19

我最喜欢的是来自已故的伟大Paul DiLascia:

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

  • 欺骗:http://stackoverflow.com/questions/184618/what-is-the-best-comment-in-source-code-you-have-ever-encountered/766044#766044 (9认同)

小智 18

// Houston, we have a problem


小智 18

David S. Miller添加的所有错误


Ed *_*rty 18

在可以踩到这个对象的游戏中,或者:

stepOff(); //bitch
Run Code Online (Sandbox Code Playgroud)


小智 18

/*现在,让所有这些在浏览器系列的延迟步兄弟,互联网他妈的浏览器*/看起来一半体面


小智 18

// This should fix something that should never happen
Run Code Online (Sandbox Code Playgroud)


小智 18

# 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 != {} )
{
Run Code Online (Sandbox Code Playgroud)


Mar*_*ath 18

// some sport psychology
if (!focused)
    Focus();
Run Code Online (Sandbox Code Playgroud)


mse*_*ery 17

// This is a walkaround for bug #7812
Run Code Online (Sandbox Code Playgroud)

由我们的一位中国程序员撰写,英语不是他的第一语言.

我真的很喜欢这个.我碰巧认为"walkaround"几乎是一个比"解决方法"更好的术语.

  • //这是bug#7812的反应 (8认同)

小智 17

// For the sins I am about to commit, may James Gosling forgive me
Run Code Online (Sandbox Code Playgroud)


小智 17

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

05/17/99 D JONES 评论BLOODY AUZIES CODE(02/19/99)

05/17/99 K ROBINSON BLOODY TEXAN无法正确调整AUSSIE(无代码更改 - 仅作评论)


Bra*_*row 17

在VB.NET中使用分号

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';
Run Code Online (Sandbox Code Playgroud)

  • 好多了.... (2认同)

小智 17

早在八十年代初期,我就在汇编程序中引用了这个内容(引用昏暗的内存):

I don't understand how the following bit works, but it worked in the program I stole it from.
Run Code Online (Sandbox Code Playgroud)


int*_*tar 16

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

; Rechnen ja ; have faith in yes
Run Code Online (Sandbox Code Playgroud)

我想原来的意思是"假设在这里真实"......但是自从我把它当作我生命的口头禅.


小智 16

一些来自Linux内核:

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

-

/* 2,191 lines of complete and utter shit coming up... */
Run Code Online (Sandbox Code Playgroud)

-

#if 0 /* XXX No fucking way dude... */
Run Code Online (Sandbox Code Playgroud)


Sin*_*son 16

来自Apache Xalan的源代码:

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

进一步阅读每日WTF.


its*_*att 16

// A Gorgon class - For the love of Zeus don't look directly at it!
Run Code Online (Sandbox Code Playgroud)


mar*_*nus 16

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

facebook api的某个地方.


小智 16

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

#!/usr/bin/perl
# perl script disguised as a bash script
Run Code Online (Sandbox Code Playgroud)


Nir*_*ran 16

//todo: never to be implemented
Run Code Online (Sandbox Code Playgroud)


小智 16

//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----|
        //|--------------------------------------------------|----------------------------------------------
Run Code Online (Sandbox Code Playgroud)


小智 16

Tweet tweet = (Tweet) tweets.get(i); // Poetic.
Run Code Online (Sandbox Code Playgroud)


Mil*_*dev 15

// Okay, let's do the loop, yeah come on baby let's do the loop
// and it goes like this ...
Run Code Online (Sandbox Code Playgroud)


Luc*_*hez 15

我发现它在Python 2.5的"扭曲"包中(文件是第371行的tcp.py)

# 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))
Run Code Online (Sandbox Code Playgroud)


lfx*_*lfx 15

// If I from the future read this I'll back in time and kill myself. 
Run Code Online (Sandbox Code Playgroud)


bmd*_*cks 14

从新闻组阅读的经典:

Teradyne硬件建模代码内部深处是一个例程,它将一大堆十六进制数字输入SYS $ QIO调用.唯一的评论是"奇怪的魔法发生在这里".


Rob*_* S. 14

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

'Avert your eyes, it may take on other forms!
Run Code Online (Sandbox Code Playgroud)

好的佛兰德斯.

  • Flanders是编写代码的开发人员的名字.但我喜欢你有参考.:) (3认同)
  • 是的,"豆子,豆子,音乐水果/你吃得越多,你就越多".这不是法兰德斯. (2认同)

mat*_*ant 14

//The following code is commented out
//(a load of commented out code followed)
Run Code Online (Sandbox Code Playgroud)


Gui*_*ido 14

i++; // increment variable i
Run Code Online (Sandbox Code Playgroud)

  • 我喜欢比他们解释的代码更长的评论,并且仍然无法解释代码. (3认同)

run*_*1ME 14

我相信JBoss某处有一条线可读

return null; //Not really null
Run Code Online (Sandbox Code Playgroud)

我总是很喜欢那条线.


BoD*_*BoD 14

有一次,我问同事如何用我们的内部框架做某事(忘了确切的,一些模糊的技术要求).他说"简单,看看这里",然后在他的编辑器中打开一个.java文件,并在几页代码中间显示这条评论:

// HERE
Run Code Online (Sandbox Code Playgroud)

我刚检查过,评论仍在此文件中:)


SPW*_*ley 14

这个来自Xee,一个图像浏览器.

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


Pra*_*mod 13

图表:

return 0; // Happy ending
Run Code Online (Sandbox Code Playgroud)

图表B:

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
);
Run Code Online (Sandbox Code Playgroud)


Mar*_*ith 13

// This code was written by a genius so don't try to understand it with
// your tiny little brain.
Run Code Online (Sandbox Code Playgroud)


Kur*_*aze 13

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

在很长的程序之前:)


小智 13

else
{
    // rien, c'est parfait.
}
Run Code Online (Sandbox Code Playgroud)

  • 可译:"无所事事,完美无缺." (3认同)

小智 13

/**
 * Happy Javadoc haiku:
 *
 * Without Javadoc
 * Builds break in Maven site stage
 * This fixes the build.
 */
Run Code Online (Sandbox Code Playgroud)


TM.*_*TM. 12

实际上前几天看到了这个问题,有些代码是在截止日期之前写的.

//This was clearly written under duress
Run Code Online (Sandbox Code Playgroud)


Mat*_*ttC 12

// Hard to explain
Run Code Online (Sandbox Code Playgroud)

它最终也被打破了.难怪难以解释


edo*_*aur 12

// Added because boss changed his mind : 20020111,20020501,20020820, ...
// Commented out because boss changed his mind : 20020201,20020614,20020908, ...
Run Code Online (Sandbox Code Playgroud)

在大多数被黑客攻击的RPG数据库和SQL Server数据库之间的ETL脚本中.我有10或20次发表此评论的内容......


Ove*_*own 12

我想我有这样的东西:


if (case1) { // trivial
...
}
else { // we are screwed
 /* fill in later */
}
Run Code Online (Sandbox Code Playgroud)

好吧,所以我可能会使用比拧紧更强的词


Ric*_*ett 12

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

' RIP LVB
Run Code Online (Sandbox Code Playgroud)

(得到它?)

  • 和平安息路德维希·范·贝多芬(1770 - 1827年).723十六进制= 1827十进制.一个老人,但一个礼物.+1. (7认同)

Pra*_*are 12

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

  //  IMPLEMENTATION GOES HERE

/**---------END-----------**/
Run Code Online (Sandbox Code Playgroud)

但没有代码;)

  • 我打赌这是有史以来最无bug的代码,如果评论算作代码......哈哈! (2认同)

use*_*503 12

// this error could never happen
Run Code Online (Sandbox Code Playgroud)

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


小智 12

我最喜欢的评论是我的一个同性恋朋友使用的.他喜欢在VB.NET中标记他所有的TODO评论

'TODO: Matt Damon
Run Code Online (Sandbox Code Playgroud)

有时提供了额外的信息,但通常不提供.


Ste*_*roy 12

当我在Highschool参加CS课程时,我们在普通教室里接受教育 - 没有电脑.我们所有的测试都是在我们递交的纸上完成的 - 每张纸一个类.我们的老师第一次用C++教课,偶尔会在黑板上切换到Pascal模式.这很尴尬,因为我们很少有兴趣学习Pascal.

对于大于课堂的工作,我们会在家里完成这些工作,并提交代码+输出打印输出进行评分.在提交了一些代码+输出打印输出之后,我们共同意识到老师实际上并没有阅读代码 - 只是打印输出.为了测试我们的理论,我对我的代码的第3页进行了评论 - 在某些类声明之间:

// If you are reading this, please place a checkmark here [  ]
Run Code Online (Sandbox Code Playgroud)

当然,我在前面拿了一个大的蓝色"A",没有找到勾选标记.


orj*_*orj 12

// BEGIN HACK
...
// END HACK: I feel dirty.
Run Code Online (Sandbox Code Playgroud)


小智 12

  rescue
    # silently, we fail
    # many validations fade
    # like tear drops in rain
  end
Run Code Online (Sandbox Code Playgroud)

这只是其中之一......


小智 12

'Mind boggling, gibberish version of a SQL statement, but it work's, so dont touch it
Run Code Online (Sandbox Code Playgroud)

  • upvote,因为你不值得一个downvote (4认同)

小智 12

在makefile中找到了这个

# ===== Never edit below this line. Ever. Or I'll kick your ass. ====
Run Code Online (Sandbox Code Playgroud)


rsh*_*oda 11

当我实现原型变成真正的代码时,这实际上是由我做的:

// Abandon all hope you who needs to debug this
Run Code Online (Sandbox Code Playgroud)

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


Dav*_*lie 11

"这永远不会发生".

着名的遗言我的朋友......


And*_*dré 11

在XSLT文件的标头中:

DON'T TOUCH THIS SCRIPT -> XSLT is like arcane, black magic
Run Code Online (Sandbox Code Playgroud)

  • 我同意.很多年前我做了一些XSLT魔法.这有点像伏都教,但我发誓我玩得很开心 - 当我不拔我的头发时,就是这样. (4认同)
  • 对,复杂的事情很容易,但简单的事情可以让你在XSLT中疯狂... (3认同)

小智 11

Linux评论

这里有很多好的......

这些都是linux中的评论

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

我最喜欢的:

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

./drivers/scsi/qlogicpti.h
/* Am I fucking pedantic or what? */
Run Code Online (Sandbox Code Playgroud)


Joh*_*man 11

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

第一次提交(在测试人员返回结果后跟随其他几十个人):

Squashed some IPR mod bugs. The were big and juicy ones, too.
Run Code Online (Sandbox Code Playgroud)

第二次提交:

Squashed some more mod bugs. Those are some nasty bugs, them mod bugs...
Run Code Online (Sandbox Code Playgroud)

第三:

Squashed some more mod bugs. They are like cockroaches: they'll live through a nuclear war.
Run Code Online (Sandbox Code Playgroud)

第4名:

Squashed some more John bugs. They too are like cockroaches: they appear anywhere John goes. Wait. That doesn't sound right.
Run Code Online (Sandbox Code Playgroud)

第五名:

Same John bug. It didn't die, just played 'possum.
Run Code Online (Sandbox Code Playgroud)

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


Joh*_*itb 11

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

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

   If you're interested in how this works, just forget it.  You really
   do not want to know about this braindamage.  */
Run Code Online (Sandbox Code Playgroud)

这个也是:

/* Don't ask about these magic sequences.  I took them straight
   from gas-1.36 which took them from the a.out man page.  */
Run Code Online (Sandbox Code Playgroud)

...

/* 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.  */
Run Code Online (Sandbox Code Playgroud)

另一个:

/* 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. ... */
Run Code Online (Sandbox Code Playgroud)

从天然气:

/* 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.  */
Run Code Online (Sandbox Code Playgroud)


Tim*_*ost 11

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

/*
 * Don't OOM me, bro!
 */
Run Code Online (Sandbox Code Playgroud)

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

/*
 * Don't swap me, bro!
 */
Run Code Online (Sandbox Code Playgroud)


Boy*_*ski 11

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

// 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 
Run Code Online (Sandbox Code Playgroud)


Jor*_*orn 11

/* FIXME This must absolutely be removed before 4.0.7 release
 * TODO really remove this */
Run Code Online (Sandbox Code Playgroud)

我们发布了4.0.7,4.0.8,4.0.9和4.1版本......


小智 11

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

// Cabbage fart?
Run Code Online (Sandbox Code Playgroud)

我不知道它应该是什么意思.很高兴我的立方体不在谁写的旁边.


小智 11

/* Here I sit, Joe broken hearted, came to do some sh*t, but only just started. */
Run Code Online (Sandbox Code Playgroud)

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


小智 11

public function get state( /* of Palestine back */ ):Boolean
Run Code Online (Sandbox Code Playgroud)


小智 11

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
Run Code Online (Sandbox Code Playgroud)


小智 11

在完全任意行之后的几千行JScr​​ipt文件中间......

// The world is a happy place.
Run Code Online (Sandbox Code Playgroud)


Tim*_*ost 11

好吧,这是我刚刚承诺的一个:

/* 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.
 */
Run Code Online (Sandbox Code Playgroud)

有人可以像greatcodecomments.com一样开始赚钱.然而,那个人不是我.


小智 11

// need a coffee to fix this.
Run Code Online (Sandbox Code Playgroud)


Mao*_*gue 11

// Singleton object. Leave $me alone.
private static $me;
Run Code Online (Sandbox Code Playgroud)


小智 10

int Q13Factor = 8125; // 2^13 for Q13 
Run Code Online (Sandbox Code Playgroud)


小智 10

THIS PROGRAM HAS CODE THAT DOES NOT MEET STANDARDS      
Run Code Online (Sandbox Code Playgroud)

这个评论几乎在我们这里的每个项目......

  • 像维基百科一样有清理和引用来源标签...... (3认同)

Enr*_*lio 10

在JUnit API中找到:

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


bel*_*bob 10

在LucasArts的电脑游戏"The Eidolon"的源代码中看到了(这本身就是奇怪和古怪的)......

// He's dead, Jim!
Run Code Online (Sandbox Code Playgroud)


Ric*_*ner 10

// TODO - Comment this function
Run Code Online (Sandbox Code Playgroud)

  • 对不起 那是我. (6认同)

Chr*_*ssl 10

我不记得确切,但这个想法是这样的:

Person p = new Person("John", "Doe", "male");
Collection women = new ArrayList();
women.insert(p.getTail());
Run Code Online (Sandbox Code Playgroud)

这是脏代码;)

  • 在我添加这个答案之前,这个答案没有评论. (24认同)
  • 就像那段代码那样肮脏,结果是你把一个男性放在女性的集合中.因此,当下一个程序员使用女性名单时,他会得到一个男性并将其用作女性.因此,虽然第一个程序员认为他的家伙很幸运,但下一个程序员确保这个家伙得到了相同的治疗方法. (5认同)

Dr.*_*Bob 10

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

但代码仍然存在......


Jos*_*hua 10

'Do not optimize these next two lines. Compiler bugs lurk.
Run Code Online (Sandbox Code Playgroud)

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


jpi*_*912 10

从一个明显一直在看Monty Python的小伙子:

> // And now, for something completely
> // different:
Run Code Online (Sandbox Code Playgroud)

class theLarch {


bla*_*ank 10

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

if (groupid < 10) {
groupid = "0" + groupid;
}
Run Code Online (Sandbox Code Playgroud)


Ada*_*mBT 10

今天刚刚添加了这个:

// Hardcoded this for time sake ... will make andrew fix later :)
Run Code Online (Sandbox Code Playgroud)


Pol*_*olo 10

这条评论来自我必须调试的旧项目:

//Haleluya i can go home!
Run Code Online (Sandbox Code Playgroud)

  • 当他甚至无法正确拼写哈利路亚时,我不必惊讶你必须调试代码. (5认同)
  • 这是因为没有intellisense援助 (2认同)

Chr*_*ett 10

在我决定用脚本语言替换它之前,我不得不将这个添加到旧的数据表驱动的规则引擎中.

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

  • 对于那些不了解神曲的人(或像我这样的意大利人)来说,这是"放弃所有希望,你们进入这里的人". (2认同)

dan*_*nio 10

   // Some wanker in ISO got rid of ifstream(int), ofstream(int), and
   // fstream(int).  Twit.
Run Code Online (Sandbox Code Playgroud)


小智 10

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


小智 10

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

/* You are not expected to understand this. */
Run Code Online (Sandbox Code Playgroud)


Jas*_*son 10

// Fuck.
Run Code Online (Sandbox Code Playgroud)

那个,......

// This code worked before, but my cat decided to take a trip across my keyboard...
Run Code Online (Sandbox Code Playgroud)

  • 他没有撤消按钮? (4认同)

ant*_*tik 9

// TODO: Implement this function!
Run Code Online (Sandbox Code Playgroud)

  • 嘿! 你一直在读我的代码! (8认同)

Bra*_*orn 9

# absolutely foul heuristic code.
# ..it's dirty, but you want it.
Run Code Online (Sandbox Code Playgroud)

和:

# VERY USEFUL DEBUGGING AID, for when the above all goes pearshaped:
Run Code Online (Sandbox Code Playgroud)


trs*_*hiv 9

/* My lawyer told me not to reveal */
Run Code Online (Sandbox Code Playgroud)


小智 9

不是评论,而是属性

[ThereBeDragons]
Run Code Online (Sandbox Code Playgroud)

我在IHttpHandler的实现中看到了一个

//What is this?
public bool IsReusable
{
    get{return false;}
}
Run Code Online (Sandbox Code Playgroud)


cop*_*pro 9

这是我自己的代码中的一个,但它仍然非常有趣,我想我也可以把它放在一起,因为它是在公共SVN中.

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


Lil*_*ily 9

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;
}
Run Code Online (Sandbox Code Playgroud)


Nor*_*des 9

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

// Notice: I feel so dirty doing this, but it's the only way to make it cross browser.
Run Code Online (Sandbox Code Playgroud)

但在阅读Scott Hanselmen的一篇文章时,我发现了以下引用,这与我在代码中找到的评论非常相符:

Every line of code you write that you feel gross about will ultimately come back to haunt you. Therefore, avoid writing code that makes you feel dirty.
Run Code Online (Sandbox Code Playgroud)

那很好笑 :)


Ted*_*Ted 8

// Bad Christian, No cookie
Run Code Online (Sandbox Code Playgroud)

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


sma*_*ell 8

这是我最喜欢的评论.

/// 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
Run Code Online (Sandbox Code Playgroud)

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

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

再来一次

if( where == null)//be nice
Run Code Online (Sandbox Code Playgroud)


And*_*son 8

// THE LOOP THAT DO EVERYTHING!!!!!!!
Run Code Online (Sandbox Code Playgroud)


Nat*_*Nat 8

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

Without a crash 

Or mighty bang 

The sync disk 

Did it's process hang
Run Code Online (Sandbox Code Playgroud)


Geo*_*rge 8

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


Chr*_*anz 8

我刚刚在一个非常简单的测试C++程序中遇到过这个问题,这个程序适用于大学课程.

我正在评论一堂课.

在析构函数中......

// Choose! Choose the form of the Destructor!
// The choice is made! The Traveler has come!
Run Code Online (Sandbox Code Playgroud)


Sim*_*hke 8

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

<!-- Hopfully we can do this otherwise the nav is going to be pretty plain and Hong will go postal. -->
Run Code Online (Sandbox Code Playgroud)


i_a*_*orf 8

// TODO: Drive an ashen stake through the foul heart of this function.
Run Code Online (Sandbox Code Playgroud)

这是一个犯规功能.到目前为止,我一直都在做噩梦.


Ben*_*jol 8

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

//#region Code for weird cases - do you really want to know?
Run Code Online (Sandbox Code Playgroud)

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

' Commented out following code, don't delete for when [CustomerName] changes his mind
Run Code Online (Sandbox Code Playgroud)

碰巧,[客户名称]并未改变主意,但他无法访问网络服务器,他发现该行...


The*_*tor 8

// This condition can't happen. Call the police or something.
Run Code Online (Sandbox Code Playgroud)


小智 8

var arbitraryNumber = 10;
//I don't know why. Just move on.
Run Code Online (Sandbox Code Playgroud)


ano*_*ard 8

我在Google Code Search上找到了这个

    // 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;
    }
Run Code Online (Sandbox Code Playgroud)


cli*_*ers 8

// TODO: not this
Run Code Online (Sandbox Code Playgroud)

由同事在一个查询之上写下,迫切需要优化.在他的辩护中,我们在这一点上工作了70个小时,持续了几个月......


小智 8

/*

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


*/
Run Code Online (Sandbox Code Playgroud)


Geo*_*uer 8

// This part is more difficult
Run Code Online (Sandbox Code Playgroud)

在方法的顶部.

这大约是5行.

并不是很困难.

这是唯一的评论.

在整个应用程序中.


小智 8

/**
 * 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
 */
Run Code Online (Sandbox Code Playgroud)


小智 8

//Dave chapelle reports errors.
function reporterror() {
  davechapelle.trace("FUCK!");
}
Run Code Online (Sandbox Code Playgroud)


Pro*_*ner 8

// TODO: Finish.


小智 7

我在重新使用我在很久以前写过的PHP类时发现了这一点.我仍然不记得那里去了什么,我仍然没有找到它...我实际上甚至不记得我写的评论; 所以当我找到它时,我大声笑出声来.

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


Tha*_*oke 7

在一个文件中的5000多行代码中的一些极少数评论
我实际上与编码者辩论他的编码风格...
没有评论!
并且没有评论;-)(或很少)
遗憾的是这是生产代码.

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

我喜欢这个开关!

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);
}
Run Code Online (Sandbox Code Playgroud)

并且没有,没有评论解释标题中的"modif A".

if (GetFileSize(hSlotFile,NULL)==3600)   //5*720
Run Code Online (Sandbox Code Playgroud)

什么是720?

  • 720是2*2*2*2*3*3*5,duh. (8认同)

Sim*_*ett 7

在为某个芬兰移动网络设备制造商工作时,通过硬件抽象层进行探索,我发现了100多个芬兰语单词"puukko".

"puukko"是每个芬兰人在他们的工具箱或房子周围都有的通用刀.它用于从剥土豆到进行电脑维修(我的观察)的一切.我相信在这种情况下,芬兰语相当于"哈克"这个词.

我的芬兰同事否认了这一点,并表示这意味着更像"外科手术/干预"......我几乎相信它们,直到我发现评论为止:

/* Perkele ISO Puukko! */ -> Fucking Big Hack!
Run Code Online (Sandbox Code Playgroud)


Par*_*ppa 7

一个奇怪的合适的有趣拼写错误:

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


小智 7

不是评论:

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

可悲的是,没有评论,PSCRIPT5.DLL确实爆炸了......


小智 7

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

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

// Now you can call your grandmother back. ;)
Run Code Online (Sandbox Code Playgroud)


Fre*_*ory 7

在LKM中:

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


Bob*_*obC 7

catch (Exception ex)
{ 
    // just die already.
}
Run Code Online (Sandbox Code Playgroud)


thi*_*ijs 7

我最近看到了这个:

//你刚丢了游戏

如果你不知道游戏是什么:http: //en.wikipedia.org/wiki/The_Game_ (mind_game)(它非常愚蠢,但在某种程度上有点愚蠢)

  • 我刚刚输掉比赛 (2认同)

Mar*_*ini 7

我在一个显式奇怪的强制转换函数FULL中看到了这段代码:

// 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. "
Run Code Online (Sandbox Code Playgroud)

代码很可怕:)


bre*_*tik 7

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

// IE7 update. this is still bad code, but IE8 is probably a long way off :)
Run Code Online (Sandbox Code Playgroud)


小智 7

# dont question, i just felt like throwing some globals in
# this is actually quite pointless as youll soon see
Run Code Online (Sandbox Code Playgroud)

稍后在代码中

#draw the circles (complicated)...dont question
Run Code Online (Sandbox Code Playgroud)

甚至更晚......

# complicated process of drawing the circles in a
# somewhat symmetrical, 3-d pattern
# dont question again
Run Code Online (Sandbox Code Playgroud)

甚至以后......

# will determine if user clicks on die
# i determined these values...dont worry about them
Run Code Online (Sandbox Code Playgroud)


MrV*_*dez 6

Coding Horror向朋友展示这篇文章几个小时后,我在他的代码中看到了这个评论:

// MrValdez是一个暴力的精神病患者.不要惹恼他.


mos*_*ald 6

刚从大学毕业,我急于弄脏自己的手.我的第一个任务是......"为我评论这段代码".

笨蛋.

过了一会儿我厌倦了......

// 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]
Run Code Online (Sandbox Code Playgroud)


Ret*_*tne 6

-- Change Log:  Not needed. The code is perfect 'cause I wrote it.
-- If you change it, it will break.
Run Code Online (Sandbox Code Playgroud)

我正在审查一些代码注释以检查它们是否有意义,并且看到了上面的适度行.


mof*_*dub 6

在被迫为贫血域对象编写单元测试时,这些对象只不过是一堆吸气剂和固定器(我也被迫写入):

// zzzzZZZZzzzz....
Run Code Online (Sandbox Code Playgroud)


MrB*_*les 6

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

  • 我不得不说我被冒号发誓而不是糟糕的咒语更冒犯了. (3认同)
  • @__>然后我怀疑你是少数. (2认同)
  • 我同意 __.拼写错误是痛苦的,但带星号的咒骂词是荒谬的.无论是发誓还是不发誓.它会让你看起来像个懦夫. (2认同)

Ste*_*nby 6

<!-- 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) -->
Run Code Online (Sandbox Code Playgroud)


cLF*_*aVA 6

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

// 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.
Run Code Online (Sandbox Code Playgroud)


ann*_*ata 6

从C#中的单元测试类:

#region quis custodiet ipsos custodes?

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

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

#endregion
Run Code Online (Sandbox Code Playgroud)

  • 嗯,Assert.Fail(); ? (2认同)

use*_*985 6

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

  • Nooooooo !!!! 这有很好的解决方法!! 喜欢`(_xsNamespaces = new XmlSerializerNamespaces()).Add("","")`; (3认同)

Jan*_*les 6

我曾经研究过Windows 3.0的源代码.(不是,我赶紧补充一下,作为一名微软员工!)我遇到了一个多次重入的文件加载器,并且有一个令人讨厌的惩罚的例子(只是为了表明作者有多聪明).

这一堆重入代码是用英特尔汇编jmp指令(在C代码中间)执行的,该指令进入标签"we_are_not_in_kansas_any_more_toto".


Dav*_*ope 6

#ifdef TRACE
#undef TRACE     /* All your trace are belong to us. */
#endif
#define TRACE ....
Run Code Online (Sandbox Code Playgroud)


jos*_*hk0 6

整个功能非常棒(来自Linux sunhme.c驱动程序,因为Sun的昵称为Happy Meal的网卡.因为之前出现的卡是"Big MAC".获取它?获取它?)

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

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

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

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

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

    /* Fifty-two cents is your change, have a nice day. */
Run Code Online (Sandbox Code Playgroud)

}

  • 欺骗:http://stackoverflow.com/questions/184618/what-is-the-best-comment-in-source-code-you-have-ever-encountered/694652#694652 (7认同)

tlr*_*son 6

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


小智 6

// no comment


小智 6

# as you can see: I comment the code!


Pau*_*man 6

控制+ A,重写

这是一个注释添加到上一个项目的源代码控制作为签入注释.


std*_*ave 6

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

public boolean getDirty (String MAC) // not as fun as it sounds
Run Code Online (Sandbox Code Playgroud)


小智 6

// TODO: what the hell is this all about?
Run Code Online (Sandbox Code Playgroud)

然后一些注释掉的代码.

这在我们今天早些时候的工作代码中找到了.我不确定我是应该笑还是哭...


小智 6

// *** AAAAAHAHAHAH!!  What is this??
Run Code Online (Sandbox Code Playgroud)


Edu*_*añó 5

我找到了这个:

I'm not sure what I did
Run Code Online (Sandbox Code Playgroud)


Jos*_*ons 5

{
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]
}
Run Code Online (Sandbox Code Playgroud)


Mat*_*ten 5

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;
}
Run Code Online (Sandbox Code Playgroud)


Jos*_*ris 5

在名为"Bar"的类(具有少于描述性名称的UI控件)中,类标题:

/// <summary>I pity the "foo".</summary>
Run Code Online (Sandbox Code Playgroud)

Remove()方法:

/// <summary>A "foo" and his money are soon parted.</summary>
Run Code Online (Sandbox Code Playgroud)

更糟糕的是,它是一个商业合作伙伴,从生成的文档中指出了它.更糟糕的是,这些可能是我们从这个人那里获得的有用文档最接近的东西.


Nik*_*lja 5

//Iterate by one
$i++;

不幸的是,在我的"必须评论所有阶段"期间,这是我的.

  • 另外,你可能意味着"一个人增加". (12认同)

wer*_*eld 5

在一些网站上工作时,我在嵌入式JS的开头找到了这个:

我觉得这样做很脏,但那个人想要它在.NET中


Rob*_*use 5

来自C#

#region Hack - Shield Eyes Before Expanding

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

#endregion
Run Code Online (Sandbox Code Playgroud)


小智 5

很久以前我遇到了一些连接脚本,虽然我不记得语法,但我记得这些评论,因为我是Pink Floyd粉丝.

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


//Handshake Failed: I don't understand...he just hung up.
Run Code Online (Sandbox Code Playgroud)


ale*_*zio 5

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

/**
*@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...
*/
Run Code Online (Sandbox Code Playgroud)


Kel*_*tia 5

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

/*
 * A virgin directory (no blushing please).
 */
Run Code Online (Sandbox Code Playgroud)

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


Nei*_*ken 5

刚刚在我们的一些PHP代码中找到了这个

$s=2; // chicken and bacon wrap for lunch
Run Code Online (Sandbox Code Playgroud)

多么有用,幸运的是$ s是自我解释的


Ben*_*wee 5

try {
   doSomething();
} catch(err) {
   // Die quietly
   alert(err);
}
Run Code Online (Sandbox Code Playgroud)


Jaa*_*nus 5

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

这不能成为我的代码中的错误.我非常仔细地编码.


小智 5

我刚刚在自己的一些代码中遇到了这个问题.它是用于选择类别的magento管理模板:

        /*
         * 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?
        }
Run Code Online (Sandbox Code Playgroud)

我将删除我们的旗舰产品当然的语言; 但我记得我非常沮丧.如果我没有发表评论,我会尝试修改它,但后来遇到了我以前遇到的相同问题.


Bri*_*ell 5

这比您在许多评论标题中看到的可怕的法律声明和免责声明要好得多.来自SQLite.

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


小智 5

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

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 */
   ...
}
Run Code Online (Sandbox Code Playgroud)

  • 为了给你提供这些信息,有多少Bothans死了? (3认同)

Poo*_*ool 5

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

// i don't know how this works but it does so i'll leave it here anyway
Run Code Online (Sandbox Code Playgroud)

他还将BNP(英国非常右翼派对)作为测试中的一个虚拟客户添加...我们的直接老板是亚洲种族.


wom*_*omp 5

<!-- Here it is -->
Run Code Online (Sandbox Code Playgroud)

没有其他评论.直到今天,我还不知道"它"是什么.

  • "它"显然是一个评论. (4认同)

小智 5

我没有共享的代码,但想象一下这种情况.在Linux系统管理员离开绿色牧场后大约一两个月,我有幸打开了他写的shell脚本.我不记得为什么我需要编辑它,但这不重要.重要的是剧本大约有40行.我滚过评论(其中有37行)以达到实际工作代码(3行).代码很棒,但我很好奇 - 为什么有37行评论?所以,我滚动到顶部继续阅读.令我惊讶的是,评论是关于三行代码的作用以及如何改变它的说法.最好的部分 - 这是由Dr. Dre和Snoop DO DOUBLE G部分取消了Nothing But AG Thing.感谢Brian!


Jan*_*man 5

/*
* TODO: Remove this function

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

*/
Run Code Online (Sandbox Code Playgroud)


Gly*_*yph 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*
Run Code Online (Sandbox Code Playgroud)

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

"TR"在这里指的是"扭曲的现实".Zope 2和原始twisted.reality软件包广泛而不幸地使用了多重继承,这使得在看到方法调用时很难理解发生了什么.Zope 3,Twisted本身,以及其twisted.reality继承者(包括最近的,Imaginary)反而普遍赞成组件组合.


Sin*_*son 5

/**
 * 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";
Run Code Online (Sandbox Code Playgroud)

  • 欺骗http://stackoverflow.com/posts/503186/revisions (3认同)

小智 5

catch
{     
    // you’re fucked
    // write out the file somewhere and start screaming “Connection down! Connection down!”
}
Run Code Online (Sandbox Code Playgroud)


小智 5

很多年前,我接受了这项工作,为一个在Z80上实时运行的项目提供支持,并且正在组装(有没有其他方法可以做Z80?)无论如何,原作者是一个名叫尼日利亚的人.摩西.也许我应该就此止步.无论如何,分散在整个代码中的是:

XRA A    ;MT
Run Code Online (Sandbox Code Playgroud)

我花了一段时间才弄明白这是什么.指令本身只是清除累加器.这是一个光滑的方式,虽然我不确定是否有优势.你可以这样做:

LDA 0
Run Code Online (Sandbox Code Playgroud)

但也许吧

XRA A
Run Code Online (Sandbox Code Playgroud)

保存一个字节或其他东西.什么是独占或累积器本身.结果当然总是为零.

回到MT - 空(得到它?)

这是我遇到的最好的.


jus*_*ase 5

""".........................:~+?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!"
Run Code Online (Sandbox Code Playgroud)


小智 5

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


小智 5

//Time log says you've been here for 15 hours GO HOME, your code is hobo
Run Code Online (Sandbox Code Playgroud)


小智 5

我们有一个小组项目,使用Min-Max树创建Connect 4 AI.在我们的移动评分功能中,我们计算了电路板的分数,并且在该代码块之上有以下评论:

// This is kind of almost useless
Run Code Online (Sandbox Code Playgroud)

但它变得更好.我们的导师给了我们一些原始人工智能的示例代码,他留下了很好的评论:

// 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.)
Run Code Online (Sandbox Code Playgroud)


Man*_*zzi 5

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

// load image 1 - JPEG 240x320
img = f1.getImage();
if (check(img))
{
   load(img, Constants.JPEG_240x320);
}

// load image 2 - JPEG 128x128
img = f2.getImage();
if (check(img))
{
   load(img, Constants.JPEG_128x128);
}

...

// load image 13 - GIF 256x256
img = f13.getImage();
if (check(img))
{
   load(img, Constants.GIF256x256);
}

// loaded all of the f**king images
Run Code Online (Sandbox Code Playgroud)

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


小智 5

我最喜欢的是这样的

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


小智 5

// woot, global var. I havent done this for a long time.
Run Code Online (Sandbox Code Playgroud)