关于javascript:30-多个有内味道且笑死的人代码注释

17次阅读

共计 7962 个字符,预计需要花费 20 分钟才能阅读完成。

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

点赞再看,微信搜寻 【大迁世界】 关注这个没有大厂背景,但有着一股向上踊跃心态人。本文 GitHub https://github.com/qq44924588… 上曾经收录,文章的已分类,也整顿了很多我的文档,和教程材料。

代码正文,有些人说它太丑,也有些人说它是规范和良好的做法。在本文中,列出了一些在编程中遇到的乏味的代码正文。

正文 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/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`                 
                                       '''''

正文 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

编辑中可能存在的 bug 没法实时晓得,预先为了解决这些 bug, 花了大量的工夫进行 log 调试,这边顺便给大家举荐一个好用的 BUG 监控工具 Fundebug。

原文:https://medium.com/javascript…

交换

文章每周继续更新,能够微信搜寻 【大迁世界】 第一工夫浏览,回复 【福利】 有多份前端视频等着你,本文 GitHub https://github.com/qq449245884/xiaozhi 曾经收录,欢送 Star。

正文完
 0