Skip navigation.
Home

Reply to comment

Feels like Assertions

I agree with your assessment -- these checks are invaluable during development and initial QA, but once your code has stabilized, they're superfluous and just waste time and resources. These checks would be probably be implemented as assertions in other languages, which would be compiled away in production builds.

What would you think about retrofitting most of the ZF plumbing (controller, dispatcher, action base classes, etc.) so these checks would behave more like assertions which could easily be disabled? Something like:

if (! isset(ZEND_DISABLE_ASSERTIONS)) {
// do assertion-style checking
}
// do important code

And then in my bootstrap file, I could globally disable these expensive checks with a one-liner:

define(ZEND_DISABLE_ASSERTIONS, 1);

Sure, there would be a marginal bit of overhead with all of the isset() checks, but they're language constructs, so they're really fast. The difference for development environments would probably be hard to measure, but for production, it should make a noticeable difference.

Thoughts?

Reply

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
3 + 0 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.