You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Mark Thomas <ma...@apache.org> on 2021/06/30 12:51:16 UTC

Possible code clean-up

All,

I wanted to get some feedback on a possible code clean-up. Currently, we 
declare literal arrays like this:

String[] array = new String[] { "value1", "value2", "value3" );

We could simplify these declarations to:

String[] array = { "value1", "value2", "value3" );

There doesn't appear to be a checkstyle rule to enforce one approach or 
the other.

Assuming someone is willing to spend the time to make these changes what 
do the folks here think?

I think the code is a little cleaner and therefore easier to read but 
the benefit seems minimal. I'm not sure it is worth "fixing" the 
existing code.

We could use this going forward as the opportunity arises. The 
inconsistency in style bugs me a little - but not so much I couldn't 
live with it.

Thoughts?

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: Possible code clean-up

Posted by Martin Grigorov <mg...@apache.org>.
On Wed, Jun 30, 2021 at 3:51 PM Mark Thomas <ma...@apache.org> wrote:

> All,
>
> I wanted to get some feedback on a possible code clean-up. Currently, we
> declare literal arrays like this:
>
> String[] array = new String[] { "value1", "value2", "value3" );
>
> We could simplify these declarations to:
>
> String[] array = { "value1", "value2", "value3" );
>
> There doesn't appear to be a checkstyle rule to enforce one approach or
> the other.
>
> Assuming someone is willing to spend the time to make these changes what
> do the folks here think?
>
> I think the code is a little cleaner and therefore easier to read but
> the benefit seems minimal. I'm not sure it is worth "fixing" the
> existing code.
>
> We could use this going forward as the opportunity arises. The
> inconsistency in style bugs me a little - but not so much I couldn't
> live with it.
>
> Thoughts?
>

+1 to simplify !


>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

Re: Possible code clean-up

Posted by Konstantin Kolinko <kn...@gmail.com>.
ср, 30 июн. 2021 г. в 18:26, Christopher Schultz <ch...@christopherschultz.net>:
>
> All,
>
> On 6/30/21 11:23, Christopher Schultz wrote:
> > Mark,
> >
> > On 6/30/21 08:51, Mark Thomas wrote:
> >> All,
> >>
> >> I wanted to get some feedback on a possible code clean-up. Currently,
> >> we declare literal arrays like this:
> >>
> >> String[] array = new String[] { "value1", "value2", "value3" );
> >>
> >> We could simplify these declarations to:
> >>
> >> String[] array = { "value1", "value2", "value3" );
> >>
> >> [...]
> >
> > Hmm. Is there a minimum compiler version necessary to use that syntax?
> > I've literally never seen it before. Maybe it's just always been there...
>
> Been there forever:
> http://titanium.cs.berkeley.edu/doc/java-langspec-1.0/10.doc.html#11358

I also wondered. Just tested that it works with Java 6. More examples here:
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html

+1 to simplify.

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: Possible code clean-up

Posted by Christopher Schultz <ch...@christopherschultz.net>.
All,

On 6/30/21 11:23, Christopher Schultz wrote:
> Mark,
> 
> On 6/30/21 08:51, Mark Thomas wrote:
>> All,
>>
>> I wanted to get some feedback on a possible code clean-up. Currently, 
>> we declare literal arrays like this:
>>
>> String[] array = new String[] { "value1", "value2", "value3" );
>>
>> We could simplify these declarations to:
>>
>> String[] array = { "value1", "value2", "value3" );
>>
>> There doesn't appear to be a checkstyle rule to enforce one approach 
>> or the other.
>>
>> Assuming someone is willing to spend the time to make these changes 
>> what do the folks here think?
>>
>> I think the code is a little cleaner and therefore easier to read but 
>> the benefit seems minimal. I'm not sure it is worth "fixing" the 
>> existing code.
>>
>> We could use this going forward as the opportunity arises. The 
>> inconsistency in style bugs me a little - but not so much I couldn't 
>> live with it.
>>
>> Thoughts?
> 
> Hmm. Is there a minimum compiler version necessary to use that syntax? 
> I've literally never seen it before. Maybe it's just always been there...

Been there forever:
http://titanium.cs.berkeley.edu/doc/java-langspec-1.0/10.doc.html#11358

+0 for me, I guess

-chris

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: Possible code clean-up

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Mark,

On 6/30/21 08:51, Mark Thomas wrote:
> All,
> 
> I wanted to get some feedback on a possible code clean-up. Currently, we 
> declare literal arrays like this:
> 
> String[] array = new String[] { "value1", "value2", "value3" );
> 
> We could simplify these declarations to:
> 
> String[] array = { "value1", "value2", "value3" );
> 
> There doesn't appear to be a checkstyle rule to enforce one approach or 
> the other.
> 
> Assuming someone is willing to spend the time to make these changes what 
> do the folks here think?
> 
> I think the code is a little cleaner and therefore easier to read but 
> the benefit seems minimal. I'm not sure it is worth "fixing" the 
> existing code.
> 
> We could use this going forward as the opportunity arises. The 
> inconsistency in style bugs me a little - but not so much I couldn't 
> live with it.
> 
> Thoughts?

Hmm. Is there a minimum compiler version necessary to use that syntax? 
I've literally never seen it before. Maybe it's just always been there...

-chris

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org