You are viewing a plain text version of this content. The canonical link for it is here.
Posted to zeta-dev@incubator.apache.org by Tobias Schlitt <to...@schlitt.info> on 2010/11/16 12:06:22 UTC

[zeta-dev] Documenting our coding style

Hi,

for another project I needed to give advice on the coding standard used
by Apache Zeta Components. There is some very old version of the eZ
Publish coding style in [1] (from 2001) but no reliable, recent source.
So I think we should document our coding style on the website.

Please complete / correct my following brainstorming:

- Indentation with 4 spaces
  - After a "{"
  - On breakup of long lines (> 78 chars) after a "("
- "{" and "}" on a new line
- 1 space after "(" and before ")"
- No space after "[" and before "]"
- 1 space after ","
- 1 space before and after "."
- Almost always camelCase
  - classes always start with ezc followed by an upper case char
  - constants all in upper case with "_"

Regards,
Toby

-- 
Tobias Schlitt        http://schlitt.info        GPG Key: 0xC462BC14
Want to hire me? Need quality assurance?            http://qafoo.com
eZ Components are Zeta Components now!          http://bit.ly/9S7zbn

Re: [zeta-dev] Documenting our coding style

Posted by Piotrek Karas <p....@mediaself.pl>.
> I'm sorry, but that is not how we code in Zeta. We use camelCase
> everywhere and the idea should not be to change a coding standard, but
> to document it properly.
> Regards,
> Toby
>

Hello everyone,

A while ago we were choosing/finetuning our internal coding standards 
and we mostly based it on eZComponents one with only few modifications. 
Since we use ZendStudio for everyday work, we have it saved using ZS PHP 
formatter that is quite advanced and detailed compared to what Eclipse 
gives by default and expresses every rule quite clearly. I'm not sure if 
it is of any help now, but I attach our ZS formatter definition. Maybe 
it helps to think of some less obvious things and rules to document. 
Unfortunately, it doesn't cover variables.

Cheers,
Piotrek

Re: [zeta-dev] Documenting our coding style

Posted by Tobias Schlitt <to...@schlitt.info>.
Hi Thomas,

On 11/16/2010 01:32 PM, Maxime Thomas wrote:

> What are the limit cases for this one : Almost always camelCase ?

I listed the cases directly below this point. Actually, only constants
are an exception to the camelCase rule.

> I would like to add a semantic rule to that about function naming.
> Function names must be :

> - Short
> - Explicit
> - Use verbs as first name : get, put, set, call, fetch, send...
> - Be always lowered camelCased

This kind of stuff is already documented here:

http://incubator.apache.org/zetacomponents/community/implementation.html

> I also would like to add another semantic rule about variable naming :
> 
> - if attribute of class : must be camelCased
> - if local variable : must be url styled : lowered and white caracters
> escape with underscore

I'm sorry, but that is not how we code in Zeta. We use camelCase
everywhere and the idea should not be to change a coding standard, but
to document it properly.

> For comment, I guess we will follow the same as eZPublish, good rule of
> thumb, or inherit from PEAR, a good start and easily pluggable into phpunit.

> Do we have to set the encoding settings of the files (UTF-8, Unix Style) ?

We use UTF-8 everywhere. For SVN you are best of with svn:eol-style set
to native.

Regards,
Toby

-- 
Tobias Schlitt        http://schlitt.info        GPG Key: 0xC462BC14
Want to hire me? Need quality assurance?            http://qafoo.com
eZ Components are Zeta Components now!          http://bit.ly/9S7zbn

Re: [zeta-dev] Documenting our coding style

Posted by Maxime Thomas <ma...@gmail.com>.
Hi Tobias,

What are the limit cases for this one : Almost always camelCase ?

I would like to add a semantic rule to that about function naming.
Function names must be :

- Short
- Explicit
- Use verbs as first name : get, put, set, call, fetch, send...
- Be always lowered camelCased

I also would like to add another semantic rule about variable naming :

- if attribute of class : must be camelCased
- if local variable : must be url styled : lowered and white caracters
escape with underscore

For comment, I guess we will follow the same as eZPublish, good rule of
thumb, or inherit from PEAR, a good start and easily pluggable into phpunit.

Do we have to set the encoding settings of the files (UTF-8, Unix Style) ?

Regards,

Max

2010/11/16 Tobias Schlitt <to...@schlitt.info>

