[geeklog-devel] Coding standards clarification
Joe Mucchiello
joe at ThrowingDice.com
Thu May 24 00:33:23 EDT 2007
At 10:03 PM 5/23/2007, Heather Engineering wrote:
>(1) require_once '../../../lib-common.php'; // no brackets,
>one space before, no space after
>(2) require_once('../../../lib-common.php'); // brackets, no
>spaces
>(3) require_once( '../../../lib-common.php' ); // brackets, spaces
>
>I would assume (1) from the guidelines, but I see some of (2) and
>lots of (3) in core geeklog code.
The guidelines are new. Core Geeklog does not fully conform to the
new standards. (1) above is correct as I understand the guidelines.
>/* B */
>
>Operators in control structures. Didn't see this anywhere in the
>guidelines, but all examples in the php manual use (1):
>
>(1) if( $groupid == $_CONF['remote_users_group_id'] ) // spaces
>around comparison operator
>(2) if( $groupid==$_CONF['remote_users_group_id'] ) // no
>spaces around comparison operator
>
>(1) is easier to read I think, but I see lots of (2) as well.
Actually, if is not a function. It's a control structure so there
should be a space after if. No spaces after the parens:
3) if ($groupid == $_CONF['whatever'])
>/* C */
>
>Indenting. Never quite sure about this. The following line has to
>wrap. How many spaces should I indent the second line? I would
>normally do about 16 spaces more than the $retval in this case.
The standards don't address this but I would guess a continued line
should be indented further than normal. Making it look "nice" is up to you.
>$retval .= COM_startBlock($LANG_AR_ADMIN[1], '',
> COM_getBlockTemplate('_admin_block', 'header'));
if $retval is indented 4 spaces, then COM_getBlockTemplate... should
be indented at least 8 spaces, more than 8 optionally.
>Should this kind of thing be avoided?
Yes, because it is hard to maintain because it is ugly and it has so
many side effects. Make multiple trips to the database for code
clarity. Speed it up only if you do tests that show it is a bottleneck.
----
Joe Mucchiello
Throwing Dice Games
http://www.throwingdice.com
More information about the geeklog-devel
mailing list