Craig R. McClanahan at [EMAIL PROTECTED] wrote:
> 
> In trivial experiments a long while back, I seem to recall that this trick
> worked if your constant was "static final".  But I haven't looked lately.

Yep... Setting a public static final boolean DEBUG = true/false; will behave
like an ifdef in C for something like:

If(DEBUG) logger.debug(...);

If DEBUG is set to true, logger.debug() will be compiled in, otherwise it'll
be left out.

> There are also some cases where you want to be able to set the debug level
> at runtime, without having to recompile.  In such cases, I typically am
> real liberal about debug statements when first creating a module, and then
> comment them out (versus removing them) in high-frequency-of-use portions
> of the code.  That way, you've got ready-made debug code to uncomment if
> you run into problems later.

I'm not arguing about le debug level, but, instead of commenting out pieces
of code (and then, when you want to do a debug build, you have to remove all
comments) it would be "nicer" to set a public static final boolean, and
instead of using comments, using the "if boolean".

Aesthetics, but I had to do that while checking the WARP connector to behave
like HTTP, and the source was full of comments. Using the static final
boolean I would have had to change just one line :)

As I said, it's just aesthetics...

    Pier

Reply via email to