[geeklog-devel] Coding standards clarification

Heather Engineering info at heatherengineering.com
Thu May 24 02:44:09 EDT 2007

On 2007/05/24, at 13:33, Joe Mucchiello wrote:


>> /*  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'])

Sorry, there should have been a space before the left bracket. I was  
asking about around the comparator '=='.


>> $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.

That's a different question, but actually one I wanted to ask. Is it  
usually better to make one big query, or several smaller ones?  
Performance-wise, which is better? I was under the impression it was  
generally better to combine into as few queries as possible.

Thanks for the comments.


More information about the geeklog-devel mailing list