[RFC & Patch][Implemented] Coding Guidelines

Note: We are moving the topics of this forum and it will be deleted at some point

Publish your own request for comments/change or patches for the next version of phpBB. Discuss the contributions and proposals of others. Upcoming releases are 3.2/Rhea and 3.3.
User avatar
naderman
Consultant
Posts: 1727
Joined: Sun Jan 11, 2004 2:11 am
Location: Karlsruhe, Germany
Contact:

[RFC & Patch][Implemented] Coding Guidelines

Post by naderman »

Information about the RFC on the wiki: http://wiki.phpbb.com/PhpBB4/RFC/Coding_Guidelines

The current document can be found on github in my coding-guidelines branch: http://github.com/naderman/phpbb/blob/c ... s.markdown A small tool for converting the document to HTML can be found in the develop/ directory.

Please discuss! If you want to contribut changes, you can post a patch (created with git format-patch) here. Alternatively you can fork the official repository on github yourself: http://github.com/phpbb/phpbb You can then add naderman/phpbb as an additional remote, pull the branch from it, make your changes, and let me know to pull them back into my repository.

User avatar
Dog Cow
Registered User
Posts: 271
Joined: Wed May 25, 2005 2:14 pm

Re: [RFC & Patch] Coding Guidelines

Post by Dog Cow »

The only thing I don't like is spaces instead of tabs. I just hate looking at someone else's mess who didn't use tabs. :x

rma-web
Registered User
Posts: 11
Joined: Sat Jan 16, 2010 1:27 am

Re: [RFC & Patch] Coding Guidelines

Post by rma-web »

If you can update your post Naderman, its http://github.com/phpbb/phpbb ;)

User avatar
naderman
Consultant
Posts: 1727
Joined: Sun Jan 11, 2004 2:11 am
Location: Karlsruhe, Germany
Contact:

Re: [RFC & Patch] Coding Guidelines

Post by naderman »

Oops, yes thank you.

House
Registered User
Posts: 3
Joined: Mon Jan 18, 2010 2:51 am

Tabbing -> Spacing

Post by House »

Question: Why will phpBB 4 be using SPACES instead of TABS?
Answer: So the code always looks the same regardless of what width you have your tabs set to.
Having their tabs set to a width of 2 or 8 often caused people to indent incorrectly with tabs.
Tabs also don't work very will in the middle of a line when trying to line up variable assignments for example.

Phil
Registered User
Posts: 185
Joined: Sun Mar 11, 2007 3:20 am
Contact:

Re: [RFC & Patch] Coding Guidelines

Post by Phil »

Looks good to me as well aside from one minor thing (which Dog Cow already mentioned) -- the use of spaces instead of tabs. To be honest I don't understand the rationale here -- correct me if I'm wrong the purpose is so the code looks visually identical (or close) regardless of one's text editor settings. Even if that is the case, one will still likely need to configure their text editor to use spaces as tabs, which seems to defeat the purpose.

If nothing else, in most other projects I've seen, tabs seem to be the de facto standard. Changing it seems more like it would cause more annoyance than benefit.

Other than that, looks good -- reads well, clear, and above all, makes sense. Good work.
My phpbb.com account
Note that any of my opinions expressed in RFC topics are my own and not necessarily representative of the opinion of the phpBB Team.

ckwalsh
Registered User
Posts: 54
Joined: Tue Apr 18, 2006 2:25 am

Re: [RFC & Patch] Coding Guidelines

Post by ckwalsh »

I actually like spaces. it bothers me when I open up a file and it's obvious my tab widths are different from the target width, making the mess unreadable.

As for having trouble getting people to use spaces instead, a hook could be setup that would automatically convert tabs to spaces. Problem solved.

Looks pretty solid. My only complaint is you used php instead of PHP and html instead of HTML sometimes :P.

User avatar
onehundredandtwo
Registered User
Posts: 33
Joined: Mon Feb 02, 2009 6:55 am

Re: [RFC & Patch] Coding Guidelines

Post by onehundredandtwo »

I don't like the CamelCase (instead of camel_case). The variable without camel-case looks a lot cleaner to me.

Code: Select all

$my_var
$myVar
Need help preventing spam? Read Preventing spam in phpBB 3.0.6 and above

User avatar
naderman
Consultant
Posts: 1727
Joined: Sun Jan 11, 2004 2:11 am
Location: Karlsruhe, Germany
Contact:

Re: [RFC & Patch] Coding Guidelines

Post by naderman »

It would be nice if rather than just stating what you like or don't you could give some rational arguments as to why one or ther other is better otherwise I don't think there is reason for change.

User avatar
bantu
3.0 Release Manager
3.0 Release Manager
Posts: 557
Joined: Thu Sep 07, 2006 11:22 am
Location: Karlsruhe, Germany
Contact:

Re: [RFC & Patch] Coding Guidelines

Post by bantu »

I'd like to suggest to add a rule that the last line of a text file should end with "\n".

Example

Changing

Code: Select all

..."\n"
$someVar = false; 
to

Code: Select all

..."\n"
$someVar = false;"\n"
$someOtherVar = false; 
will list the $someVar-Line as modified in the repository, which should not be.

It should be

Code: Select all

..."\n"
$someVar = false;"\n" 
from the beginning, so you can easily add

Code: Select all

$someOtherVar = false;"\n" 

Post Reply