You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Mladen Turk <mt...@apache.org> on 2006/11/28 14:40:46 UTC

[TC6] Minimum coding style

Hi,

Just committed two files, and again I've bumped
upon the coding style.
Although it seems we are quite good relating to the
tabs, the trailing spaces are a real mess in some files.
There are lots of files where we have
if (...) {
followed with the one or more spaces.
Also there are lots empty lines that contains only
one more space chars.

I propose I make a simple script that will remove
all the trailing spaces from all files in the repository,
and after that we should take care on that just like
we take care on tabs.

I know it's not something critical, but neither are
unused imports, etc...
IMHO, it's better to do that at once rather then
having commits changing lots of irrelevant coding style
related issues.

Comments?

Regards,
Mladen.


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


Re: [TC6] Minimum coding style

Posted by Kevin Jackson <fo...@gmail.com>.
>
> AS FOR STYLE, I THINK ALL UNNECESSARY
> WHITESPACE SHOULD BE BANNED AND TABS
> MADE ILLEGAL, THEY JUST INCREASE
> FILE SIZE TOO MUCH AND MY COMMODORE
> 64 JUST CAN'T HANDLE SOME OF THOSE
> LARGE SOURCE FILES ALL IN ONE GO.
>
> PLEASE WRITE YOUR JAVA LIKE THIS:
>
> public class Foobar{private String
> NAME;public void Foobar(){}public
> String getName(){return this.NAME;
> public void setName(String NAME){
> this.NAME=NAME;}

Although meant in jest, I'm stuck on a relatively slow link and
anything that reduces the amount of needless code downloaded the
better in my opinion.  I know most people have uber-fast DSL
connections etc, but many people in the developing world don't, and
having 400K of extraneous whitespace that must be downloaded to check
out the source to a project is annoying :)

I have no problem with whitespace that is used to make code readable,
I do have a problem with needless newlines tacked on the end of every
single damn source file, and trailing spaces at the end of every if ()
{ block because it was cut'n'pasted from somewhere.

Anyway
my 2c
Kev

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


Re: [TC6] Minimum coding style

Posted by Yoav Shapira <yo...@apache.org>.
Hi,

On 11/29/06, Jim Jagielski <ji...@jagunet.com> wrote:
> Same here. Maybe 3/4 of a year ago I cleaned up the entire httpd
> codebase removing trailing spaces, "wrong" tabs, etc... It was
> painful, but it was worth it to occasionally do such housekeeping.
>
> But I haven't checked to see what, if anything, has
> snuck back in. I didn't want to get depressed :)

I think it's safe to assume code styling will always be an ongoing
thing, and will always be a subjective thing.  As long as we can agree
on basic no-no's, like tabs, I think we'll be alright.

Yoav

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


Re: [TC6] Minimum coding style

Posted by Jim Jagielski <ji...@jaguNET.com>.
On Nov 28, 2006, at 3:55 PM, Rainer Jung wrote:

>> From a very personal view I'm tempted to share Mladens dislike of
> trailing spaces. If I try to express, why I don't like them, then  
> it all
> comes back to diffs.
>

Same here. Maybe 3/4 of a year ago I cleaned up the entire httpd
codebase removing trailing spaces, "wrong" tabs, etc... It was
painful, but it was worth it to occasionally do such housekeeping.

But I haven't checked to see what, if anything, has
snuck back in. I didn't want to get depressed :)


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


Re: [TC6] Minimum coding style

Posted by Kris Nuttycombe <nu...@apache.org>.
Darryl Miles wrote:
> Just in case people didn't know,
> diff does have a number of options
> to modify white space behavior,
> such that you can check in a massive
> whitespace cleanup patch but still
> view a clean diff which ignores
> blank lines, crlf/lf and
> leading/trailing whitespace, etc...
>
> So really its not that bad. With
> the right options. 

Agreed; "diff -u -b" is your friend. That being said, I don't think that 
the version of diff used by current SVN clients supports the -b switch, 
so it could still be a problem in terms of source control.

Kris

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


Re: [TC6] Minimum coding style

Posted by Darryl Miles <da...@netbauds.net>.

Just in case people didn't know,
diff does have a number of options
to modify white space behavior,
such that you can check in a massive
whitespace cleanup patch but still
view a clean diff which ignores
blank lines, crlf/lf and
leading/trailing whitespace, etc...

So really its not that bad. With
the right options.



AS FOR STYLE, I THINK ALL UNNECESSARY
WHITESPACE SHOULD BE BANNED AND TABS
MADE ILLEGAL, THEY JUST INCREASE
FILE SIZE TOO MUCH AND MY COMMODORE
64 JUST CAN'T HANDLE SOME OF THOSE
LARGE SOURCE FILES ALL IN ONE GO.

PLEASE WRITE YOUR JAVA LIKE THIS:

public class Foobar{private String
NAME;public void Foobar(){}public
String getName(){return this.NAME;
public void setName(String NAME){
this.NAME=NAME;}


Darryl

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


Re: [TC6] Minimum coding style

Posted by Rainer Jung <ra...@kippdata.de>.
>From a very personal view I'm tempted to share Mladens dislike of
trailing spaces. If I try to express, why I don't like them, then it all
comes back to diffs.

Trailing spaces increase the potential of diff lines with no functional
differences. Nevertheless one wastes time to check very carefully, if
there's really no functional change in them.

And why do trailing spaces produce diff deltas? I think most of the time
because of copy and paste. Copy and paste is able to remove trailing
spaces, when you do it from a screen output of code. So you attempt to
clone code (I know, we never want to do that) and the result looks the
same, but in fact it will produce diff lines because of whitespace
differences.

Omitting all whitespace differences from the subversion diff mails is
something I really find dangerous, because there are cases, where you
need to see whitespace changes.

Removing all trailing whitespace from Java source files might be doable
by a script, although I didn't think about that deeply enough.

All in all I would be

+0 for a policy of not introducing new trailing whitespace (as long as
we don't shoot at each other if it happens nevertheless, but we agree,
that we should avoid it)

and

no idea about the best way of cleaning up existing code (once per script
or during the usual editing process over time).

Regards,

Rainer

Mladen Turk schrieb:
> Henri Gomez wrote:
>> I remember the cold days of the 'Tab brigade' :)
>>
> 
> Right.
> Anyhow, the point of my post was 'minimal', and
> removing the trailing spaces.
> 
> It seems that the trailing spaces are very important,
> so fine with me.
> 
> Cheers,
> Mladen.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org

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


Re: [TC6] Minimum coding style

Posted by Mladen Turk <mt...@apache.org>.
Henri Gomez wrote:
> I remember the cold days of the 'Tab brigade' :)
>

Right.
Anyhow, the point of my post was 'minimal', and
removing the trailing spaces.

It seems that the trailing spaces are very important,
so fine with me.

Cheers,
Mladen.


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


Re: [TC6] Minimum coding style

Posted by Henri Gomez <he...@gmail.com>.
I remember the cold days of the 'Tab brigade' :)

2006/11/28, Remy Maucherat <re...@apache.org>:
> Jim Jagielski wrote:
> > I'm a firm believer in the One True Tab, but I lost that
> > battle loooong ago :)
>
> Yes, I used to push for one coding style a long time ago, but it's not
> going to happen (I figured it was better to collaborate with Costin
> rather than keep the "clean" - ahem - coding style and not get any help).
>
> Creative coding "styles" are not allowed if they are not readable at
> all, of course (it's implied when one asserts tabs are avoided).
>
> Like:
>
>                      String
>
>
> ____my_stupid_field_prefix__FOO                ="bar";
>
> is not good.
>
> Rémy
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

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


Re: [TC6] Minimum coding style

Posted by Remy Maucherat <re...@apache.org>.
Jim Jagielski wrote:
> I'm a firm believer in the One True Tab, but I lost that
> battle loooong ago :)

Yes, I used to push for one coding style a long time ago, but it's not 
going to happen (I figured it was better to collaborate with Costin 
rather than keep the "clean" - ahem - coding style and not get any help).

Creative coding "styles" are not allowed if they are not readable at 
all, of course (it's implied when one asserts tabs are avoided).

Like:

                     String


____my_stupid_field_prefix__FOO                ="bar";

is not good.

Rémy


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


Re: [TC6] Minimum coding style

Posted by Jim Jagielski <ji...@jaguNET.com>.
On Nov 28, 2006, at 10:44 AM, Remy Maucherat wrote:

> Jim Jagielski wrote:
>> On Nov 28, 2006, at 9:36 AM, Mladen Turk wrote:
>>> Remy Maucherat wrote:
>>>> -1 for enforcing any coding style (except tabs, since it can  
>>>> make code unreadable very easily).
>>>>
>>>
>>> You must be joking, right?
>>>
>> One hopes...
>
> Why ?

Coding styles exist to *help* make code more readable
by being more consistent.

I'm a firm believer in the One True Tab, but I lost that
battle loooong ago :)

In any case, I agree that patches that have maybe 90% of
the diffs due to such formatting changes make it awfully
hard to figure out just what the heck in going on.


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


Re: [TC6] Minimum coding style

Posted by Remy Maucherat <re...@apache.org>.
Jim Jagielski wrote:
> 
> On Nov 28, 2006, at 9:36 AM, Mladen Turk wrote:
> 
>> Remy Maucherat wrote:
>>> -1 for enforcing any coding style (except tabs, since it can make 
>>> code unreadable very easily).
>>>
>>
>> You must be joking, right?
>>
> 
> One hopes...

Why ? Because arbitrary rules only create tensions ? It's obvious there 
isn't going a unified enforced standard.

Again: -1 to change this.

Rémy

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


Re: [TC6] Minimum coding style

Posted by Jim Jagielski <ji...@jaguNET.com>.
On Nov 28, 2006, at 9:36 AM, Mladen Turk wrote:

> Remy Maucherat wrote:
>> -1 for enforcing any coding style (except tabs, since it can make  
>> code unreadable very easily).
>>
>
> You must be joking, right?
>

One hopes...


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


Re: [TC6] Minimum coding style

Posted by Mladen Turk <mt...@apache.org>.
Remy Maucherat wrote:
> 
> -1 for enforcing any coding style (except tabs, since it can make code 
> unreadable very easily).
>

You must be joking, right?

Regards,
Mladen.


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


Re: [TC6] Minimum coding style

Posted by Remy Maucherat <re...@apache.org>.
Mladen Turk wrote:
> Also, I love the Filip style (sorry if that doesn't originates from you):
> for example, MessageDispatchInterceptor:
> 
>         }//end if
>     }//sync
> }//end if
> 
> Now, that is what I call ridiculous.

