What could be the best practices of writing the following case:
We have a controller which based on what paths users take, take different actions. For example:
if user chooses the path /path1/hello it will say hello. If a user chooses /path1/bye?name="Philipp" it will invoke sayGoodBye() and etc.
I have written a switch statement inside the controller which is simple, however IMO not efficient. What are the best way to implement this, considering that paths are generally String.
private void takeAction()
{
switch (path[1])
{
case "hello":
//sayHello();
break;
case "bye":
//sayBye();
break;
case "case3":
//Blah();
break;
...
}
}
UPDATE: In my context, the path is dynamically generated, meaning that there are not specific pages to be there. If the path is /Amir/ then Amir will be dynamically generated. Therefore, as Mark Leighton Fisher explained, it is rather difficult to put them in hashes.