Hi,

Parts of the standards seem to follow opposing preferences. While functions and methods place the opening brace on its own line, control statements state they should place on the same line as the statement def.

Seems a bit odd. I usually do the opposite :), but esp. not placing control statement braces on a new line reduces readability IMO. A method def is easy to spot - following control statements is far more complicated.

Peter's 2nd comment seems fine. I think the additional else can actually improve readability in some cases though.

Regards,
Pádraic
 


Pádraic Brady
http://blog.quantum-star.com
http://www.patternsforphp.com


----- Original Message ----
From: Peter Hodge <[EMAIL PROTECTED]>
To: Zend Framework General <[email protected]>
Sent: Thursday, September 28, 2006 6:31:44 AM
Subject: Re: [fw-general] Coding Standards & ZF 0.2

Hello,

Due to my limited involvement in the ZF project, I don't feel comfortable with
hacking up your wiki page.  However, I would like to add a couple of comments:

1) Switch

  The construct "default" may never be omitted from a "switch" statement.

I don't think requiring an empty 'default: break;' is a good idea.  It will
give less-experienced developers an incorrect concept of how switches work.
Better to add a note such as:

  NOTE: Remember to add a 'default' case to throw an Exception if the switch
value should have been caught be one of the cases.


2) If / Else / Elseif / Return

This rule is borrowed from the MySQL Coding Standards:

  If a 'return' statement is inside an 'if' block, then an 'else' block is not
necessary.

That is, instead of:

  if (...) {
    return true;
  } else {
    return false;
  }

You should use:

  if (...) {
    return true;
  }
  return false;

Unnecessary 'else' blocks make code very hard to understand.  This rule can
also be applied to 'throw', 'break' and 'continue' statements.


cheers,
Peter

  



--- Gavin Vess <[EMAIL PROTECTED]> wrote:

> As we are approaching 0.2, this might be a good time to revisit the
> various changes to the ZF Coding Standard *draft* version in the wiki,
> in order to help produce a version for release along with the other
> docbook documentation.  We also have the beginnings of a separate "best
> practices" section in our "Getting Started" wiki page, but those
> practices are more abstract and thus more subjective in nature.
>
> http://framework.zend.com/wiki/x/PQ
>
> Cheers,
> Gavin
>



        
____________________________________________________
On Yahoo!7
Check back weekly for  Trixi's new online adventures
http://www.trixi.com.au


Reply via email to