30 多个有内味道且笑死的人代码注释

时间:2022-07-24
本文章向大家介绍30 多个有内味道且笑死的人代码注释,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

作者:xor 译者:前端小智 来源:medium

代码注释,有些人说它太丑,也有些人说它是标准和良好的做法。在本文中, 列出了一些在编程中遇到的有趣的代码注释。

注释 1

// Weed Effect ! 

这是杂草效应的意思?不是很懂,有谁知道,可以留言一下。

注释 2

/**** 原文 *****/
//The following code was written by <developer name>.
// Unless it doesn't work, then I have no idea who wrote it.

/**** 自译 *****/
// 以下代码是由<developer name>编写的。
// 除非它不起作用,否则我不知道是谁写的。

注释 3

/**** 原文 *****/
// Ad Index scheming and plotting - Those with
//    heart conditions are advised to not continue

/**** 自译 *****/
// 广告索引的设计和绘图模块
// 建议不要深入阅读,否则容得得心脏病

注释 4

/**** 原文 *****/
// nobody read comments!

/**** 自译 *****/
// 没人会读的注释

注释 5

/**** 原文 *****/
i++; // increment i

/**** 自译 *****/
i++; // 自增 i

注释 6

/**** 原文 *****/
// Magic. Do not touch.


/**** 自译 *****/
// 这里已经结界,不要碰.

注释 7

/**** 原文 *****/
// sometimes I believe compiler ignores all my comments

/**** 自译 *****/
// 有时我相信编译器会忽略我的所有注释

注释 8

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

/**** 自译 *****/
// 我对此代码不承担任何责任。
// 是他们强迫我让我写的,这已违背了我的意愿。

注释 9

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

/**** 自译 *****/
// 亲爱的程序媛
// 
// 一旦你尝试“优化”此代码,并意识到这是一个可怕的错误,
// 请增加以下计数器,以警告下一个人
//  total_hours_wasted_here = 42

注释 10

/**** 原文 *****/

# To understand recursion, see the bottom of this file
At the bottom of the file
# To understand recursion, see the top of this file


/**** 自译 *****/

# 要了解递归,请参见此文件的底部

在文件的底部

# 要了解递归,请参见此文件的顶部

注释 11

/**** 原文 *****/

// I will give you two of my seventy-two virgins if you can fix this.

/**** 自译 *****/
// 如果你能解决这个问题,我就把我七十二个处女中的两个给你。

注释 12

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


/**** 自译 *****/
// 你好,未来帅气的我,请原谅我。
// 我现在无法表达我的歉意,因为我写下了这段代码。

注释 13

/**** 原文 *****/
//private instance variable for storing age
public static int age;

/**** 自译 *****/
// 用于存储年龄的私有实例变量
public static int age;

注释 14

/**** 原文 *****/
const int TEN=10; // s if the value of 10 will fluctuate...


/**** 自译 *****/
const int TEN=10; // 10 是会改变的值

注释 15

/**** 原文 *****/

/* You are not meant to understand this */


/**** 自译 *****/

/* 你不应该理解这一点 */

注释 16

/**** 原文 *****/
/*
* TODO: Remove this function

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

*/


/**** 自译 *****/
/*
* TODO: 删除函数

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

*/

注释 17

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


/**** 自译 *****/

// 当我写这段代码,只有上帝和我知道这是在做什么
...

// 现在,只有上帝知道这段代码在做什么

注释 18

/**** 原文 *****/

// drunk, fix later

/**** 自译 *****/

// 喝醉了,待会解决

注释 19

/**** 原文 *****/

// I'm sorry.

/**** 自译 *****/

// 我很抱歉

注释 20

/**** 原文 *****/

// I am not responsible of this code.

/**** 自译 *****/

// 我对此代码不承担任何责任。

注释 21

/**** 原文 *****/
// I have to find a better job

/**** 自译 *****/

// 我必须找到更好的工作

注释 22

/**** 原文 *****/

// Joe is sorry
A few hundred lines later...
// Harry is sorry too

