john boris wrote:
> I know I should use Switch
Brandon Allbery replied:
> Actually Switch is considered rather bad.
Paul Graydon asked:
> I don't think I've heard that before.. why is switch considered bad? In
> most languages it is supposed to be far more efficient than a nested if
> statement.
Sorry to beat a dead horse but...
"switch" (or case or any variation) is not a great way to validate
input. It means you need to update code every time the list changes.
It is better to put all the valid input into an array and check
against that. If all code refers to the array, all code will b
How is this solving the problem of "having to update code every time the list
of switch-inputs changes"?
The array is still part of the source-code so if a new school is added, the
code still needs to be updated.
D
On Dec 27, 2013, at 9:47 AM, Tom Limoncelli wrote:
> Sorry to beat a dead ho
Good point. I meant that if the list is repeated in many places, any
change to the list requires many code updates. It is easy to update
some but forget the others.
Even better is to load the list from a file so that only the file is
updated and never any code.
Tom
On Fri, Dec 27, 2013 at 9:49