Search code examples
javablackberry

Commenting out System.out.println


Do System.out.println(...) calls pose any effect if left in BlackBerry code or any other programming language?

When removed, the compilation time may be reduced, but is there any particular other reason to remove them?


Solution

  • There are a couple of things you need to know before using System.out.println() on Blackberry:

    1. Once you print out something to the standard output any person that has your application installed on the device will be able to see them. All they need to do is to attach the device to the simulator and run in debug mode. So make sure you do not print out anything sensitive such as passwords, class names etc. in the released application.

    2. The performance overhead that the System.out.println() itself makes is minimal, especially when the output stream is not attached to anything (i.e. Device is not connected and not in debug mode).

    I myself rather use Blackberry preprocessor to be able to disable all logs before making a release. For this reason I define a logging directive LOGGING and then in my code:

    //#ifdef LOGGING
    System.out.println("LOGGING is enabled");
    //#endif
    

    For more on how to use preprocessors in Blackberry Eclipse plugin see this.