MarkR
02-21-2006, 06:28 AM
Why is it, that a lot of PHP developers, seem to detest the idea of fail-fast? (http://failfast.com/)
Fail-fast has a great deal going for it. Yet PHP continues to fly in the face of overwhelming evidence, and suggest that it's a bad idea!
Even the manual pages (http://uk.php.net/manual/en/ref.errorfunc.php), say things like:
Enabling E_NOTICE during development has some benefits. For debugging purposes: NOTICE messages will warn you about possible bugs in your code.
This implies that E_NOTICE in production is not desirable! I find the opposite to be true. Errors are more likely to happen in production (because silly users use your app, and obnoxious robots hit your site etc), so you *REALLY* want to know about them. Even the smallest things, that E_NOTICE shows, are usually very siginificant.
In other languages, things that make E_NOTICE in PHP, often cause exceptions to be thrown (incidentally, I normally have my error handler throw exceptions in response to E_NOTICE or anything higher). The most common example is a missing key in an associative array.
---
Then open source applications[1], typically disable E_NOTICE and/or E_WARNING, because otherwise they'd create so many that the server would be significantly impeded just writing the error log!
Fail-fast is, IMHO, extremely good. All errors, warnings and notices should be enabled at all times in development *AND* production environments.
An E_NOTICE may indicate a bug which will subsequently cause data corruption - therefore, the application MUST NOT CHARGE HEADLONG INTO DESTRUCTION.
The old "oh, an error happened, but who cares, let's continue anyway!" days are long gone for me.
Mark
[1] Wordpress 2.0.1, wp-settings.php lines 65-66:
// Change to E_ALL for development/debugging
error_reporting(E_ALL ^ E_NOTICE);
Fail-fast has a great deal going for it. Yet PHP continues to fly in the face of overwhelming evidence, and suggest that it's a bad idea!
Even the manual pages (http://uk.php.net/manual/en/ref.errorfunc.php), say things like:
Enabling E_NOTICE during development has some benefits. For debugging purposes: NOTICE messages will warn you about possible bugs in your code.
This implies that E_NOTICE in production is not desirable! I find the opposite to be true. Errors are more likely to happen in production (because silly users use your app, and obnoxious robots hit your site etc), so you *REALLY* want to know about them. Even the smallest things, that E_NOTICE shows, are usually very siginificant.
In other languages, things that make E_NOTICE in PHP, often cause exceptions to be thrown (incidentally, I normally have my error handler throw exceptions in response to E_NOTICE or anything higher). The most common example is a missing key in an associative array.
---
Then open source applications[1], typically disable E_NOTICE and/or E_WARNING, because otherwise they'd create so many that the server would be significantly impeded just writing the error log!
Fail-fast is, IMHO, extremely good. All errors, warnings and notices should be enabled at all times in development *AND* production environments.
An E_NOTICE may indicate a bug which will subsequently cause data corruption - therefore, the application MUST NOT CHARGE HEADLONG INTO DESTRUCTION.
The old "oh, an error happened, but who cares, let's continue anyway!" days are long gone for me.
Mark
[1] Wordpress 2.0.1, wp-settings.php lines 65-66:
// Change to E_ALL for development/debugging
error_reporting(E_ALL ^ E_NOTICE);