note 71942 rejected from function.assert by danbrown
| From: | danbrown@php.net | Date: | Mon, 21 Jul 2008 03:56:54 +0000 |
| Subject: | note 71942 rejected from function.assert by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142407@lists.php.net to get a copy of this message | ||
Note Submitter: tom russo at gmail dot com
----
hodgman at ali dot com dot au said:
"Assertions should only be enabled during testing/development, and then disabled once your code
reaches a production stage."
Assertions should _not_ be turned off in production code. Although it's common to do so,
turning off assertions in production is a bad practice.
If your production code fails an assert, YOU WANT TO KNOW ABOUT IT. Asserts are a debugging tool,
but you should not stop debugging your code just because it has gone into production.
Many people claim that removing asserts gives a performance benefit. In modern programming
languages this simply isn't true. If you were doing an assert on something that is extremely
slow/expensive to compute, you might consider turning that assert off. But in practice this really
isn't how asserts are used.
There's a good discussion of this issue in the book The Pragmatic Programmer.