Hi!

Am I hitting another controversy topic? ;-)

Example from ImapHandler.java

        catch ( IOException e ) {
            if ( getLogger().isErrorEnabled() ) {
                StringBuffer exceptionBuffer =
                        new StringBuffer( 256 )
                        .append( "Cannot open connection from " )
                        .append( remoteHost )
                        .append( " (" )
                        .append( remoteIP )
                        .append( "): " )
                        .append( e.getMessage() );
                getLogger().error( exceptionBuffer.toString(), e );
            }
            throw e;
        }

IMHO this blows up the code and reduces the readability by only bringing
a negligible performance enhancement.
IMO the bottleneck is IO and in the big frameworks (JavaMail ;-) and not
in simple string computation.

Better readability will bring our users less bugs and costs only a few 
microseconds.

IMO StringBuffer is only mandatory when dealing with really big Strings
(like message headers/body) or when doing really much concats.
I would use isDebugEnabled() only inside a loop and not in a per command
issue.

BTW:

catch ( IOException e ) {
   getLogger().error( "Cannot open connection from " + remoteHost + " ("
                      + remoteIP + "): " + e.getMessage() );
   throw e;
}

To make it clear: I'm not proposing refactoring all around James. I just
don't want to make extensive use of isLogEnabled() and StringBuffer().
I'm going to remove it from Imap code where I think it brings more
readability. 

WDYT?

Joachim




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to