> Hi,
>
> for another project I needed to give advice on the coding standard used
> by Apache Zeta Components. There is some very old version of the eZ
> Publish coding style in [1] (from 2001) but no reliable, recent source.
> So I think we should document our coding style on the website.
>
> Please complete / correct my following brainstorming:
>
> - Indentation with 4 spaces
>  - After a "{"
>  - On breakup of long lines (> 78 chars) after a "("
> - "{" and "}" on a new line
> - 1 space after "(" and before ")"
> - No space after "[" and before "]"
> - 1 space after ","
> - 1 space before and after "."
> - Almost always camelCase
>  - classes always start with ezc followed by an upper case char
>  - constants all in upper case with "_"
>
> Regards,
> Toby
>
> --
> Tobias Schlitt        http://schlitt.info        GPG Key: 0xC462BC14
> Want to hire me? Need quality assurance?            http://qafoo.com
> eZ Components are Zeta Components now!          http://bit.ly/9S7zbn
>

Re: [zeta-dev] Documenting our coding style

Posted by Tobias Schlitt <to...@schlitt.info>.
Hi Jerome,

On 11/17/2010 03:28 PM, Jerome Renard wrote:

> On Tue, Nov 16, 2010 at 1:06 PM, Tobias Schlitt <to...@schlitt.info> wrote:

>> for another project I needed to give advice on the coding standard used
>> by Apache Zeta Components. There is some very old version of the eZ
>> Publish coding style in [1] (from 2001) but no reliable, recent source.
>> So I think we should document our coding style on the website.
>>
>> Please complete / correct my following brainstorming:
>>
>> - Indentation with 4 spaces
>>  - After a "{"
>>  - On breakup of long lines (> 78 chars) after a "("
>> - "{" and "}" on a new line
>> - 1 space after "(" and before ")"
>> - No space after "[" and before "]"
>> - 1 space after ","
>> - 1 space before and after "."
>> - Almost always camelCase
>>  - classes always start with ezc followed by an upper case char
>>  - constants all in upper case with "_"

> Looks good.

> A precision might be needed though about the 78 chars limit :
> As far as I remember (correct me if I am wrong) the limit it 80 chars
> but since there is one space after the "(" and before ")" that
> makes the string longer or equal than 80 chars hence the line breakup.
> 
> (Not sure I am completel clear here :/)

yeah, in fact there is a limit of 80 chars per line. I think I had 78 in
mind from text stuff.

Regards,
Toby

-- 
Tobias Schlitt        http://schlitt.info        GPG Key: 0xC462BC14
Want to hire me? Need quality assurance?            http://qafoo.com
eZ Components are Zeta Components now!          http://bit.ly/9S7zbn

Re: [zeta-dev] Documenting our coding style

Posted by Jerome Renard <je...@gmail.com>.
Hi Tobias,

On Tue, Nov 16, 2010 at 1:06 PM, Tobias Schlitt <to...@schlitt.info> wrote:
> Hi,
>
> for another project I needed to give advice on the coding standard used
> by Apache Zeta Components. There is some very old version of the eZ
> Publish coding style in [1] (from 2001) but no reliable, recent source.
> So I think we should document our coding style on the website.
>
> Please complete / correct my following brainstorming:
>
> - Indentation with 4 spaces
>  - After a "{"
>  - On breakup of long lines (> 78 chars) after a "("
> - "{" and "}" on a new line
> - 1 space after "(" and before ")"
> - No space after "[" and before "]"
> - 1 space after ","
> - 1 space before and after "."
> - Almost always camelCase
>  - classes always start with ezc followed by an upper case char
>  - constants all in upper case with "_"
>

Looks good.
A precision might be needed though about the 78 chars limit :
As far as I remember (correct me if I am wrong) the limit it 80 chars
but since there is one space after the "(" and before ")" that
makes the string longer or equal than 80 chars hence the line breakup.

(Not sure I am completel clear here :/)

Cheers :)

-- 
Jérôme Renard
http://39web.fr | http://jrenard.info | http://twitter.com/jeromerenard

Re: [zeta-dev] Documenting our coding style

Posted by Jerome Renard <je...@gmail.com>.
Maxime,

On Sat, Nov 27, 2010 at 10:29 AM, Maxime Thomas <ma...@gmail.com> wrote:
> I saved in my bookmarks this one : http://pear.xplib.de/get/
>
> <http://pear.xplib.de/get/>Max
>

Cool, thanks :)

-- 
Jérôme Renard
http://39web.fr | http://jrenard.info | http://twitter.com/jeromerenard

Re: [zeta-dev] Documenting our coding style

Posted by Maxime Thomas <ma...@gmail.com>.
I saved in my bookmarks this one : http://pear.xplib.de/get/

