Re: Coding standards
| From: | Manuel Lemos | Date: | Fri, 21 Dec 2001 05:22:41 +0000 |
| Subject: | Re: Coding standards | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-3612@lists.php.net to get a copy of this message | ||
Hello,
Jon Parise wrote:
>
> I've been thinking about proposing a change to the coding
> standards to would relax the majority of the style requirements.
>
> For the most part, instead of spelling out how code should be
> formatted, the existing requirements would become more of a
> suggested style guide (meaning "this is how the 'official' code
> is already formatted and it would be nice if new code were
> formatted like this").
>
> Next, we add a single (strict!) requirement that, when making
> changes to existing code in the repository, the changes must
> honor the style of the original file. Gross style-related
> commits would not be permitted unless a good (technical) reason
> is provided.
Thank you for listening.
And to be make the requirement of honouring the style of the original
contributor, I think that somehow the contributor needs to declare what
is that style for others to follow: indenting - tabs or spaces? how
many? Capitalization - Which variable and function name capitalization
type? capitalize initials? except the first? precede words with
underscores? Scope braces - in front or below?
I noticed that some C developers put the rules that they follow in the
form of vi directives in the bottom of their source code files. Similar
idea could be followed, maybe some custom XML tags in PHP comments,
something like this:
/*
<Style>
<Indentation>
<Type>Spaces</Type>
<Count>4</Count>
</Indentation>
<Capitalization>
<Type>InitialsExceptFirst</Type>
</capitalization>
<ScopeBraces>
<Position>Below</Position>
</ScopeBraces>
</Style>
*/
Why XML? Because it is easier to parse programatically and more flexible
to extend. Hopefully somebody will write a prettifier that will reformat
the code edited by somebody with a different style thus helping people
to write code to conform with the original contributor style rules.
Regards,
Manuel Lemos