Link Details

Link 147927 thumbnail
User 285573 avatar

By alashcraft
via elegantcode.com
Published: Jan 12 2009 / 01:58

Switch, select, case, really long if statement…whatever the cause, when they get too long they all become unmanageable. Overly long switch statements do exists, I’ve written them, we have all seen them in other peoples code. In fact, I remember hearing, from a fellow Elegant Coder, that a coworker of his hit the limit for how many cases can be in a .Net switch statement. I don’t remember what the limit was, but it was a lot, and they exceeded that number.
  • 9
  • 2
  • 1131
  • 473

Comments

Add your comment
User 372108 avatar

cristian.malinescu replied ago:

0 votes Vote down Vote up Reply

Neither splitting into multiple methods or polymorphism is the right solution. The right solution is the *Strategy Pattern*.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.