/**** 自译 *****/

// 老五抱歉了

写了几百行代码之后...

// 小五对不住了

注释 23

/**** 原文 *****/
# Christmas tree initializer  
    toConnect = []  
    toRead =   [  ]  
    toWrite = [    ]   
    primes = [      ]  
    responses = {}  
    remaining = {}
    
    
/**** 自译 *****/

# 圣诞树初始化器
    toConnect = []  
    toRead =   [  ]  
    toWrite = [    ]   
    primes = [      ]  
    responses = {}  
    remaining = {} 

注释 24

/**** 原文 *****/

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

/**** 自译 *****/

Catch (Exception e) {
 // 管它呢?
}

注释 25

/**** 原文 *****/

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

/**** 自译 *****/

IE7更新,这仍然是错误的代码,看来 IE8 还有很长的路要走:)

注释 26

/**** 原文 *****/

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

/**** 自译 *****/

// 如果这个代码有效的话,它就是由 前端小智 编写的。如果出错了,我也不知道是谁写的。

注释 27

/**** 原文 *****/

// This comment is self explanatory.

/**** 自译 *****/

// 这个注释不言自明。

注释 28

/**** 原文 *****/

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

/**** 自译 *****/

int main(void)
/* 程序从这里开始 */

注释 29

/**** 原文 *****/

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

/**** 自译 *****/

// 我不确定我们是否需要这个,但又害怕删除

注释 30

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


/**** 自译 *****/
/**
 * 总是返回 true.
 */
public boolean isAvailable() {
    return false;
}

注释 31

/**** 原文 *****/

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

/**** 自译 *****/

// 自动生成,不要编辑。所有的更改都将被撤销。

注释 32

/**** 原文 *****/

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


/**** 自译 *****/
// 破解ie浏览器(假设ie是一个浏览器)

注释 33

/**** 原文 *****/

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

/**** 自译 *****/

/////////////////////////////////////// 这是一个很好的注释

注释 34

/**** 原文 *****/

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

/**** 自译 *****/

// 编译先生,请不要读取这个

注释 35

/**** 原文 *****/

// All bugs added by David S. Miller

/**** 自译 *****/

// 所有 bug 都是由 老王 添加的

注释 36

/**** 原文 *****/

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


/**** 自译 *****/

// 如果你现在在认真详细的阅读这段代码,那么写的这段代码应该是没有问题的。

注释 37

/**** 原文 *****/

Catch (Exception e) {
    //eat it
}

/**** 自译 *****/

Catch (Exception e) {
    // 吃掉它
}

注释 38

/**** 原文 *****/

//todo: never to be implemented

/**** 自译 *****/

// todo:永远不会执行

注释 39

/**** 原文 *****/

// simply copied from another code

/**** 自译 *****/

// 别问,问我也是从另一个代码拷贝过来的

注释 40

/**** 原文 *****/

//Please comment on your source code

/**** 自译 *****/

// 拜托啦,请把你写的代码注释一下

注释 41

/**** 原文 *****/
# as you can see: I comment the code!


/**** 自译 *****/

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

注释 42

/**** 原文 *****/

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

/**** 自译 *****/

// 如果我再看到这个,我会带枪去工作

注释 43

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  .__  _.-   
  ##         | |  |  ``/  /`  /
  ##        /,_|  |   /,_/   /
  ##           /,_/      '`-'
  ##

注释 44

/**** 原文 *****/

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


/**** 自译 *****/

long long ago; /* 在遥远的星系中 */

注释 45

/**** 原文 *****/
try {

} finally { // should never happen 

}

/**** 自译 *****/
try {

} finally { // 这里永远不会被执行

}

注释 46

/**** 原文 *****/

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


/**** 自译 *****/

// 啊啊啊!你永远都不会明白为什么这个方法有效。

注释 47

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

/**** 自译 *****/

// 这个公式是正确的,如果你不相信我,自己动手算一下

注释 48

/**** 原文 *****/

// This was clearly written under duress

/**** 自译 *****/

// 这显然是在胁迫下写的

