令人笑噴的56個代碼注釋,最后幾個老衲實在憋不住了。。。
閱讀本文大概需要 5 分鐘。
來自:程序員的幽默
/** 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*
親愛的維護者 如果嘗試對這段程序進行'優(yōu)化' 并且您已經(jīng)意識到這是一個多么可怕的錯誤, 請增加以下計數(shù)器的個數(shù)用來對后來人進行警告 這里總共浪費的時間= 73
Exception up = new Exception("Something is really wrong.");throw up; //ha ha
例外=新的異常("確實有問題。") 放棄; //哈哈
// When I wrote this, only God and I understood what I was doing// Now, God only knows
當(dāng)我寫下這個的時候,只有上帝和我明白我在做什么 現(xiàn)在,只有上帝知道
// sometimes I believe compiler ignores all my comments
有時,我會相信編譯器會忽略我所有的注釋
// 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.
謹以此代碼,獻給我的妻子達琳,感謝她一直支持著我,以及我的三個孩子和一條狗。
// drunk, fix later
喝多了,改天再修
// Magic. Do not touch.
魔法!不要碰。
// I'm sorry.
抱歉。
return 1; # returns 1
返回 1;# 返回 1
Catch (Exception e) {//who cares?}
捕獲(異常e) 誰在乎?
/*** Always returns true.*/public boolean isAvailable() {return false;}
代碼返回 false ,注釋則始終返回 true
/** 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.*/
你可能相信你能看懂以下代碼, 但是其實絕對不可能,相信我。 一旦你調(diào)試了,你絕對會后悔裝聰明去嘗試優(yōu)化這段代碼。 最好的方式是關(guān)閉文件, 去玩點兒你喜歡的東西吧!
try {} finally { // should never happen}
絕對不會運行到這里
const int TEN=10; // As if the value of 10 will fluctuate...
好像 10 的值會波動...
// This code sucks, you know it and I know it.// Move on and call me an idiot later.
這段代碼的確很爛,我知道你也知道, 先不要罵我,請先接著往下看
// If this comment is removed the program will blow up
如果刪了此處注釋,程序就炸了
// I am not responsible of this code.// They made me write it, against my will.
我不負責(zé)這個代碼 他們強迫我寫,違背了我的意愿。
/* Please work */
請工作
// no comments for you// it was hard to write// so it should be hard to read
沒有注釋, 很難寫, 所以它應(yīng)該很難閱讀
options.BatchSize = 300; //Madness? THIS IS SPARTA!
瘋了吧?這是斯巴達!
// If this code works, it was written by Paul DiLascia.// If not, I don't know who wrote it
如果這個代碼能夠正常工作,那么是Paul DiLascia寫的 否則,我也不知道是誰寫的
// Peter wrote this, nobody knows what it does, don't change it!
這是彼得寫的,沒人知道它是做什么的,別改動!
/** Logger */private Logger logger = Logger.getLogger();
不管怎么費盡心力,人會受傷的時候就會受傷。by 村上春樹
// I have to find a better job
我必須找到更好的工作
// Real programmers don’t comment their code.// If it was hard to write,// it should be hard to understand.
真正的程序員不注釋他們的代碼。 如果很難寫 應(yīng)該是難以理解
// This is black magic// from// *Some stackoverlow link// Don’t play with magic, it can BITE.
這是來自stackoverlow的黑魔法 別玩魔法,它會咬人的
// For the sins I am about to commit, may James Gosling forgive me
對于我即將犯下的罪行,希望詹姆斯·高斯林(James Gosling)能原諒我
// Comment this later
稍后對此注釋
// Remove this if you wanna be fired
如果你想被炒魷魚,就刪除它
}catch(Exception ex){// Houston, we have a problem}
Houston,我們有一個問題
// I can’t divide with zero, so I have to divide with something very similarresult = number / 0.00000000000001.
我不能除以0,所以我要除以一個非常相似的數(shù)
int getRandomNumber(){Return 4; // chosen by fair dice roll.// guaranteed to be random.}
通過公平擲骰子選擇 保證是隨機的
#TODO: Figure out what I’m doing here and comment accordingly.
弄清楚這里做什么并相應(yīng)地添加注釋
// 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...
如果這段代碼停止工作時還在使用, 殺了我吧,哦~你不能這么做 我死了......
// 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)被任命為我之前的項目的負責(zé)人。 對不起,真抱歉。祝你好運。
// I wrote this while drunk, I don’t know what it does,// but if you remove it the program breaks.
我是在喝醉的時候?qū)懙模圆恢浪歉墒裁从玫?/section> 但如果你刪除它,程序就會中斷
// This code worked before, but my cat decided to take a// trip across my keyboard...
這段代碼以前是有效的,但是我的貓決定在我的鍵盤上跑一趟
long long ago; /* in a galaxy far far away */
在很遠很遠的銀河系外 (這段代碼能運行,絕對是個奇跡)
long john; // silver
金銀島
# TRUE FALSE // Happy debugging suckers
快樂的去調(diào)試你的代碼吧,哈哈
// Dear future me. Please forgive me.// I can't even begin to express how sorry I am.
未來親愛的我,請原諒我 我說不出來我有多抱歉
// private instance variable for storing agepublic static int age;
用于存儲年齡的私有實例變量
// I am not sure why this works but it fixes the problem.
雖然我不知道為什么這樣管用,但它卻是修復(fù)了問題
last = first; /* Biblical reference */
最后即是開始,圣經(jīng)引用
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!!!}
不用多說,基本上你完蛋了
// 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)閉你 這段代碼不是什么“奇怪的東西” 那就是身份驗證
long time; /* know C */
過來很久時間才知道
// Abandon all hope ye who enter beyond this point
入此門者了斷希望
/* Ah ah ah! You'll never understand why this one works. */
啊啊啊!你永遠都不會明白為什么這個方法有效
catch (Ex as Exception) {// oh crap, we should do something.}
糟糕,我們應(yīng)該做點什么
// TODO make this work
用TODO做這件事
// If you're reading this, then my program is probably a success
如果你現(xiàn)在在認真詳細的閱讀這段代碼,那么寫的這段代碼應(yīng)該是沒有問題的
// set break point here - you'll never reach it
在這里設(shè)置斷點-你永遠作不到十全十美
/*** 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) 這是一份祝福,而不是法律通知 愿你行善不作惡。 愿你寬恕自己,寬恕他人 愿你自由分享,永遠不要超過付出
// I'm not sure what I did
我不確定我做了什么
// This is crap code but it's 3 a.m. and I need to get this working.
這是垃圾代碼,但現(xiàn)在是凌晨3點,我需要讓他能夠正常運行
推薦閱讀:
太強了,終于徹底搞懂 Nginx 的五大應(yīng)用場景~
內(nèi)容包含Java基礎(chǔ)、JavaWeb、MySQL性能優(yōu)化、JVM、鎖、百萬并發(fā)、消息隊列、高性能緩存、反射、Spring全家桶原理、微服務(wù)、Zookeeper、數(shù)據(jù)結(jié)構(gòu)、限流熔斷降級......等技術(shù)棧!
?戳閱讀原文領(lǐng)取! 朕已閱 
評論
圖片
表情

