At 11:29 AM -0400 5/5/09, Robert Cummings wrote:
On Tue, 2009-05-05 at 11:21 -0400, tedd wrote:
> At 10:13 AM -0400 5/5/09, Robert Cummings wrote:
> >Just so we all know why...
Yep -- just so we know why:
>
<http://php1.net/a/if-v-switch/>
>
It all depends upon how you use the tools at your command.
My preference is still valid and I think the code is more readable. YMMV.
Extra level of indentation, needing to add a break statement for every
case. Yours is more verbose and less clear. Forgetting a break statement
would lead to a silent bug. Abuse of the switch statement... switching
on a constant is not a switch at all. I consider it obfuscated. The
techniques you've used are also non-portable to most other languages
with a switch construct. Sorry, your attempt to call this good advice
fails.
Cheers,
Rob.
Rob:
I agree that the way I use the switch in my example does not port to
other languages, but I'm not working in other languages and it's the
way I solve my elseif problem in this language. If I was working in a
different language, then I would solve it differently. But I have
never used an elseif statement, nor do I intend.
If you will read my original post, I preference each statement with
"In my opinion". I can certainly have an opinion about the way I
choose to program, can't I? And, what's wrong with voicing that
opinion providing that you are stating it as your opinion?
While I see what you are doing and agree that your solution is
probably better for the majority than mine, your solution still
doesn't work for me. I find it confusing and I find my solution much
more readable and understandable. Others may find it so as well. As
the say in Perl, there is always more than one way to do anything.
I admit that you are a better php programmer than I, and I usually
learn from you, but on this point I can't follow.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php