注释 49

                                   .='  ' .`/,/!(=)Zm.           
                     .._,,._..  ,-`- `, ` -` -`\7//WW.         
                ,v=~/.-,-- -!|V-s.)iT-|s|-.'   `///mK%.        
              v!`i!-.e]-g`bT/i(/[=.Z/m)K(YNYi..   /-]i44M.       
            v`/,`|v]-DvLcfZ/eV/iDLND/ZK@%8W[Z..   `/d!Z8m       
           //,c(2(X/NYNY8]ZZ/bZd()/7WY%WKKW)   -'|(][%4.      
         ,\ic(e)WX@WKKZKDKWMZ8(b5/ZK8]Z7%ffVM,   -.Y!bNMi      
         /-iit5N)KWG%%8%%%%W8%ZWM(8YZvD)XN(@.  [   ]!/GXW[      
        / ))G8NMN%W%%%%%%%%%%8KK@WZKYK*ZG5KMi,-   vi[NZGM[      
       i!(44Y8K%8%%%**~YZYZ@%%%%%4KWZ/PKN)ZDZ7   c=//WZK%!      
      ,vYtMZW8W%%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)8Mi!-,-/i-v((tKNGN%W%%            
       'M8M88(Zd))///((|DtDY\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/ZGt5((+)L'-,,/  -)X(NWW%%           
                      `~`MZ/DZGNZG5(((,    ,t\Z)KW%@           
                         'M8K%8GN85(5///]i!vK)85W%%f           
                           YWWKKKKWZ8G54X/GGMeK@WM8%@            
                            !M8%8%48WG@KWYbW%WWW%%%@             
                              VM%WKWK%8K%%8WWWW%%%@`             
                                ~*%%%%%%W%%%%%%%@~               
                                   ~*MM%%%%%%@f`                 
                                       '''''

注释 50

/************************************************************
        *                                                           *
        *  .=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-.       *
        *   |                     ______                     |      *
        *   |                  .-"      "-.                  |      *
        *   |                 /                             |      *
        *   |     _          |              |          _     |      *
        *   |    (          |,  .-.  .-.  ,|         / )    |      *
        *   |     > "=._     | )(__/  __)( |     _.=" <     |      *
        *   |    (_/"=._"=._ |/     /     | _.="_.="_)    |      *
        *   |           "=._"(_     ^^     _)"_.="           |      *
        *   |               "=__|IIIIII|__/="               |      *
        *   |              _.="| IIIIII/ |"=._              |      *
        *   |    _     _.="_.="          /"=._"=._     _    |      *
        *   |   ( _.="_.="     `--------`     "=._"=._/ )   |      *
        *   |    > _.="                            "=._ <    |      *
        *   |   (_/                                    _)   |      *
        *   |                                                |      *
        *   '-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='      *
        *                                                           *
        *      LASCIATE OGNI SPERANZA, VOI CH'ENTRATE               *              LEAVE EVERY HOPE, YOU COME IN
        *************************************************************/

注释 51

/**** 原文 *****/
// This was clearly written under duress

/**** 自译 *****/
// 如果将来我读到这篇文章,我会回到过去并自杀。

注释 52

/**** 原文 *****/
// This was clearly written under duress

/**** 自译 *****/
// 乱七八糟的 SQL语句,但它有效,所以请不要触摸它

注释 53

//        .==.        .==.          
//       //`^\      //^`\         
//      // ^ ^(__/)/^ ^^\        
//     //^ ^^ ^/6  6 ^^ ^ \       
//    //^ ^^ ^/( .. )^ ^ ^ \      
//   // ^^ ^/| v""v |/^ ^ ^\     
//  // ^^// /  `~~`   /^ ^\    
//  -----------------------------
/// 这是条龙

注释54

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

/**** 自译 *****/
// 这是垃圾代码,但现在是凌晨3点,我需要把它修好。

注释55

// 我不确定我做了什么

注释56

如果你想被解雇,请将其删除

注释 57

// 切勿动以下代码,否则我会踢你的 PP