Re: Setting a variable (NDEBUG) during compilation of a JDK 1.1 applet




"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

.



Relevant Pages

  • Re: Office or InDesign breaks VS 2005 debugging?
    ... Given tha I was using and debugging the sub-projects in this solution before ... some getting used to) and the debug symbols for the child project are no ...
    (microsoft.public.vsnet.debugging)
  • Re: Cant Debug COM Interface
    ... When I start to debug the application the DLL is ... a com client in vb.net which is referencing the interface of the COM Server ... If I use this application as Host application I can debug without ... For debugging I can start the ...
    (microsoft.public.vsnet.debugging)
  • Re: Windows Service in C#
    ... Depending on what level of logging you need log4net or the Enterprise Library logging block may be of use. ... I'd start by checking the event log in the application section on the machine where the errors are occuring at just to make sure something hasn't already been logged. ... In this way you can use the debugger against the service in the same way as if you were debugging a standard windows executable. ... This works, but a drawback of this method is that it doesn't allow you to debug the process from the start, so you can miss events you need to see. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: C++ Workable Mainframe Debuggers
    ... you have to be able to read assembler to do ... IBM Debug Tool for z/OS is available. ... You can license Debug Tool as MLC or, in the form of the Debug Tool ... For graphical debugging use Rational Developer for System z (or ...
    (bit.listserv.ibm-main)
  • Re: Need help with my logic
    ... Hand Execution ... This will save you a lot of time when you write (and debug) large programs. ... In each method put at least one debugging statement at the head of a method that accepts information to show the arguments: ...
    (comp.lang.java.programmer)