Support forums : The Future

QP5 path: coding standards

The future of this project but not in a "I want a pony" sort of way. This is all about everything meta about Quam Plures. The general direction, the support tools, stuff like that.

Moderator: Dracones

QP5 path: coding standards

Postby EdB » Sat Feb 16, 2013 8:09 pm

Noting viewtopic.php?f=2&t=353 these are some of the "standards" I have been working towards and will pretty much leave as-is when I do branchwork:

This doesn't matter at all other than cosmetic appeal to the future coders: spaces around components of a function call. First the "wrong" way:
Code: Select all
load_funcs('plugins/_plugin.funcs.php');[code]Then the "right" way:[/code]load_funcs( 'plugins/_plugin.funcs.php' );
The same applies when we're doing param values in an array: "less good" first:
Code: Select all
array('foo'=>'bar');
Now the "new" way:
Code: Select all
array( 'foo' => 'bar' );
The only exception due to how much is already in core is when we have translatable bits inside a T_('foo') call. Technically the strings are components of a function call but we've got almost everything doing translatable strings without extra spaces.

I also have gone away from having either { or } share a line with anything else. ESPECIALLY comments. Old way quite common and valid:
Code: Select all
if( $foo == 'bar' )
{ // foo is equal to bar
   foo_is_bar();
}
New way, purely for cosmetics to my eyes when I look at code:
Code: Select all
if( $foo == 'bar' )
{
   // foo is equal to bar
   foo_is_bar();
}
Both the { and } are at the "parent" level, and the comment is tabbed in as much as the actions for the condition.

More to follow I'm sure as I work through diffs and get the first branch available for testing ...

EDIT: another pet peeve of mine is tabs. I absolutely hate tabs in the middle of a string of characters! So I've gone to a simple rule: the left edge of a tab is against the left margin or another tab. Marginally related is having more than one space to line shit up with the bit above it. I dunno why, but that one bugs the hell out of me. Eventually you'll see that almost every instance of "space-space" has been replaced with "space". Also "tab-space" have been done away with but the solution depends on the circumstance for that level of detail.
EdB
Dracone
User avatar
 
Posts: 2072
Joined: Sun Nov 22, 2009 7:20 am
Location: Maricopa Arizona

Re: QP5 path: coding standards

Postby leeturner » Sat Feb 16, 2013 10:39 pm

All good as far as I am concerned. I prefer { and } on their own lines as well.
leeturner
Dracone
User avatar
 
Posts: 730
Joined: Fri Dec 11, 2009 11:55 am
Location: Brighton, UK


Return to The Future

Who is online

Users browsing this forum: No registered users and 1 guest

cron