On Wed, May 23, 2012 at 10:14 PM, shiplu <shiplu....@gmail.com> wrote:
> On Thu, May 24, 2012 at 1:56 AM, Matijn Woudt <tijn...@gmail.com> wrote:
>> I agree that large switch block are not always easy and useful to split,
>> however, writing too much code inside a switch block isn't considered good
>> practice too IMO. Though, it is unavoidable in some cases I think. I do have
>> some of these functions in my code too, I have one switch block of more than
>> 500 lines, but that's just because I have more than 400 individual case
>> statements, and I don't think there's a better way to do it. Doesn't mean I
>> like it btw.
> I never encounter such big switch statement in PHP yet. However I saw huge
> switch and had to optimize it while  working with a custom programming
> language interpreter written in C.  When I see the language is OO, I try to
> apply polymorphic behavior and eliminate any switch statements. Here is a
> video that demonstrated the concept
> http://www.youtube.com/watch?v=4F72VULWFvc

This is interesting. You do realize that if I would take this switch
down to OO, I would have to create 400 different classes to replace
this switch statement? Luckily in PHP we can have more classes in a
single file, thinking about Java for example would mean I have to
create 400 new files...
I like the concept, but I don't see how it works for such switch statements.

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

Reply via email to