java - Design pattern for taking user input and invoking method -
I need to implement a control solution for a computer game that I am writing to take user input.
I'm looking at the command pattern, but it is not certain that there is a good fit for it.
IMO, command pattern is used more for this kind of situation if the command is completely transient So - you are not going to store or manipulate objects - then there is very little point in the extra complexity, object code overhead and the boilerplate to use the command.
A more appropriate approach Simple switch and method call Perhaps you can separate the interface from one implementation, though it can be done later (if you want a test or mark, Will do the same). If the keys can change, then the input value should be a straightforward map of the action value.
Comments
Post a Comment