這 56 個代碼注釋讓我笑吐了
程序員的幽默(ID:humor1024)整理
老衲不請自來,
給大家獻(xiàn)上一波神注釋
供施主們娛樂娛樂
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
*親愛的維護(hù)者
如果嘗試對這段程序進(jìn)行'優(yōu)化'
并且您已經(jīng)意識到這是一個多么可怕的錯誤,
請?jiān)黾右韵掠?jì)數(shù)器的個數(shù)用來對后來人進(jìn)行警告
這里總共浪費(fèi)的時間= 73
1.
Exception up = new Exception("Something is really wrong.");
throw up; //ha ha
例外=新的異常("確實(shí)有問題。")
放棄; //哈哈
// When I wrote this, only God and I understood what I was doing
// Now, God only knows
當(dāng)我寫下這個的時候,只有上帝和我明白我在做什么
現(xiàn)在,只有上帝知道
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.
謹(jǐn)以此代碼,獻(xiàn)給我的妻子達(dá)琳,感謝她一直支持著我,以及我的三個孩子和一條狗。
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.
*/
你可能相信你能看懂以下代碼,
但是其實(shí)絕對不可能,相信我。
一旦你調(diào)試了,你絕對會后悔裝聰明去嘗試優(yōu)化這段代碼。
最好的方式是關(guān)閉文件,
去玩點(diǎn)兒你喜歡的東西吧!
12.
try {
} finally { // should never happen
}
絕對不會運(yùn)行到這里
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.
我不負(fù)責(zé)這個代碼
他們強(qiáng)迫我寫,違背了我的意愿。
17.
/* Please work */
請工作
18.
// no comments for you
// it was hard to write
// so it should be hard to read
沒有注釋,
很難寫,
所以它應(yīng)該很難閱讀
19.
options.BatchSize = 300; //Madness? THIS IS SPARTA!
瘋了吧?這是斯巴達(dá)!
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();
不管怎么費(fèi)盡心力,人會受傷的時候就會受傷。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.
真正的程序員不注釋他們的代碼。
如果很難寫
應(yīng)該是難以理解
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,所以我要除以一個非常相似的數(shù)
31.
int getRandomNumber()
{
Return 4; // chosen by fair dice roll.
// guaranteed to be random.
}
通過公平擲骰子選擇
保證是隨機(jī)的
32.
#TODO: Figure out what I’m doing here and comment accordingly.
弄清楚這里做什么并相應(yīng)地添加注釋
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.
如果你看到了這里,這意味著你已經(jīng)被任命為我之前的項(xiàng)目的負(fù)責(zé)人。
對不起,真抱歉。祝你好運(yùn)。
35.
// I wrote this while drunk, I don’t know what it does,
// but if you remove it the program breaks.
我是在喝醉的時候?qū)懙模圆恢浪歉墒裁从玫?/p>
但如果你刪除它,程序就會中斷
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 */
在很遠(yuǎn)很遠(yuǎn)的銀河系外 (這段代碼能運(yùn)行,絕對是個奇跡)
38.
long john; // silver
金銀島
39.
#define TRUE FALSE // Happy debugging suckers
快樂的去調(diào)試你的代碼吧,哈哈
40.
// Dear future me. Please forgive me.
// I can't even begin to express how sorry I am.
未來親愛的我,請?jiān)徫?nbsp;
我說不出來我有多抱歉
41.
// private instance variable for storing age
public static int age;
用于存儲年齡的私有實(shí)例變量
42.
// I am not sure why this works but it fixes the problem.
雖然我不知道為什么這樣管用,但它卻是修復(fù)了問題
43.
last = first; /* Biblical reference */
最后即是開始,圣經(jīng)引用
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.
如果你再刪除一次
看在上帝的份上,我要關(guān)閉你
這段代碼不是什么“奇怪的東西”
那就是身份驗(yàn)證
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. */
啊啊啊!你永遠(yuǎn)都不會明白為什么這個方法有效
49.
catch (Ex as Exception) {
// oh crap, we should do something.
}
糟糕,我們應(yīng)該做點(diǎn)什么
50.
// TODO make this work
用TODO做這件事
51.
// If you're reading this, then my program is probably a success
如果你現(xiàn)在在認(rèn)真詳細(xì)的閱讀這段代碼,那么寫的這段代碼應(yīng)該是沒有問題的
52.
// set break point here - you'll never reach it
在這里設(shè)置斷點(diǎn)-你永遠(yuǎn)作不到十全十美
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.
*/
作者放棄此源代碼的版權(quán)
這是一份祝福,而不是法律通知
愿你行善不作惡。
愿你寬恕自己,寬恕他人
愿你自由分享,永遠(yuǎn)不要超過付出
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.
這是垃圾代碼,但現(xiàn)在是凌晨3點(diǎn),我需要讓他能夠正常運(yùn)行

