Ray said:
I'm pretty sure he's ONLY talking about IF/ELSEIF and not IF in general.
That's what I got from the message. Correct me if I'm wrong.
Of course, you're absolutely right -- I said specifically IF/ELSEIF.
My objection is not with the IF statement, of course I use that. In
fact, I use if/else for two choices and switch for three or more.
I find it interesting that some programmers, who have to be exact
with their syntax, can't read a simple statement containing proper
syntax without misreading it.
---
John C. Nichel IV said:
I remember IF constructs from BASIC and PASCAL, but no switch
statements (somebody correct me if I'm wrong). But what I'm
wondering is how in the world did you do conditional checking if
there were no switches, and you don't use IF's? Did you not code
error handling, different cases based on user input, status of a
data stream, etc in all the years prior to something like switch
being introduced???
I'm no programming historian, but from memory, Fortran, BASIC, and
PASCAL all started without a "switch" construct. However, later-on
BASIC most definitely provided a SELECT/CASE and PASCAL had a case
operation of some type -- as for FORTRAN, it's been a long time since
I did anything in it, I don't know.
As for how did I did conditional checking, I did it like every other
programmer of that day -- and without ELSE/IF's. You certainly can't
use the construct if it's not there -- using IF's sufficed and as I
said above, I NEVER said that I don't use if/else -- what I said was
I don't use if/elseif.
Actually, by you misreading my post, you provided support for my
claim that the use of if/elseif is confusing and thus less readable.
Clearly if I had said that I don't use the switch, there would have
been less confusion on your part, right?
---
Rob said:
I think I may have read too much into your previous post. Are you saying
specifically that you never use the elseif construct or any of the if,
elseif, else constructs? If the latter then I think your methodology is
somewhat asinine since I'm sure 99% of the programmers out there would
view code consisting entirely of switches in place of ifs with a huge
grain of WTF :)
You read too much? No, the case is that you didn't read enough -- or
you didn't comprehend what I wrote. I said that I NEVER use the
IF/ELSEIF construct. I did not say that I don't use IF/ELSE (forgive
my double negative). Don't be what you called my methodology.
As for what the 99% of programmers out there -- Locus ab auctoritate
est infirmissimus.
Also would you care to provide proof for your statistics?
---
Kevin provided:
benchmarks can be hazardous, but lets look at them at their most
basic level. By this
I mean how folks use them every day...
http://www.phpro.org/benchmarks/if-switch-benchmark.html
Thanks for the link. That fits with my tests -- however, the speed
difference, which in not significant IMO, is not at issue with me --
it's the readability. To me, the switch wins hands down in
readability over the multiple if/elseif's. However, I realize that's
a personal decision and do not claim good/bad practice in using
either.
---
M said:
If it can be used, I'd go for the clarity of switch.
I have yet to find a single problem where a switch can't be used to
replace multiple if/elseif's. I even posted an open query to this
list in that regard, and while at least one was compelled to call my
methodology asinine, no one could provide an example otherwise.
So my claim stands that you simply don't need the if/elseif construct
-- for it can be totally replaced with the switch. Now, someone prove
me wrong -- please -- I would like to know why the construct is still
around after being the evolutionary step between if/else and switch.
Is it just habit, or what?
Personally, as I said before, I use if/else for two conditions and
switch for three or more. Your mileage may vary, but it's truly a
matter of choice and is not one of asinine methodology.
Thanks to all who replied.
tedd
--
--------------------------------------------------------------------------------
http://sperling.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php