Nice comment :( And what if he likes it and it makes his programming 
easier ?

-1 for enforcing any coding style (except tabs, since it can make code 
unreadable very easily).

Rémy


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


Re: [TC6] Minimum coding style

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
Mladen Turk wrote:
> Remy Maucherat wrote:
>> Mladen Turk wrote:
>>>
>>> Comments?
>>
>> -1. This will screw up diffs, and these really irrelevant things will 
>> be added back very quickly. Tabs is one thing since it can be hard to 
>> work with, but this is simply ridiculous.
>
> Right, but at least the empty lines with spaces are very well
> ridiculous, don't you think?
> Most of those things come as a copy/paste from older Tomcat versions.
>
>> Also, don't do commits that include these cosmetic changes and real 
>> changes if you can avoid it.
>>
>
> I'm using editor (UltraEdit) that has an option to
> remove the trailing spaces on save. I'm sure most
> other editors have something similar, so I occasionally forget
> the rule of different ASF project.
>
> Anyhow, we still don't have a release for TC6, so
> we might consider cleaning up the code style at this early stage.
>
> Also, I love the Filip style (sorry if that doesn't originates from you):
> for example, MessageDispatchInterceptor:
>
>         }//end if
>     }//sync
> }//end if
>
> Now, that is what I call ridiculous.
I guess any publicity is good publicity ;)

Filip


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


Re: [TC6] Minimum coding style

Posted by Mladen Turk <mt...@apache.org>.
Remy Maucherat wrote:
> Mladen Turk wrote:
>>
>> Comments?
> 
> -1. This will screw up diffs, and these really irrelevant things will be 
> added back very quickly. Tabs is one thing since it can be hard to work 
> with, but this is simply ridiculous.

Right, but at least the empty lines with spaces are very well
ridiculous, don't you think?
Most of those things come as a copy/paste from older Tomcat versions.

> Also, don't do commits that include 
> these cosmetic changes and real changes if you can avoid it.
>

I'm using editor (UltraEdit) that has an option to
remove the trailing spaces on save. I'm sure most
other editors have something similar, so I occasionally forget
the rule of different ASF project.

Anyhow, we still don't have a release for TC6, so
we might consider cleaning up the code style at this early stage.

Also, I love the Filip style (sorry if that doesn't originates from you):
for example, MessageDispatchInterceptor:

         }//end if
     }//sync
}//end if

Now, that is what I call ridiculous.

Regards,
Mladen.


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


Re: [TC6] Minimum coding style

Posted by Remy Maucherat <re...@apache.org>.
Mladen Turk wrote:
> Hi,
> 
> Just committed two files, and again I've bumped
> upon the coding style.
> Although it seems we are quite good relating to the
> tabs, the trailing spaces are a real mess in some files.
> There are lots of files where we have
> if (...) {
> followed with the one or more spaces.
> Also there are lots empty lines that contains only
> one more space chars.
> 
> I propose I make a simple script that will remove
> all the trailing spaces from all files in the repository,
> and after that we should take care on that just like
> we take care on tabs.
> 
> I know it's not something critical, but neither are
> unused imports, etc...
> IMHO, it's better to do that at once rather then
> having commits changing lots of irrelevant coding style
> related issues.
> 
> Comments?

-1. This will screw up diffs, and these really irrelevant things will be 
added back very quickly. Tabs is one thing since it can be hard to work 
with, but this is simply ridiculous. Also, don't do commits that include 
these cosmetic changes and real changes if you can avoid it.

Rémy

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


Re: [TC6] Minimum coding style

Posted by Tim Funk <fu...@joedog.org>.
+1 trailing spaces always annoy me and text editors can easily be 
configured to strip them out.

An alternative is to change the email diffs to diff ignoring whitespace 
changes. Then lines can have all the trailing spaces they want and we 
won't see those diffs.

-Tim

Mladen Turk wrote:
> Hi,
> 
> Just committed two files, and again I've bumped
> upon the coding style.
> Although it seems we are quite good relating to the
> tabs, the trailing spaces are a real mess in some files.
> There are lots of files where we have
> if (...) {
> followed with the one or more spaces.
> Also there are lots empty lines that contains only
> one more space chars.
> 
> I propose I make a simple script that will remove
> all the trailing spaces from all files in the repository,
> and after that we should take care on that just like
> we take care on tabs.
> 
> I know it's not something critical, but neither are
> unused imports, etc...
> IMHO, it's better to do that at once rather then
> having commits changing lots of irrelevant coding style
> related issues.
> 

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