 |
Debuggers: a modern 'Dr. Jekyll and Mr. Hyde'
Posted by schaefa on December 02, 2003 at 02:16 PM | Comments (5)
I have to admit that I only use a debugger if someone wants to show me a problem he discovered within his debugger. Other than that I never used a debugger since I started to code in Java even thought I used debuggers before in C and C++. But when I started with Java there were no debuggers and so I have to rely on debugging statements and stack traces. When the first useful debuggers became available I had to switch between multiple OSs that, of course, one or more of them were not supported, yet. Finally, today, where many excellent debuggers are available but I really do not need them anymore and even think they do more harm than good. Dr. Jekyll or the debugger as useful tool can easily turn into a Mr. Hyde or a time sink if misused or overused.
Beside that for certain problems a debugger is a great tool it prevents many developers from focusing on the real problem that their code is plain buggy and that they have no clue where to look for. Stepping through a program only works well when the developer can remember where he came from and where he is heading to. But most of the time people lose that and when they found the problem they do not know how they got there in the first place and so the have to step through multiple times until they understand what caused the problem and how to fix it. A much better way is to look at your code, log output and, if you have, your test cases to localize your problem area and then focus on this area. For me this does mostly lead to a solution and I do not need a debugger anymore. With an AOP framework and a decompiler I can also debug third party library without a debugger.
You might think that I do not have to debug much and hardly have to deal with unknown code. As a J2EE application server developer I have to deal with many third party libraries, deployed application that are written in the company but also by customers and therefore I spend half of my time debugging code to find the problems and to fix it or to suggest a solution.
A debugger is like a telescope looking at the night sky and you have to find the North Star. With the naked eye you will find it pretty easily even when you have to remember that the rear leg of the Big Bear directs to it. The telescope needs to be directed pretty closely to the target otherwise you will miss it and waste a lot of time. Actually that would not be so bad but it prevents you also from learning the big picture of the night sky and to navigate easily through all the stars and nebulas. In addition a debugger can only work when program is not working as expected and therefore does not help in any way to prevent a bug. A debugger does not or barely work with race conditions (multi threading), class loading issues, network problems or any other runtime issues.
Here some tips how programs can be debugged without a debugger:
- Use a logging tool like ‘log4j’ to log the progress, warnings and exception stack traces
- Use ‘jUnit’ to write test cases and suites to make sure your code is working as expected and that the code does not regress due changes
- Narrow down the problem and check for previous warnings that may indicate the cause of the problem
- Use an AOP framework like ‘AspectJ’ or ‘AspectWerkz’ to introduce logging without changing the code
- Minimize side effects of other components or additional libraries
- Expect runtime problems from multi threading, class loading etc
For me this is good enough to master all bugs so far. But if you feel comfortable to use a debugger then do it even thought I would suggest that you try it first without and if all else fails fall back to the debugger. This will speed up the bug fixing process and make sure that you fix the cause and not mask the symptoms.
Happy Coding – Andy
Bookmark blog post: del.icio.us Digg DZone Furl Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment
-
a debugger vs. logging
i see my debugger as a simple way to watch the state information of my application as it runs. this is functionally no different than add log statements all over the place. it's simpler because i don't have to recompile to add them in, and then remember to take them back out again after i finish.
debuggers are useful sometimes, but they're no magic wand. they won't help you if you're a poor programmer, but they do save time if you are.
in otherwords, no, my leatherman won't help me change the tire on my jeep, nor help me reengineer the yugo. but that doesn't mean it's worthless. it's still great for tweaking the occasional nut. :-)
--
-------------------------------
Derek C. Anderson
Senior Software Engineer
Computer Sciences Corporation
http://kered.org/professional
public@kered.org
-------------------------------
Posted by: keredson on December 03, 2003 at 09:04 AM
-
Are Debuggers just for "debugging"?
I personally make use of Debuggers not so much as a tool for debugging, but as a way of verifying the dynamic behavior of programs. This is especially useful for programs you have not written yourself, or haven't picked up for a long time.
For example: "Hmm, I wonder if and when this method get's called" - lets put in a breakpoint and see if it get's hit. This can be a lot faster and less intruisive than putting in a logging statement. Keep in mind, this is a different process from using an IDE to find all the code segments that call a particular method, it's about finding out if the dynamic behavior of the program results in it being called, which are two seperate things.
Posted by: agherring on December 03, 2003 at 03:10 PM
-
Good when you need them
I think that most people overuse debuggers for the very reasons you mention. However, they do have their uses. I personally like JSwat (freely available) because I created a simple launch shell script that can easily launch just about any Java app with a single command. For those few situations when I am totally bewildered, the tool is invaluable. This most often happens with unexpected interactions regarding public APIs that don't quite work as predicted.
Posted by: tlaurenzo on December 04, 2003 at 10:12 AM
-
wow power leveling
wow powerleveling
wow power leveling
wow gold
wow items
feelingame.com
wow tips
Most Valuable WOW Power Leveling Service
wow power leveling faq
cheap wow power leveling
wow power leveling
wow powerleveling
wow power lvl
Posted by: wowleveling3 on December 13, 2007 at 09:38 PM
-
网络è¥é”€è½¯ä»¶
网络è¥é”€è½¯ä»¶
网络è¥é”€è½¯ä»¶
群å‘软件
群å‘软件
---
群å‘软件
网络è¥é”€è½¯ä»¶
论å›ç¾¤å‘软件
网站排å软件
群å‘软件
推广å°åŠ©æ‰‹ç ´è§£ç‰ˆ
论å›ç¾¤å‘软件
网站排å软件
群å‘软件
推èç»™ä½ å¾ˆå¥½çš„ç¾¤å‘软件和信æ¯ç¾¤å‘软件和供求群å‘软件
推èç»™ä½ å¾ˆå¥½çš„ç¾¤å‘软件和信æ¯ç¾¤å‘软件和供求群å‘软件åšå®¢ç¾¤å‘软件网络è¥é”€è½¯ä»¶ç½‘络è¥é”€è½¯ä»¶
网站排å软件网站排å软件网站优化软件信æ¯ç¾¤å‘软件信æ¯ç¾¤å‘软件信æ¯ç¾¤å‘软件论å›ç¾¤å‘软件网站推广软件网站推广软件åšå®¢ç¾¤å‘软件åšå®¢ç¾¤å‘软件
群å‘软件群å‘软件åšå®¢ç¾¤å‘软件论å›ç¾¤å‘软件网络è¥é”€è½¯ä»¶è®ºå›ç¾¤å‘软件
ä¿¡æ¯ç¾¤å‘软件推广软件网站推广软件网络è¥é”€è½¯ä»¶ç½‘站推广软件群å‘软件网站排å软件网站推广软件åšå®¢ç¾¤å‘软件论å›ç¾¤å‘软件群å‘软件网站排å软件网站推广软件åšå®¢ç¾¤å‘软件论å›ç¾¤å‘软件
网站排å软件
åšå®¢ç¾¤å‘软件
网站排å软件
网站推广软件
群å‘软件信æ¯ç¾¤å‘软件
å…费论å›ç¾¤å‘软件
论å›ç¾¤å‘软件
网站排å软件
å…è´¹åšå®¢ç¾¤å‘软件
网站推广软件
群å‘软件
åšå®¢ç¾¤å‘软件
网站排å软件
网站推广软件
群å‘软件信æ¯ç¾¤å‘软件
å…费论å›ç¾¤å‘软件
论å›ç¾¤å‘软件
网站排å软件
å…è´¹åšå®¢ç¾¤å‘软件
åšå®¢ç¾¤å‘软件
ä¿¡æ¯ç¾¤å‘软件
论å›ç¾¤å‘软件
ä¿¡æ¯ç¾¤å‘软件
åšå®¢ç¾¤å‘软件
qq群å‘软件
邮件群å‘软件
åšå®¢ç¾¤å»ºè½¯ä»¶
ä¼ä¸šå录æœç´¢è½¯ä»¶
ä¿¡æ¯ç¾¤å‘软件
邮件群å‘软件
论å›ç¾¤å‘软件
åšå®¢ç¾¤å‘软件
网站推广软件
网络è¥é”€è½¯ä»¶
全能è¥é”€ç ´è§£ç‰ˆ
网络è¥é”€è½¯ä»¶
论å›ç¾¤å‘软件
论å›ç¾¤å‘软件
论å›ç¾¤å‘软件
网络è¥é”€è½¯ä»¶
ä¿¡æ¯ç¾¤å‘软件
ä¿¡æ¯ç¾¤å‘软件
ä¿¡æ¯ç¾¤å‘软件
群å‘软件
论å›ç¾¤å‘软件
群å‘软件
网络è¥é”€è½¯ä»¶
网站推广软件
Posted by: u89io98 on December 25, 2007 at 11:14 PM
|