Re: elseif statements

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2009-05-05 at 12:12 -0400, tedd wrote:
> 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.

It may be true that you are not using different languages, but without a
compelling argument for one form over another, one should generally take
the most general form that is understood and practiced by the majority.
You have not made a compelling argument for subverting usual semantics
to contort the logic into your vision.

> 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?

Your opinion is one thing... and this is indeed opinion, but you
entangled it with prescription:

    In my opinion, whenever your choices exceed two, use switch.
                            ----

You are certainly permitted your opinion, as I am too. I am offering my
opinion that your advice is bunk... and I have followed it up with
argument to back my stated views.

> 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.

This is certainly true, when you program for yourself, and you will be
the only maintainer of that code. But down the road it is quite likely
someone else will view that code and think to themself... WTF! And that
makes it a poor judgement call. Anyone can write Perl, but how many can
write Perl that a newbie can understand?

> 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.

I'm not looking for gratification... merely hoping to ensure that
readers of your niche style understand that it is niche, and that it is
not really the best option of all available options. You are welcome to
disagree, your opinion is your own, but as you have argued, we are all
entitled to our opinion. Those opinions with the greatest merit should
have the better supporting arguments (one would hope anyways :)

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux