| ユーザフォーラムで議論/質問 | マニュアル検索 | ハイライト | ハイライトオフ | ポータル | php spot |
Exceptions and normal program flowExceptions should never be used as normal program flow. If removing all exception handling logic (try-catch statements) from the program, the remaining code should represent the "One True Path" -- the flow that would be executed in the absence of errors. This requirement is equivalent to requiring that exceptions be thrown only on error conditions, and never in normal program states. One example of a method that wrongly uses the bubble up capability of exceptions to return a result from a deep recursion:
<?php In the example the ResultException is simply using the "eject!" qualities of exception handling to jump out of deeply nested recursion. When actually used to signify an error this is a very powerful feature, but in the example above this is simply lazy development. |
各種マニュアル:
PHPマニュアル |
PEARマニュアル |
Smarty(英語)マニュアル |
PHP-GTKマニュアル |
「Exceptions and normal program flow」をGoogle検索
|