You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pig.apache.org by Stefan Groschupf <sg...@101tec.com> on 2008/02/26 06:46:47 UTC

code formatting rules?

Hi,
can we all agree on some code formatting rules?
I suggest http://java.sun.com/docs/codeconv/CodeConventions.pdf, but  
change the number of characters per line to 120 or 200.
(we dont live in the middle age anymore) :-)
However I'm completely unemotional how the rules should look like but  
as each other open source project we should have some too.
It will make it easier to read the code, read  patches etc.
Thanks.
Stefan


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
101tec Inc.
Menlo Park, California, USA
http://www.101tec.com



Re: code formatting rules?

Posted by pi song <pi...@gmail.com>.
You can configure Checkstyle to treat style violations as warnings so we can
just use this as a guideline. This way we can gradually enforce and keep
changing the code to the same style bit by bit. New code to be committed
should not introduce new warnings if it's not too critical.

What do you think?

On 2/28/08, Benjamin Francisoud <be...@joost.com> wrote:
>
> I think what stefan is proposing is to make it part of the build
> process...
> I have already seen this in cruisecontrol build .xml file using
> checkstyle.
>
> If you try to do "ant compile" and some code doesn't follow coding
> convention, the build will fail.
>
> That's quite constraining but you are sure all you're code follow coding
> convention at any time...
> Some people may find it annoying... in my experience, it must be a team
> decision.
>
> Moving to such a process would require to do a bulk formatting of pig
> current code at some point.
>
> --
> Benjamin Francisoud
>
>
> Olga Natkovich a écrit :
> > We have done part of it - converting tabs to spaces. What other changes
> > do you feel are important to do early?
> >
> > The general rule is to follow the style of the file in which you are
> > making changes and not to mix reformatting with other patches because
> > they make the review process very confusing.
> >
> > Olga
> >
> >
> >> -----Original Message-----
> >> From: Stefan Groschupf [mailto:sg@101tec.com]
> >> Sent: Tuesday, February 26, 2008 4:19 PM
> >> To: pig-dev@incubator.apache.org
> >> Subject: Re: code formatting rules?
> >>
> >>
> >>> We do have coding conventions, as mentioned here:
> >>> http://wiki.apache.org/pig/HowToContribute
> >>> .  We use the ones you reference, except that we use spaces rather
> >>> than tabs.  As for characters per line, we do still use 80.
> >>>
> >>  Even if
> >>
> >>> we don't live in the middle ages some of us like to have multiple
> >>> panes open at a time and be able to see across them :)
> >>>
> >> I'm fine wiht 80 too - no discussion need.
> >>
> >> It looks to me most of the code does not follow this coding
> >> conventions. I'm always not sure if a patch should follow the coding
> >> conventions in this one class or use the java once - it is getting
> >> messy in any case.
> >>
> >> Even if it is very unpopular and painful one day we might
> >> need to run
> >> a code formatter over all classes (or step by step)and I
> >> suggest to do
> >> that earlier than later.
> >> Writing patches would be easier after that.
> >>
> >> Just my 2 cents.
> >> Stefan
> >>
> >>
>
>

Re: code formatting rules?

Posted by Benjamin Francisoud <be...@joost.com>.
I think what stefan is proposing is to make it part of the build process...
I have already seen this in cruisecontrol build .xml file using checkstyle.

If you try to do "ant compile" and some code doesn't follow coding 
convention, the build will fail.

That's quite constraining but you are sure all you're code follow coding 
convention at any time...
Some people may find it annoying... in my experience, it must be a team 
decision.

Moving to such a process would require to do a bulk formatting of pig 
current code at some point.

--
Benjamin Francisoud


