Quantcast
Channel: Refactor java code - Stack Overflow
Browsing latest articles
Browse All 6 View Live

Answer by Anon for Refactor java code

You say that you're processing input from a socket. How much input? How complex is it? How structured is it?Depending on the answers to those questions, you might be better off writing a grammar, and...

View Article



Answer by Itay Maman for Refactor java code

Building the Command patten upon an enum class can reduce some of the boilerplate code. Let's assume that x in input.equals(x) is "XX" and y in input.equals(y) is "YY"enum Commands { XX { public void...

View Article

Answer by Instantsoup for Refactor java code

How about interfaces, a factory, and a little reflection? You will still need to handle exceptions on bad input, but you would always need to do this. With this method, you just add a new...

View Article

Answer by Romain for Refactor java code

One way could be to have an interface ICommand that is the general contract for a command, e.g.:public interface ICommand { /** @param context The command's execution context */ public void...

View Article

Answer by BalusC for Refactor java code

Collect those commands in a Map<String, Command> where Command is an interface with an execute() method.Map<String, Command> commands = new HashMap<String, Command>();// Fill it with...

View Article


Refactor java code

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...

View Article
Browsing latest articles
Browse All 6 View Live




Latest Images