Re: switch vs elseif
| From: | Kirk dot Johnson at zootweb dot com | Date: | Tue, 13 Jan 2009 22:03:51 +0000 |
| Subject: | Re: switch vs elseif | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-286278@lists.php.net to get a copy of this message | ||
I regret that I don't recall who made the brilliant observation that
programmers spend the majority of their time *reading* code (their own or
others) as opposed to *writing* code.
So, I make it a point to try to make my code easily scannable. I only and
always use the switch construct when evaluating the value of a single
variable. The switch then tells me that at a glance when I'm reading code,
and I don't have to plow through a bunch of elseif clauses to get the big
picture of what the code is doing.
The bottom line for me on this issue is the "bottom line" - productivity.
Kirk