`
Murcielago7998
  • 浏览: 3091 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

转自pda158的欢乐注释

阅读更多
相信每一个编程极客都知道什么是注释,也都知道如何在代码中添加注释,今天这篇文章中,我们将不会讨论如何添加注释,或者如何添加一个完美的注释,在今天的文章里,我们将给大家奉献一场来自全球开发人员的注释盛宴,看看大家是怎么在代码中添加自己富有想象力的注释吧,绝对会让你乐此不彼!
 
当然,如果你也有很多超有趣的注释,请留言和我们分享!我们的口号是:“快乐编程,娱乐注释” !!!
 
注重语法的注释
  1. return 1; # returns 1  
 
来自绝对菜鸟的注释
  1. // I am not sure if we need this, but too scared to delete. 
  2. ...  
  3. ... 
中文:个人不确认是不是需要,但是实在不敢删除
 
来自正直程序员的注释
  1. // I am not responsible of this code. 
  2. // They made me write it, against my will. 
中文:个人不负责这块的质量,因为他们逼迫我违心的写了这段代码
 
来自电影的注释
  1. options.BatchSize = 300; //Madness? THIS IS SPARTA! 
中文:疯了吧?这是斯巴达!
 
绝对尽责的注释
  1. i++; // increase i by 1 
中文:给变量i增加一个记数
 
绝对会被忽略的注释
  1. Catch (Exception e) { 
  2.  //who cares? 
  3. }  
中文:谁在意?
 
绝对不能信任注释
  1. /** 
  2.  * Always returns true. 
  3.  */ 
  4. public boolean isAvailable() { 
  5.     return false
中文:返回为true (编辑:永远不能相信注释)
 
典型的遗留系统代码里的注释
  1. /* 
  2.  * You may think you know what the following code does. 
  3.  * But you dont. Trust me. 
  4.  * Fiddle with it, and youll spend many a sleepless 
  5.  * night cursing the moment you thought youd be clever 
  6.  * enough to "optimize" the code below. 
  7.  * Now close this file and go play with something else. 
  8.  */  
中文:你可能相信你能看懂以下代码,但是其实绝对不可能,相信我。一旦你调试了,你绝对会后悔装聪明去尝试
优化这段代码。最好的方式是关闭文件,去玩点儿你喜欢的东西吧。
 
Java程序里经常能看到的“典型”注释
  1. try { 
  2.   
  3. finally { // should never happen  
  4.   
中文:绝对不会运行到这里
 
超级有自知之明的代码注释
  1. //This code sucks, you know it and I know it.   
  2. //Move on and call me an idiot later. 
中文:这段代码的确很挫,我知道你也知道,先不要骂我2B了,请先继续往下看
 
绝对有年头的注释
  1. long long ago; /* in a galaxy far far away */  
中文:在很远很远的银河系外 (编辑:这段代码能运行,绝对是个奇迹)
 
绝对无法挑剔的注释
  1. /////////////////////////////////////// this is a well commented line 
中文:这注释绝对完全没有问题
 
保证正确体位的注释
  1. // I don't know why I need this, but it stops the people being upside-down 
  2. x = -x; 
中文:我也不知道为什么需要这个,但是这个能保持大家不会倒立
 
来自Java1.2 SwingUtilities的注释
  1. doRun.run();  // ... "a doo run run". 
最好的帮助你了解递归的注释
  1. # To understand recursion, see the bottom of this file  
  2.   
  3. At the bottom of the file: 
  4.   
  5. # To understand recursion, see the top of this file 
中文:#如果想了解递归,请看最下面的注释...如果想了解递归,请看最上面的注释
 
绝对督促你工作的注释
  1. /* Please work */ 
绝对菜鸟注释
  1. //I am not sure why this works but it fixes the problem.  
中文:不知道为什么,但是的确解决了这个问题。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics