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


当前回答

在开发团队中每个人都在大量编辑的代码文件头部:

'Avert your eyes, it may take on other forms!

好弗兰德斯。

其他回答

在20世纪80年代早期的某个时候,我们在PL/I中为公用事业编写财务建模代码。接到一个客户的电话,说代码在评论之后就爆炸了

/* Honest this works */

这家伙用了我们的标准金融方程花了大约15页的代数把一堆代码组合成一个方程。在三里岛事件后,当公用事业公司不得不以巨大的代价注销他们的核电站时,这个方程失败了,因为FIXED BIN 15(整数)溢出,如果代数没有发生,就不会发生这种溢出。

这不是严格意义上的评论,但是…

那是20世纪90年代中期,我正在进行一次大的迁移:小软件供应商,大客户,压力很大。我们有很多转移门柱的东西;这个项目很难控制。我是关键的开发人员,但对系统还不熟悉,而另一个开发人员是供应商的所有者/创始人。

在几个月没有按时完成任务,也没有让客户满意之后,公司的所有者/创始人找来了另一名远程工作的开发人员。(我可以大胆地说,新开发人员的技能和经验都不如我。)

好吧,这个新人对我已经做过的代码做了一些更改,然后一两个月后我又回到了代码的同一区域,其中有一些我以前没有见过的变量。他的名字叫StupidMark。

伙计,这是不对的。我的意思是,有团队合作方面的考虑,但是:在这个环境中,变量名可能会出现在运行时错误消息中。我只是说说而已。

在我看来,那个新人的代码并没有让我们更接近可交付的产品,这让侮辱变得更伤人了。

当我读到这篇关于我负责维护的项目的文章时,我哭了。

//Write Code Here

我仍然畏缩:)

我经历了一个睡眠不足的编程过程,开始只写引用自《搏击俱乐部》的评论。

多年后,我仍然在浏览代码,发现了一条让我发笑的评论。大多数只是随机的想法。然而,我确实保持我的评论行比率相当好!

// This shouldn't happen. The only way this can happen is if the
// <code>JFileChooser</code> has returned a <code>File</code> that doesn't exist
// on the system. If this happens we can't recover, and there is more than likely
// a rip in the space time continuum that the user is too distracted by to notice
// anything else.

 /**
   * This method leverages collective synergy to drive "outside of the box"
   * thinking and formulate key objectives into a win-win game plan with a
   * quality-driven approach that focuses on empowering key players to drive-up
   * their core competencies and increase expectations with an all-around
   * initiative to drive down the bottom-line. I really wanted to work the word
   * "mandrolic" in there, but that word always makes me want to punch myself in
   * the face.
   */
private void updateFileCountLabel() {
// long live COM'n'Roll
public enum StatusCode
{
        //success codes
        S_OK                                            = 1,
        S_NONE                                          = 2,
        S_SQL_OPERATIONS_LISTS_EMPTY                    = 3,

        //error codes
        E_NO_MATCHING_END_FOUND                         = -1,
        E_SEQUENCE_NUMBER_NOT_FOUND_AT_BEGINNING        = -2,
        E_SEQUENCE_NUMBER_NOT_FOUND_AT_END              = -3,
        E_FORWARD_AND_BACKWARD_OPS_COUNT_DO_NOT_MATCH   = -4,
        E_FORWARD_AND_BACKWARD_IDS_DO_NOT_MATCH         = -5,
        E_IDS_DO_NOT_MATCH                              = -6
}