你遇到过的源代码中最好的注释是什么?
当前回答
整个函数非常棒(来自Linux的sunhme.c驱动程序,用于被Sun戏称为“快乐套餐”的网卡)。因为在那之前的卡片是“巨无霸”。明白了吗?明白了吗?)
static void happy_meal_tcvr_write(struct happy_meal *hp,
void __iomem *tregs, int reg,
unsigned short value)
{
int tries = TCVR_WRITE_TRIES;
ASD(("happy_meal_tcvr_write: reg=0x%02x value=%04x\n", reg, value));
/* Welcome to Sun Microsystems, can I take your order please? */
if (!(hp->happy_flags & HFLAG_FENABLE)) {
happy_meal_bb_write(hp, tregs, reg, value);
return;
}
/* Would you like fries with that? */
hme_write32(hp, tregs + TCVR_FRAME,
(FRAME_WRITE | (hp->paddr << 23) |
((reg & 0xff) << 18) | (value & 0xffff)));
while (!(hme_read32(hp, tregs + TCVR_FRAME) & 0x10000) && --tries)
udelay(20);
/* Anything else? */
if (!tries)
printk(KERN_ERR "happy meal: Aieee, transceiver MIF write bolixed\n");
/* Fifty-two cents is your change, have a nice day. */
}
其他回答
// This part is more difficult
在方法的顶部。
大概有5行。
并不难。
这是唯一的评论。
在整个应用程序中。
我在重用我很久以前写的一个PHP类时发现了这一点。我仍然不记得那里有什么,我仍然发现它没有任何用处……我甚至不记得我写过那篇评论;所以当我找到它的时候,我真的笑出声来了。
try
{
// Some database logic
}
catch (Exception $ex)
{
// sure, it looks silly and I honestly cant remember what code used to go here... but i swear i will
// find a use for this code.... eventually....
throw $ex;
}
// this is really complicated
没有其他评论了
我在一家大型投资银行看到,该银行要求记录和评论所有应用程序中断
Without a crash
Or mighty bang
The sync disk
Did it's process hang
Case 1:
...
break;
...
//I don't want do do this but [my coworker] says it's part of the code standard
default:
break;
推荐文章
- 在构建中编写注释的语法是什么?gradle文件?
- Java注释中的/**和/*
- 有没有办法注释掉.ASPX页面中的标记?
- Jenkins:注释可以添加到Jenkins文件中吗?
- TypeScript注释的语法记录在哪里?
- CSV文件可以有注释吗?
- 什么是自文档化代码?它能取代文档化良好的代码吗?
- 在erb中添加注释的最佳方法
- 为什么Python没有多行注释?
- 我应该在批处理文件中使用哪种注释风格?
- 如何在Office VBA编辑器中注释和取消注释代码块
- “# noqa”在Python注释中是什么意思?
- 我可以向pip需求文件添加注释吗?
- 你遇到过的源代码中最好的注释是什么?
- 在Bash中创建多行注释的方法?