Quantcast
Channel: Refactor java code - Stack Overflow
Viewing all articles
Browse latest Browse all 6

Refactor java code

$
0
0

Okay guess this question looks a lot like:

What is the best way to replace or substitute if..else if..else trees in programs?

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.


Viewing all articles
Browse latest Browse all 6

Latest Images

Trending Articles



Latest Images