7

笑哭丨谁的代码注释我都不服,就服你的!

 2 years ago
source link: http://www.androidchina.net/7542.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

什么是代码注释,如何在代码中添加注释,相信每一位了解编程的人并不陌生。注释里往往有很多有趣的脑洞和「真心话」。今天我们一起去看看那些6到飞起,被玩坏了的幽默注释吧。
a89765b8-9743-4929-b2eb-d1ff36b8cba3.gif

信息量太大的注释系列——

01 你造么?我是菜鸟!的注释

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

中文:个人不确认是不是需要,但是实在不敢删除

02 「我能怎么办?我也很绝望啊!」的注释

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

中文:个人不负责这块的质量,因为他们逼迫我违心的写了这段代码
ca465232-2022-40ed-94fc-d46a253e773d.png

03 来自斯巴达勇士一般嘶吼的注释

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

中文:疯了吧?这是斯巴达!
d7fdb4c7-77d6-4941-adf3-0b7b40fc9b8f.png

04 程序员了无牵挂时写下的注释

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

中文:谁在意?

05 「打死我,我也不会信」的注释

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

中文:返回为true

06 「我写的代码最牛X」的注释

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

中文:你可能相信你能看懂以下代码,但是其实绝对不可能,相信我。一旦你调试了,你绝对会后悔装聪明去尝试优化这段代码。最好的方式是关闭文件,去玩点儿你喜欢的东西吧

07 Java程序里经常能看到的「典型」注释

try { } finally { // should never happen }

中文:绝对不会运行到这里

08 不自信到让看到注释的人有些心疼的注释

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

中文:这段代码的确很挫,我知道你也知道,先不要骂我2B,请先接着往下看
875c13cc-fc4f-4276-b44b-a1e6a5d70dc7.png

09 绝对是「星战迷」的注释

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

中文:在很远很远的银河系外 (这段代码能运行,绝对是个奇迹)
0d808de4-9df7-40af-907b-2db79cd9137e.png

10 老司机一不小心开了车的注释

double penetration; // ouch

中文:我擦!(注:简单来说,double penetration 代表一种「体位姿势」,大家自行百度or谷歌吧~)
2e5600d4-478b-479d-bc34-0f233ce54edc.png

11 最能帮助你了解递归的注释

# To understand recursion, see the bottom of this file At the bottom of the file: # To understand recursion, see the top of this file中文: #如果想了解递归,请看最下面的注释 … #如果想了解递归,请看最上面的注释

12 一不小心暴露你家庭地位的注释

(a != b) ? b : a //和老婆意见不一致的时候听她的,意见一致的时候听我的。

13 以为上个WC会有好心人帮忙做完工作的注释

这里还没有完善,先去下WC,如果你看到了,可以帮忙补上相关代码,谢谢!

14 结果,老板在我去WC的时候偷偷的在代码里加了这样的注释……

/* Please work harder*/
f844998f-5246-4f77-8a9f-1e8cf9591fc5.png

从WC回来看到这样一行注释的我,已哭晕在电脑前……

逼格满满的注释:

34406a1b-feb0-410a-9bbf-027f69448f46.png

303309fa-ebd7-4e9d-92d0-2f9ff4b25067.png

7c5d5187-e013-4dd4-a3e2-712ae9fd06a4.png

8fef542c-8d9d-4e06-a220-5285438187ba.png

转载请注明:Android开发中文站 » 笑哭丨谁的代码注释我都不服,就服你的!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK