在github的LTP项目(一个linux内核测试项目)的文档看到这么一句话不很理解,关于代码注释的危害.
Comments can sometimes save you day but they can easily do more harm than good. There has been several cases where comments and actual implementation were drifting slowly apart which yielded into API misuses and hard to find bugs. Remember there is only one thing worse than no documentation, wrong documentation.
我印象中不是鼓励大家进行代码注释嘛?这里面说Comments more harm than good 。
原因 :comments and actual implementation were drifting slowly apart
结果:API misuses and hard to find bugs.
因为自己英语不太好,用翻译软件也觉得生硬, 注释和实际实现之间的距离很近?导致API滥用和未知的错误?
请教下, 这几句到底是什么含义?API滥用以及未知的错误 又可能 会导致什么危害? 能举个具体的例子就更为感谢。
比注释更有用的是规范的命名和单一职责