Re: Function size
| From: | shiplu | Date: | Wed, 23 May 2012 20:14:28 +0000 |
| Subject: | Re: Function size | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-317971@lists.php.net to get a copy of this message | ||
On Thu, May 24, 2012 at 1:56 AM, Matijn Woudt <tijnema@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
--
Shiplu.Mokadd.im
ImgSign.com | A dynamic signature machine
Innovation distinguishes between follower and leader