当源代码注释指示有问题时

开发人员有自己的愤世嫉俗的幽默感。 例如,考虑一下Geek和Poke关于如何侮辱开发人员的观点

但是,比在网站上发布内容更好的幽默感。 有源代码注释。 因为您现在可以咯咯笑,所以请写下机智的话语,然后等待您的同事在3-4年后才发现您的幽默感(当您久违了,在另一个项目,部门或公司工作)。 这不是玩世不恭的最终方式吗?

例如,我曾经在以前的雇主的旧版源代码中遇到过这段难得的Javadoc:

/**
 * NEVER EVER TOUCH THIS METHOD OR EVERYTHING
 * WILL EXPLODE!!!!!
 */

但是错误在于这种方法! 大约有500行和80个缩进字符的怪物! 所以我去了,首先修复了Javadoc:

/**
 * NEVER EVER TOUCH THIS METHOD OR EVERYTHING
 * WILL EXPLODE!!!!!
 * ^^^^^^^^^^^^^^^^^
 * Chicken!
 */

如果您有空闲时间(或几个小时)来阅读其他机智和愤世嫉俗的注释,请深入研究这个令人敬畏的Stack Overflow问题,其中包括代码中最重要的549条注释提取物史蒂夫Weet

我曾经想出了一个我认为是解决一个特别棘手问题的绝妙解决方案,回想起来,这有点麻烦,并且大量使用了宏程序宏。 几年后,我从维护程序员那里发现了这个评论

/*
The Total Perspective Vortex derives its picture of
the whole Universe on the principle of extrapolated
matter analyses.

To explain - since every piece of matter in the
Universe is in some way affected by every other
piece of matter in the Universe, it is in theory
possible to extrapolate the whole of creation -
every sun, every planet, their orbits, their
composition and their economic and social history
from, say, one small Macro.

The man who invented the Total Perspective Vortex
did so basically in order to annoy the IT
department.

Steve Weet - for that was his name - was a dreamer,
a thinker, a speculative philosopher or, as some
would have it, a slacker.

And they would nag him incessantly about the
utterly inordinate amount of time he spent staring
out into space, or mulling over the mechanics of
Chelsea FC, or doing spectrographic analyses of
macros.

"Have some sense of proportion!" they would say,
sometimes as often as thirty-eight times in a
single day.

And so he built the Total Perspective Vortex - just
to show them.

And into one end he plugged the whole of reality as
extrapolated from one macro, and into the other
end he plugged the IT department: so that when he
turned it on they saw in one instant the whole
infinity of creation and theirselves in relation to
it.

To Steve Weet's horror, the shock completely
annihilated their brains; but to his satisfaction
he realized that he had proved conclusively that if
life is going to exist in a Universe of this size,
then the one thing it cannot afford to have is a
sense of proportion.
*/

参考: 当源代码注释指出我们的JCG合作伙伴 Lukas Eder在Java,SQL和JOOQ博客上出现问题时。

翻译自: https://www.javacodegeeks.com/2013/12/when-source-code-comments-indicate-trouble.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值