學習,提高debug技能

http://www.javaworld.com/community/node/2927
Learning and Improving Your Debugging Skills
Programmers spend a high percentage of the time debugging rather than writing code.
程序員花在調試的時間比寫代碼的時間還多。
You probably had some training in learning a language or framework--but how did you learn to fix the defects in your software?
可能會有人培訓如何使用一個框架,但是卻很少培訓如何調試。
....省略很多字
   1. Be disciplined. Debugging is a process, said one developer, not a series of random events. Don't randomly tweak knobs; follow the code's execution process. Just like fixing a lawnmower, he said. Does part A get the input it needs? How about the output? If that's OK, move on.
有條理的,像割草工人一樣....
   2. To improve your skills, debug other people's code rather than your own. It will be easier to see the faults in the other person's assumptions than it is to see your own. You might do this as part of a cross-peer code review and cross-peer debugging. You will develop the ability to recognize the common causes of defects more quickly, promised one developer, and teach you to recognize (and abandon) your own bad development practices.
調試別人的代碼....
   3. Pretend you're the compiler. Find and correct as many errors as you can before pressing the Compile button. While most modern IDEs include integrated debuggers (like Visual Studio's Intellisense), you'll learn less from their automation than you will from consciously examining the process. (The same way you'll never learn to spell correctly by relying on a spell checker to do all the work.)
裝成編譯器的樣子,在按下編譯的時候多有意識去找出一些錯誤.....
   4. Learn to fix bugs as early in the development process as you can. That might mean something formalized, such as test-driven development. That also means devoting time to debugging your design instead of barreling into coding.
學習儘可能早的修復bug.... tdd....多花時間設計,別奮不顧身的跳進代碼..(redface.gif)
   5. Debugging is easiest when you can hold the whole system in your head. Don't make the mistake of focusing in on only one part of an application. Pay attention to the interrelationships between modules. Read the code at multiple levels of abstraction, advised one programmer. "Finding the bug is the hardest part, and it takes clear understanding of what multiple pieces of the code are doing," she said.
hold the whole system ,很重要,讓debug變得更簡單。
   6. Part of the same bit of advice, I think, is someone else's suggestion: gain a good understanding of the system one level down from what you are working on. "If you are debugging a system level C program, it helps to know some assembly and something about the OS," explained a system software lead engineer. "If you are debugging a J2EE app, it helps to know something about Java threads, RMI and GC." In many cases, he pointed out, error messages come from that one-level-down. "If you can understand what that means, it will help you figure out what is going wrong at your level of abstraction," he explained.
多瞭解地下一層。寫C的,可以多瞭解點操作系統級,寫Java可以多瞭解點虛擬機級別。用Java高級框架,就瞭解點Java,比如struts的,就瞭解點servlet,jsp等等。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章