От: | monax | ||
Дата: | 04.08.11 09:32 | ||
Оценка: |
At the SciPy 2010 conference, a speaker showed several short code samples and asked us what each sample did. The samples were clearly written, but we had no comments to provide context. This was the last sample.
def what( x, n ): if n < 0: n = -n x = 1.0 / x z = 1.0 while n > 0: if n % 2 == 1: z *= x x *= x n /= 2 return z
Now suppose you’re a contractor on the opposite side of the world from Sam. You have even less context than if you were in his office talking to his office mate. After a great deal of agony, you send your contribution back to Sam’s company. You comment your code beautifully, but Sam’s colleagues complain that your code is poorly written and that you didn’t solve the right problem.
Institutional memory is more valuable than source code comments. It costs a great deal to replace a programmer, even one who leaves behind well-commented code.