<http://pear.xplib.de/get/>Max

2010/11/27 Jerome Renard <je...@gmail.com>

> Hi,
>
> On Fri, Nov 26, 2010 at 2:23 PM, Derick Rethans <de...@apache.org> wrote:
> > On Tue, 16 Nov 2010, Tobias Schlitt wrote:
> >
> >> for another project I needed to give advice on the coding standard used
> >> by Apache Zeta Components. There is some very old version of the eZ
> >> Publish coding style in [1] (from 2001) but no reliable, recent source.
> >> So I think we should document our coding style on the website.
> >>
> >> Please complete / correct my following brainstorming:
> >>
> >> - Indentation with 4 spaces
> >>   - After a "{"
> >>   - On breakup of long lines (> 78 chars) after a "("
> >> - "{" and "}" on a new line
> >> - 1 space after "(" and before ")"
> >> - No space after "[" and before "]"
> >> - 1 space after ","
> >> - 1 space before and after "."
> >> - Almost always camelCase
> >>   - classes always start with ezc followed by an upper case char
> >>   - constants all in upper case with "_"
> >
> >
> > There is also a script at
> >
> http://svn.apache.org/repos/asf/incubator/zetacomponents/scripts/syntax-check.sh
> > that has a few rough automated checks.
> >
>
> I remember I used a PHP Code Sniffer standard for ZC is it still
> available somewhere ?
> I tried the old URL and it seems it's no longer there.
>
> Best Regards,
>
> --
> Jérôme Renard
> http://39web.fr | http://jrenard.info | http://twitter.com/jeromerenard
>

Re: [zeta-dev] Documenting our coding style

Posted by Jerome Renard <je...@gmail.com>.
Hi,

On Fri, Nov 26, 2010 at 2:23 PM, Derick Rethans <de...@apache.org> wrote:
> On Tue, 16 Nov 2010, Tobias Schlitt wrote:
>
>> for another project I needed to give advice on the coding standard used
>> by Apache Zeta Components. There is some very old version of the eZ
>> Publish coding style in [1] (from 2001) but no reliable, recent source.
>> So I think we should document our coding style on the website.
>>
>> Please complete / correct my following brainstorming:
>>
>> - Indentation with 4 spaces
>>   - After a "{"
>>   - On breakup of long lines (> 78 chars) after a "("
>> - "{" and "}" on a new line
>> - 1 space after "(" and before ")"
>> - No space after "[" and before "]"
>> - 1 space after ","
>> - 1 space before and after "."
>> - Almost always camelCase
>>   - classes always start with ezc followed by an upper case char
>>   - constants all in upper case with "_"
>
>
> There is also a script at
> http://svn.apache.org/repos/asf/incubator/zetacomponents/scripts/syntax-check.sh
> that has a few rough automated checks.
>

I remember I used a PHP Code Sniffer standard for ZC is it still
available somewhere ?
I tried the old URL and it seems it's no longer there.

Best Regards,

-- 
Jérôme Renard
http://39web.fr | http://jrenard.info | http://twitter.com/jeromerenard

Re: [zeta-dev] Documenting our coding style

Posted by Derick Rethans <de...@apache.org>.
On Tue, 16 Nov 2010, Tobias Schlitt wrote:

> for another project I needed to give advice on the coding standard used
> by Apache Zeta Components. There is some very old version of the eZ
> Publish coding style in [1] (from 2001) but no reliable, recent source.
> So I think we should document our coding style on the website.
> 
> Please complete / correct my following brainstorming:
> 
> - Indentation with 4 spaces
>   - After a "{"
>   - On breakup of long lines (> 78 chars) after a "("
> - "{" and "}" on a new line
> - 1 space after "(" and before ")"
> - No space after "[" and before "]"
> - 1 space after ","
> - 1 space before and after "."
> - Almost always camelCase
>   - classes always start with ezc followed by an upper case char
>   - constants all in upper case with "_"


There is also a script at 
http://svn.apache.org/repos/asf/incubator/zetacomponents/scripts/syntax-check.sh 
that has a few rough automated checks. 

regards,
Derick

-- 
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug

[zeta-dev] Patch: Re: [zeta-dev] Documenting our coding style

Posted by Tobias Schlitt <to...@schlitt.info>.
Hi,

find attached the patch I commited in order to document our coding style
for review.

Regards,
Toby

-- 
Tobias Schlitt        http://schlitt.info        GPG Key: 0xC462BC14
Want to hire me? Need quality assurance?            http://qafoo.com
eZ Components are Zeta Components now!          http://bit.ly/9S7zbn