Quantcast

Coding Standards - Errors and Exceptions

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Coding Standards - Errors and Exceptions

Darby Felton
Hi all,

Though this is probably more appropriate for fw-docs, here we have the
most eyes, so here I post. :)

Ralph brought to my attention that the coding standards do not indicate
E_STRICT compliance, so I made a quick addendum to the coding standards
in the wiki:

The diff (it's a little buggy):

http://framework.zend.com/wiki/pages/diffpages.action?pageId=61&originalId=7347

The wiki page view (at the bottom is the content I added):

http://framework.zend.com/wiki/x/PQ

Please provide feedback for revision as needed with your comments here
or on the wiki page.

Thank you,
Darby
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Coding Standards - Errors and Exceptions

Bill Karwin from Zend
That's great, I was thinking of writing a section in the coding
standards for exceptions too.  I've appended some more notes after
yours, under a subheading "Exception best practices".

Regards,
Bill

Darby Felton wrote:

> Hi all,
>
> Though this is probably more appropriate for fw-docs, here we have the
> most eyes, so here I post. :)
>
> Ralph brought to my attention that the coding standards do not indicate
> E_STRICT compliance, so I made a quick addendum to the coding standards
> in the wiki:
>
> The diff (it's a little buggy):
>
> http://framework.zend.com/wiki/pages/diffpages.action?pageId=61&originalId=7347
>
> The wiki page view (at the bottom is the content I added):
>
> http://framework.zend.com/wiki/x/PQ
>
> Please provide feedback for revision as needed with your comments here
> or on the wiki page.
>
> Thank you,
> Darby
>
>
>  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Coding Standards - Errors and Exceptions

Peter Hodge-5
In reply to this post by Darby Felton
Hello,

Can I also suggest:

  Using '@' for suppressing errors is { highly discouraged | banned }. It
  suppresses _all_ the helpful notices and warnings and if it is used in the
  wrong place it can effect remote parts of the framework as well. If you have
  never spent an hour searching for a fatal error which is hidden by '@', then
  you are fortunate.  For a similar experience, have someone else bury your
  car keys in the sand at a beach and then try to find them.

regards,
Peter



               
____________________________________________________
On Yahoo!7
Answers: Share what you know and you might make someone's day
http://www.yahoo7.com.au/answers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Coding Standards - Errors and Exceptions

Bruno Viana
In reply to this post by Darby Felton
What means E_STRICT?

On 10/10/06, Darby Felton <[hidden email]> wrote:
Hi all,

Though this is probably more appropriate for fw-docs, here we have the
most eyes, so here I post. :)

Ralph brought to my attention that the coding standards do not indicate
E_STRICT compliance, so I made a quick addendum to the coding standards
in the wiki:

The diff (it's a little buggy):

http://framework.zend.com/wiki/pages/diffpages.action?pageId=61&originalId=7347

The wiki page view (at the bottom is the content I added):

http://framework.zend.com/wiki/x/PQ

Please provide feedback for revision as needed with your comments here
or on the wiki page.

Thank you,
Darby



--
"Fui para os bosques viver de livre vontade. Para sugar todo o tutano da vida, para aniquilar tudo o que não era vida e para, quando morrer, não descobrir que não vivi."
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Coding Standards - Errors and Exceptions

Peter Hodge-5
In reply to this post by Bill Karwin from Zend
--- Bill Karwin <[hidden email]> wrote:

> That's great, I was thinking of writing a section in the coding
> standards for exceptions too.  I've appended some more notes after
> yours, under a subheading "Exception best practices".

  "Clean up resources such as database connections or network connections. Use
a finally block for this."

PHP has no 'finally' support.

regards,
Peter


               
____________________________________________________
On Yahoo!7
Music: Create your own personalised radio station.
http://au.launch.yahoo.com/ 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Coding Standards - Errors and Exceptions

GavinZend
In reply to this post by Bruno Viana
Most surprising, I found the explanation here insufficient:
http://www.php.net/error_reporting

The explanation at http://www.php.net/errorfunc seems better:

"Note: In PHP 5 a new error level E_STRICT is available. As E_STRICT is
not included within E_ALL you have to explicitly enable this kind of
error level. Enabling E_STRICT during development has some benefits.
STRICT messages will help you to use the latest and greatest suggested
method of coding, for example warn you about using deprecated functions."

Cheers,
Gavin

Bruno Viana wrote:

> What means E_STRICT?
>
> On 10/10/06, *Darby Felton* <[hidden email] <mailto:[hidden email]>>
> wrote:
>
>     Hi all,
>
>     Though this is probably more appropriate for fw-docs, here we have the
>     most eyes, so here I post. :)
>
>     Ralph brought to my attention that the coding standards do not
>     indicate
>     E_STRICT compliance, so I made a quick addendum to the coding
>     standards
>     in the wiki:
>
>     The diff (it's a little buggy):
>
>     http://framework.zend.com/wiki/pages/diffpages.action?pageId=61&originalId=7347
>     <http://framework.zend.com/wiki/pages/diffpages.action?pageId=61&originalId=7347>
>
>     The wiki page view (at the bottom is the content I added):
>
>     http://framework.zend.com/wiki/x/PQ
>
>     Please provide feedback for revision as needed with your comments
>     here
>     or on the wiki page.
>
>     Thank you,
>     Darby
>
>
>
>
> --
> "Fui para os bosques viver de livre vontade. Para sugar todo o tutano
> da vida, para aniquilar tudo o que não era vida e para, quando morrer,
> não descobrir que não vivi."

--
Cheers,
Gavin

Which ZF List?
=================
Everything, except the topics below: [hidden email]

Authorization, Authentication, ACL, Access Control, Session Management
[hidden email]

Tests, Caching, Configuration, Environment, Logging
[hidden email]

All things related to databases
[hidden email]

Documentation, Translations, Wiki Manual / Tutorials
[hidden email]

Internationalization & Localization, Dates, Calendar, Currency, Measure
[hidden email]

Mail, MIME, PDF, Search, data formats (JSON, ...)
[hidden email]

MVC, Controller, Router, Views, Zend_Request*
[hidden email]

Community Servers/Services (shell account, PEAR channel, Jabber)
[hidden email]

Web Services & Servers (HTTP, SOAP, Feeds, XMLRPC, REST)
[hidden email]


How to subscribe:  http://framework.zend.com/wiki/x/GgE


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Coding Standards - Errors and Exceptions

Colin Ross
In reply to this post by Peter Hodge-5
Granted, but the point remains...

try {
... do something risky ...
} catch {
... error recovery code here ...
}
... cleanup code ...

I know the 'finally' debate has come up a couple times in the php-dev ml though.


I think that a good rule of thumb is to end your catch blocks with a simple catch(Exception $e) in order to be sure to catch all of them, even if all you are doing is rethrowing them, IMHO

 
On 10/10/06, Peter Hodge <[hidden email]> wrote:
--- Bill Karwin <[hidden email]> wrote:

> That's great, I was thinking of writing a section in the coding
> standards for exceptions too.  I've appended some more notes after
> yours, under a subheading "Exception best practices".

  "Clean up resources such as database connections or network connections. Use
a finally block for this."

PHP has no 'finally' support.

regards,
Peter



____________________________________________________
On Yahoo!7
Music: Create your own personalised radio station.
http://au.launch.yahoo.com/


Loading...