10分钟
柯林汉定律 (Kernighan's Law)
调试在一开始就比编写程序困难一倍。因此,按照定义,如果你的代码写得非常巧妙,那么你就没有足够的能力来调试它。 布莱恩·柯林汉 (Brian Kernighan)
柯林汉定律是以布莱恩·柯林汉 (Brian Kernighan) 的名字命名的,引述自柯林汉和普劳格 (P.J. Plauger) 的《编程格调》 (The Elements of Programming Style) 一书中的一句话:
每个人都知道,调试在一开始就比编写程序困难一倍。那么,如果您在编写它时尽可能地巧妙,又如何来调试它?
尽管这有些夸张,但它提出的论点是,简单的代码会比复杂的代码更可取,因为调试复杂代码的过程中出现的任何问题都会十分棘手,甚至无法解决。
参见:
学员评价