|
Posted by Josh Whiting on 01/07/05 02:36
> If I have a large app what is the difference, other than having a very
> large file, of doing this
>
> switch($action){
> /* several dozen cases to follow */
> case "foo":
> writing out all of the code
> break;
> }
>
> and this
>
> switch($action){
> /* several dozen cases to follow */
> case "foo":
> include that will handle processing this case
> break;
> }
>
> Correct me if I am wrong, but includes (and/or requires) will get all of
> the code in all of the cases regardless if the case is being processed.
> That being the case the code would essentially be the same length. Given
> that, would there be an efficieny issue?
>
> This would (the second way) also make the project easier to work on by
> multiple programmers at the same time, similar to modular work being
> done by programmers on C++ projects.
Correction: include() statements are executed at *run time*, which means
that if the case is not executed, the include will not be executed and
the file is not even read! The include() method is not only more
efficient but also easier to maintain as you suggest.
Otherwise, I'm curious as to why you're using a large switch, not that
it's bad inherently IMHO, but there may be a better overall approach.
/jw
[Back to original message]
|