Let's say you have many paths that an application can take at a certain point based on the value of a specific input (for example a simple int
). Is there a certain method that is most efficient for picking which path to follow? A nice and organized way would be a simple switch
statement, but does that scale as the number of possible cases grows larger? Is there a better method when you have, say 100 or 1000 possible cases? Assume polymorphism isn't applicable and each case has totally unique functions which cannot be abstracted further.
Edit: Just to clarify, this is a thought experiment, I'm not actually writing code with 1000 cases. Also I found this related question to be enlightening on how the compiler/JIT handle the issue: http://programmers.stackexchange.com/questions/79111/why-use-an-oo-approach-instead-of-a-giant-switch-statement