Re: Setting a variable (NDEBUG) during compilation of a JDK 1.1 applet
- From: "Oliver Wong" <owong@xxxxxxxxxxxxxx>
- Date: Mon, 13 Mar 2006 21:08:45 GMT
"Mitch" <spudtheimpaler@xxxxxxxxx> wrote in message news:4415D6A6.7050002@xxxxxxxxxxxx
Oliver Wong wrote:"Mitch" <spudtheimpaler@xxxxxxxxx> wrote in message news:4415C4CE.704@xxxxxxxxxxxx
Now I am young and naive so am sure this hasn't been mentioned for good reason
if( debug == true )
{
do debug stuff
}
now my question is why? are you referring to a method of debugging that involves the ide in some way (breakpoints etc) that you can do with other languages / ides etc that you cant with java. What am I missing? You learn a lot from others questions but sometimes you just can't keep up :)
Why what? Is your question "Why don't you do that?" or is it "Why did you do that?" or something else?
My question was more along the lines of "Is it ok to do that?". Most of the reading I have done on debugging turns me against flooding code with println's etc. and tries to encourage the use of the IDE's debug features.
Don't use println's (I'm presuming you mean println calls on System.out or System.err) for logging. Instead, try to learn how to use Java's logging API. There's a tutorial from Sun at http://java.sun.com/j2se/1.4.2/docs/guide/util/logging/overview.html but it's a bit difficult to read (in my opinion anyway).
But logging should be used for recording what's going on. If you're writing a web server, for example, your user might want it to record every request that was made for statistical purposes. Or if something "funny" happens, you might want to log that so that someone can look over it later to check for security breaches. If an error happens, you might want to produce a log that the user can e-mail into you so that you can try to figure out what the problem was, without asking the user to manually try to replicate the problem.
For debugging, you should definitely use a debugger. It allows you to step through the program one line at a time, and inspect the contents of variables at any point in the program, which largely eliminates the need for println statements that are only used for debugging.
- Oliver
.
- References:
- Setting a variable (NDEBUG) during compilation of a JDK 1.1 applet
- From: A. Farber
- Re: Setting a variable (NDEBUG) during compilation of a JDK 1.1 applet
- From: Thomas Hawtin
- Re: Setting a variable (NDEBUG) during compilation of a JDK 1.1 applet
- From: A. Farber
- Re: Setting a variable (NDEBUG) during compilation of a JDK 1.1 applet
- From: Thomas Hawtin
- Re: Setting a variable (NDEBUG) during compilation of a JDK 1.1 applet
- From: Mitch
- Re: Setting a variable (NDEBUG) during compilation of a JDK 1.1 applet
- From: Oliver Wong
- Re: Setting a variable (NDEBUG) during compilation of a JDK 1.1 applet
- From: Mitch
- Setting a variable (NDEBUG) during compilation of a JDK 1.1 applet
- Prev by Date: Re: should getInstance() be idempotent?
- Next by Date: Re: how to practice JDBC programming?
- Previous by thread: Re: Setting a variable (NDEBUG) during compilation of a JDK 1.1 applet
- Next by thread: Re: Setting a variable (NDEBUG) during compilation of a JDK 1.1 applet
- Index(es):
Relevant Pages
|