maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emmanuel Venisse" <emman...@venisse.net>
Subject Re: cvs commit: maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/goal/phase GoalAttainmentPhase.java
Date Fri, 01 Oct 2004 12:03:18 GMT

----- Original Message ----- 
From: "Maczka Michal" <michal.maczka@imtf.ch>
To: "'Maven 2 Developers List'" <m2-dev@maven.apache.org>
Sent: Friday, October 01, 2004 10:44 AM
Subject: RE: cvs commit:
maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/goal/ph
ase GoalAttainmentPhase.java


>
> >   +    private String createPluginParameterRequiredMessage(
> > MojoDescriptor mojo, Parameter parameter )
> >   +    {
> >   +        StringBuffer message = new StringBuffer();
> >   +
> >   +        message.append( "The " + parameter.getName() ).
> >   +                append( " is required for the execution of the " ).
> >   +                append( mojo.getId() ).
> >   +                append( " mojo and cannot be null." );
> >   +
> >   +        return message.toString();
> >        }
> Jason!
>
> Any particular reason why are you using StringBuffers for such tasks? Is
it
> question of the style?
>
> AFAIK this will result of such code in exactly the same
> as:
>
>
> String message = "The " + parameter.getName() + " is required for the
> execution of the "  + mojo.getId() + " mojo and cannot be null." );
>
>
> I mean that byteycode & performance is identical

Yes for the Sun jdk, but it isn't the case for all bytecode generator.

>
> If I remember it is mentioned in JLS   and described in "effective java".

I think it's only a recommandation. If a generator doesn't use the
stringbuffer model, it's a correct bytecode but not optimized.

>
> StringBuffers are normally recommended if you need to use loops for
> constructing messages.
>
> I personally always use second form - but this is really the question of
> style - that's why I am asking if this is a style which you prefer?
>
>
> Michal
>


Mime
View raw message