Olga Natkovich a écrit :
> We have done part of it - converting tabs to spaces. What other changes
> do you feel are important to do early?
>
> The general rule is to follow the style of the file in which you are
> making changes and not to mix reformatting with other patches because
> they make the review process very confusing.
>
> Olga 
>
>   
>> -----Original Message-----
>> From: Stefan Groschupf [mailto:sg@101tec.com] 
>> Sent: Tuesday, February 26, 2008 4:19 PM
>> To: pig-dev@incubator.apache.org
>> Subject: Re: code formatting rules?
>>
>>     
>>> We do have coding conventions, as mentioned here:  
>>> http://wiki.apache.org/pig/HowToContribute
>>> .  We use the ones you reference, except that we use spaces rather 
>>> than tabs.  As for characters per line, we do still use 80. 
>>>       
>>  Even if 
>>     
>>> we don't live in the middle ages some of us like to have multiple 
>>> panes open at a time and be able to see across them :)
>>>       
>> I'm fine wiht 80 too - no discussion need.
>>
>> It looks to me most of the code does not follow this coding  
>> conventions. I'm always not sure if a patch should follow the coding  
>> conventions in this one class or use the java once - it is getting  
>> messy in any case.
>>
>> Even if it is very unpopular and painful one day we might 
>> need to run  
>> a code formatter over all classes (or step by step)and I 
>> suggest to do  
>> that earlier than later.
>> Writing patches would be easier after that.
>>
>> Just my 2 cents.
>> Stefan 
>>
>>     


RE: code formatting rules?

Posted by Olga Natkovich <ol...@yahoo-inc.com>.
We have done part of it - converting tabs to spaces. What other changes
do you feel are important to do early?

The general rule is to follow the style of the file in which you are
making changes and not to mix reformatting with other patches because
they make the review process very confusing.

Olga 

> -----Original Message-----
> From: Stefan Groschupf [mailto:sg@101tec.com] 
> Sent: Tuesday, February 26, 2008 4:19 PM
> To: pig-dev@incubator.apache.org
> Subject: Re: code formatting rules?
> 
> > We do have coding conventions, as mentioned here:  
> > http://wiki.apache.org/pig/HowToContribute
> > .  We use the ones you reference, except that we use spaces rather 
> > than tabs.  As for characters per line, we do still use 80. 
>  Even if 
> > we don't live in the middle ages some of us like to have multiple 
> > panes open at a time and be able to see across them :)
> I'm fine wiht 80 too - no discussion need.
> 
> It looks to me most of the code does not follow this coding  
> conventions. I'm always not sure if a patch should follow the coding  
> conventions in this one class or use the java once - it is getting  
> messy in any case.
> 
> Even if it is very unpopular and painful one day we might 
> need to run  
> a code formatter over all classes (or step by step)and I 
> suggest to do  
> that earlier than later.
> Writing patches would be easier after that.
> 
> Just my 2 cents.
> Stefan 
> 

Re: code formatting rules?

Posted by Stefan Groschupf <sg...@101tec.com>.
> We do have coding conventions, as mentioned here:  http://wiki.apache.org/pig/HowToContribute 
> .  We use the ones you reference, except that we use spaces rather  
> than tabs.  As for characters per line, we do still use 80.  Even if  
> we don't live in the middle ages some of us like to have multiple  
> panes open at a time and be able to see across them :)
I'm fine wiht 80 too - no discussion need.

It looks to me most of the code does not follow this coding  
conventions. I'm always not sure if a patch should follow the coding  
conventions in this one class or use the java once - it is getting  
messy in any case.

Even if it is very unpopular and painful one day we might need to run  
a code formatter over all classes (or step by step)and I suggest to do  
that earlier than later.
Writing patches would be easier after that.

Just my 2 cents.
Stefan 

Re: code formatting rules?

Posted by Alan Gates <ga...@yahoo-inc.com>.
We do have coding conventions, as mentioned here:  
http://wiki.apache.org/pig/HowToContribute.  We use the ones you 
reference, except that we use spaces rather than tabs.  As for 
characters per line, we do still use 80.  Even if we don't live in the 
middle ages some of us like to have multiple panes open at a time and be 
able to see across them :)

Perhaps these coding conventions need to be more prominently displayed 
in the docs.  I'm open to suggestions.

Alan.

Stefan Groschupf wrote:
> Hi,
> can we all agree on some code formatting rules?
> I suggest http://java.sun.com/docs/codeconv/CodeConventions.pdf, but 
> change the number of characters per line to 120 or 200.
> (we dont live in the middle age anymore) :-)
> However I'm completely unemotional how the rules should look like but 
> as each other open source project we should have some too.
> It will make it easier to read the code, read  patches etc.
> Thanks.
> Stefan
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 101tec Inc.
> Menlo Park, California, USA
> http://www.101tec.com
>
>