Okay guess this question looks a lot like:
consider this question CLOSED!
I would like to refactor code which looks something like this:
String input; // input from client socket.
if (input.equals(x)) {
doX();
} else if (input.equals(y)) {
doY();
} else {
unknown_command();
}
It is code which checks input from socket to perform some action, but I don't like the if else
construction because every time a new command is added to the server (code) a new if else has to be added which is ugly. Also when deleting a command the if else
has to be modified.