令人笑喷的56个代码注释,最后几个老衲实在憋不住了。。。

关注人瑞IT内推圈

回复“大厂”领取整理好的面试资料

老衲不请自来,给大家献上一波神注释,供施主们娱乐娱乐!

0./* * Dear Maintainer * * Once you are done trying to ‘optimize’ this routine, * and you have realized what a terrible mistake that was, * please increment the following counter as a warning * to the next guy. * * total_hours_wasted_here = 73 *

亲爱的维护者

如果尝试对这段程序进行'优化'

并且您已经意识到这是一个多么可怕的错误,

请增加以下计数器的个数用来对后来人进行警告

这里总共浪费的时间= 73 

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

例外=新的异常("确实有问题。")

放弃; //哈哈

2.

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

当我写下这个的时候,只有上帝和我明白我在做什么 

现在,只有上帝知道

3.

// sometimes I believe compiler ignores all my comments

有时,我会相信编译器会忽略我所有的注释

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

谨以此代码,献给我的妻子达琳,感谢她一直支持着我,以及我的三个孩子和一条狗。

5.// drunk, fix later

喝多了,改天再修

6.

// Magic. Do not touch.

魔法!不要碰。

7.​​​​​​​

// I'm sorry.

抱歉。

8.​​​​​​​

return 1; # returns 1

返回 1;# 返回 1

9.​​​​​​​

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

捕获(异常e)

谁在乎?

10.

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

代码返回 false ,注释则始终返回 true

11.​​​​​​​

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

你可能相信你能看懂以下代码,

但是其实绝对不可能,相信我。

一旦你调试了,你绝对会后悔装聪明去尝试优化这段代码。

最好的方式是关闭文件,

去玩点儿你喜欢的东西吧!

12.​​​​​​​

try {} finally { // should never happen}

绝对不会运行到这里

13.​​​​​​​

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

好像 10 的值会波动...

14.​​​​​​​

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

这段代码的确很烂,我知道你也知道,

先不要骂我,请先接着往下看

15.​​​​​​​

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

如果删了此处注释,程序就炸了

16.​​​​​​​

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

我不负责这个代码

他们强迫我写,违背了我的意愿。

17.​​​​​​​

/* Please work */

请工作

18.​​​​​​​

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

没有注释,

很难写,

所以它应该很难阅读

19.​​​​​​​

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

疯了吧?这是斯巴达!

20.​​​​​​​

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

如果这个代码能够正常工作,那么是Paul DiLascia写的 

否则,我也不知道是谁写的

21.​​​​​​​

// Peter wrote this, nobody knows what it does, don't change it!

这是彼得写的,没人知道它是做什么的,别改动!

22.​​​​​​​

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

不管怎么费尽心力,人会受伤的时候就会受伤。by 村上春树

23.​​​​​​​

// I have to find a better job

我必须找到更好的工作

24.​​​​​​​

// Real programmers don’t comment their code. // If it was hard to write, // it should be hard to understand.

真正的程序员不注释他们的代码。

如果很难写

应该是难以理解

25.​​​​​​​

// This is black magic// from// *Some stackoverlow link// Don’t play with magic, it can BITE.

这是来自stackoverlow的黑魔法

别玩魔法,它会咬人的

26.​​​​​​​

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

对于我即将犯下的罪行,希望詹姆斯·高斯林(James Gosling)能原谅我

27.​​​​​​​

// Comment this later

稍后对此注释

28.​​​​​​​

// Remove this if you wanna be fired

如果你想被炒鱿鱼,就删除它

29.​​​​​​​

}catch(Exception ex){// Houston, we have a problem}

Houston,我们有一个问题

30.​​​​​​​

// I can’t divide with zero, so I have to divide with something very similar result = number / 0.00000000000001.

我不能除以0,所以我要除以一个非常相似的数

31.​​​​​​​

int getRandomNumber(){Return 4; // chosen by fair dice roll.// guaranteed to be random.}

通过公平掷骰子选择

保证是随机的

32.​​​​​​​

#TODO: Figure out what I’m doing here and comment accordingly.

弄清楚这里做什么并相应地添加注释

33.​​​​​​​

// If this code is still being used when it stops working, then// you have my permission to shoot me. Oh, you won't be able// to - I'll be dead...

如果这段代码停止工作时还在使用,

杀了我吧,哦~你不能这么做

我死了......

34.​​​​​​​

// If you are reading this, that means you have been put in charge of my previous project.// I am sorry, so sorry for you. Godspeed.

如果你看到了这里,这意味着你已经被任命为我之前的项目的负责人。

对不起,真抱歉。祝你好运。

35.​​​​​​​

// I wrote this while drunk, I don’t know what it does, // but if you remove it the program breaks.

我是在喝醉的时候写的,所以不知道它是干什么用的

但如果你删除它,程序就会中断

36.​​​​​​​

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

这段代码以前是有效的,但是我的猫决定在我的键盘上跑一趟

37.​​​​​​​

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

在很远很远的银河系外 (这段代码能运行,绝对是个奇迹)

38.​​​​​​​

long john; // silver

金银岛

39.​​​​​​​

#define TRUE FALSE // Happy debugging suckers

快乐的去调试你的代码吧,哈哈

40.​​​​​​​

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

未来亲爱的我,请原谅我 

我说不出来我有多抱歉

41.​​​​​​​

// private instance variable for storing agepublic static int age;

用于存储年龄的私有实例变量

42.​​​​​​​

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

虽然我不知道为什么这样管用,但它却是修复了问题

43.​​​​​​​

last = first; /* Biblical reference */

最后即是开始,圣经引用

44.​​​​​​​

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!!!}

不用多说,基本上你完蛋了

45.​​​​​​​

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

如果你再删除一次

看在上帝的份上,我要关闭你

这段代码不是什么“奇怪的东西”

那就是身份验证

46.​​​​​​​

long time; /* know C */

过来很久时间才知道

47.​​​​​​​

// Abandon all hope ye who enter beyond this point

入此门者了断希望

48.​​​​​​​

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

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

49.​​​​​​​

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

糟糕,我们应该做点什么

50.​​​​​​​

// TODO make this work

用TODO做这件事

51.​​​​​​​

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

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

52.​​​​​​​

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

在这里设置断点-你永远作不到十全十美

53.​​​​​​​

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

作者放弃此源代码的版权

这是一份祝福,而不是法律通知

愿你行善不作恶。

愿你宽恕自己,宽恕他人

愿你自由分享,永远不要超过付出

54.​​​​​​​

// I'm not sure what I did

我不确定我做了什么

55.​​​​​​​

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

这是垃圾代码,但现在是凌晨3点,我需要让他能够正常运行

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值