你遇到过的源代码中最好的注释是什么?


当前回答

aComment = 'this is not aComment' # this is aComment
class T(object):
    def f(this):
        this is not aComment

其他回答

我的一个老老板总是说我们必须在内部使用我们自己的产品。“吃我们自己的狗粮……”

许多年后,我发现嵌入在一个临时同事所做的源代码中,他触及的每个函数都被标记为:

/* NOT FIT FOR HUMAN CONSUMPTION */

sqlite源文件顶部:

/*

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

*/

注意上面代码中的bug;我只是证明了它是正确的,并没有尝试过。

这是唐纳德·克努斯写的。

Case 1:
   ...
   break;
   ...
//I don't want do do this but [my coworker] says it's part of the code standard
default:
   break;

我告诉学员至少做一些异常处理。这是我在每一个db调用....返回

Catch (Exception e) {
    //eat it
}