At this point, we have systematically fixed the first bug
using the scientific method to systematically come up with a hypothesis and refine it,
refine it again, possibly come up with alternatives until we end up with a diagnosis.
So if you're an experienced programmer--and I assume you are--
you may now wonder, "Why on Earth should I actually go through all these
explicit steps if I can just jump into my debugger and fix the problem right away?"
It's actually likely that you have spotted the problem at the very moment you saw the code.
If you're a very experienced programmer, you can probably spot errors like these
in hundreds and hundreds of lines from a distance of several hundred meters.
You just look at the code and immediately see, "Well, there's something fishy in there."
And all of this is, of course, right.
There are many problems which you can immediately see
and which you can immediately fix within 5 minutes
including the one we just discussed
And it's perfectly okay, if it only takes 5 minutes,
to jump right into your editor and to fix things,
to jump into your interactive debugger and fix things,
as long as it doesn't take more than 5 minutes--
because what happens if it takes more than that?
A questo punto, abbiamo corretto sistematicamente il primo bug
usando il metodo scientifico per giungere ad un'ipotesi e affinarla,
affinarla ancora, trovare possibilmente delle alternative finche' non concluderemo con una diagnosi.
Quindi se sei un programmatore esperto, e suppongo che tu lo sia,
potresti chiederti: "Perche' accidenti dovrei mai farmi tutti questi
passaggi, visto che potrei lanciare il mio debugger e sistemare il problema in un attimo?
E' effettivamente possibile che tu abbia individuato il problema nel momento stesso in cui hai visto il codice.
Se sei un programmatore molto esperto puoi probabilmente trovare errori come questi
tra centinaia e centinaia di righe da centinaia di metri di distanza.
Tu guardi il codice e immediatamente vedi: "Uela, qui c'e' qualcosa che mi puzza".
E tutto cio, ovviamente, ci sta.
Ci sono molti problemi che tu puoi vedere immediatamente
e che puoi sistemare immediatamente in 5 minuti,
incluso quello di cui abbiamo appena discusso.
Ed e' perfettamente plausibile, ci vogliono solo 5 minuti
per entrare nel tuo editor e sistemare le cose,
per entrare nel tuo debugger interattivo e sistemare le cose,
almeno finche' non ci vogliono piu' di 5 minuti,
perche', cosa succederebbe se ci vuole di piu'?
これで最初のバグを系統的に修正できました
科学的手法で系統的に仮説を立て立証します
そして再検証や別の仮説を立てることで
仮説を立証していくのです
あなたは恐らく経験豊富なプログラマだと思いますが
"どうしてこんな細かいステップを
行わなければいけないんだ?"
"デバッガが使えれば問題をすぐ修正できるのに"と
思っていますよね
実際コードを見た瞬間に問題が分かることもあります
非常に経験豊かなプログラマなら
膨大なラインの中のエラーを
すぐ発見できるかもしれません
コードを見た瞬間に
エラーがありそうな場所が分かるからです
もちろんこれは間違いではありません
すぐ見つけることができて
5分以内に修正できるような問題はたくさんあります
今解説してきたようなエラーもそうでしょう
エディタ画面や対話型デバッガで
修正を行うことが5分でできるのであれば
全く問題ありません
ただし5分以上かかる場合は違います
もしそれ以上時間をかけたらどうなるでしょうか?
现在,我们已经系统地修复了第一个bug,
使用科学方法,系统地提出假设、改进假设,
或者提出新的假设,直到得出诊断结论。
所以如果你是个经验丰富的程序员--我假设你是--
你可能会好奇,“为什么我非得这样做,
这样刻板,而不是直接打开调试器去解决问题呢?”
事实上,等代码完成时,你可能已经有很多的错误了。
如果你是个经验丰富的程序员,你可能已经遗留了许多这样的错误,
甚至有数百处,互相隔着几百行。
你只是看着代码,“咦,这里有些问题”
这些当然也没错。
只是他们属于你可以立马发现的问题,
所以你可以在5分钟中搞定他们,
就包括我们刚才讨论的这个。
如果只要5分钟,当然没问题,
你就打开编辑器去修改吧,
运行调试器,把问题解决掉,
只要它花费的时间不超过5分钟--
但如果时间超过了,会发生什么呢?想想。