You are viewing a plain text version of this content. The canonical link for it is here.
Posted to m2-dev@maven.apache.org by Maczka Michal <mi...@imtf.ch> on 2004/10/01 10:44:08 UTC
RE: cvs commit: maven-components/maven-core/src/main/java/org/apa
che/maven/lifecycle/goal/phase 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
If I remember it is mentioned in JLS and described in "effective java".
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
Re: cvs commit: maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/goal/phase GoalAttainmentPhase.java
Posted by Emmanuel Venisse <em...@venisse.net>.
----- Original Message -----
From: "Maczka Michal" <mi...@imtf.ch>
To: "'Maven 2 Developers List'" <m2...@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
>