首页 文章

你遇到的源代码中最好的评论是什么? [关闭]

提问于
浏览
360

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

30 回答

  • 1033
    #Christmas tree initializer  
        toConnect = []  
        toRead =   [  ]  
        toWrite = [    ]   
        primes = [      ]  
        responses = {}  
        remaining = {}
    
  • 589

    大约30页xslt的中间

    <!-- Here be dragons  -->
    
  • 412
    long long ago; /* in a galaxy far far away */
    
  • 913

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

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

    I'M SORRY!!!! 我无法自救.....!

    另一个,我实际上已经释放到野外,尽管我很想在一个不那么直观的课程中这样做:

    // 
    // 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
    //
    
  • 508
    Exception up = new Exception("Something is really wrong.");
    throw up;  //ha ha
    
  • 640
    //When I wrote this, only God and I understood what I was doing
    //Now, God only knows
    
  • 354
    stop(); // Hammertime!
    
  • 325

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

    // Autogenerated, do not edit. All changes will be undone.
    
  • 542
    // sometimes I believe compiler ignores all my comments
    
  • 719
    // 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.
    
  • 362

    //代码消毒以保护愚蠢 .
    使用系统;
    使用System.Collections.Generic;
    使用System.Text;
    使用System.Reflection;
    使用System.Web.UI;

    名称空间Mobile.Web.Control
    {
    /// <summary>
    ///用来解决理查德是一个他妈的白痴的 class
    /// </ summary>
    /// <备注>
    ///这点是为了解决他的糟糕设计,以便分页
    ///使用移动控件 . 主要问题是BindCompany()方法,
    ///他希望能够做到的一切 . 我希望他死了 .
    /// </备注>
    公共抽象类RichardIsAFuckingIdiotControl:MobileBaseControl,ICompanyProfileControl
    {
    protected abstract Pager Pager {get; }

    public void BindCompany(int companyId){}

    公共RichardIsAFuckingIdiotControl()
    {
    MakeSureNobodyAccidentallyGetsBittenByRichardsStupidity();
    }

    private void MakeSureNobodyAccidentallyGetsBittenByRichardsStupidity()
    {
    //确保没有人真正使用那个他妈的bindcompany方法
    MethodInfo m = this.GetType() . GetMethod(“BindCompany”,BindingFlags.DeclaredOnly |
    BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
    if(m!= null)
    {
    抛出新的RichardIsAFuckingIdiotException(“不!!不要使用他妈的BindCompany方法!!!”);
    }
    // P.S.这个方法是一个笑话......班上的其他人都很认真
    }

    /// <summary>
    ///如果该控件应该执行任何操作,则返回true
    ///根本没有这个请求 . 理查德认为加载是个好主意
    ///每个请求期间的整个网站,让事情变成自己
    ///关闭他还认为头巾和飞行员太阳镜是“他妈的”
    /// gnarly,伙计 . “
    /// </ 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();
    }

    //其余的还原接口成员
    公共抽象字符串MenuItemName {get;组; }
    公共抽象字符串MenuItemKey {get;组; }
    public abstract bool IsCapable(CapabilityCheck checker,int companyId);
    public abstract bool ShowInMenu {get; }
    public virtual Control CreateHeaderControl()
    {
    return null;
    }
    }
    }

    Update: 代码原作者has outed himself所以我必须在到期时给予信任 . Dan McKinley在我开始后不久离开了我所在的公司,他更多地谈论了这些代码,解释了一些背景以及"WTF's"所写的一些内容 .

  • 727
    // somedev1 -  6/7/02 Adding temporary tracking of Login screen
    // somedev2 -  5/22/07 Temporary my ass
    
  • 636
    // drunk, fix later
    

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

  • 352
    // Magic. Do not touch.
    
  • 592

    #define TRUE FALSE //Happy debugging suckers

  • 387
    // I'm sorry.
    
  • 946
    return 1; # returns 1
    
  • 1049
    /* This is O(scary), but seems quick enough in practice. */
    

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

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

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

  • 457
    long john; // silver
    
  • 431
    Catch (Exception e) {
     //who cares?
    }
    
  • 1052
    /**
     * Always returns true.
     */
    public boolean isAvailable() {
        return false;
    }
    

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

  • 496
    /*
     * 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.
     */
    
  • 1464
    try {
    
    } finally { // should never happen 
    
    }
    
  • 1056

    来自: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.
    
  • 355
    const int TEN=10; // As if the value of 10 will fluctuate...
    
  • 701

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

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

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

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

    endif出现在800号线附近)

  • 827
    //This code sucks, you know it and I know it.  
    //Move on and call me an idiot later.
    
  • 365
    // If this comment is removed the program will blow up
    

相关问题