V
VisionSet
The usual example for a Socket based protocol is an enumeration of int
commands and a huge switch statement.
Yuk!
I'm thinking of a String command that is the name of a class, then loading,
instantiating and executing its single method, which accepts and returns an
Object.
All these methods will want to interact with some global attributes, so I'm
thinking have them as inner classes.
Not sure of the exact symantics but I'm guessing
Object response = Class.forName(OUTER_CLASS + "." +
command).newInstance().execute(commandArg);
[Casts removed for brevity.]
How's that sound?
Any advice wrt this ie improvements!?
commands and a huge switch statement.
Yuk!
I'm thinking of a String command that is the name of a class, then loading,
instantiating and executing its single method, which accepts and returns an
Object.
All these methods will want to interact with some global attributes, so I'm
thinking have them as inner classes.
Not sure of the exact symantics but I'm guessing
Object response = Class.forName(OUTER_CLASS + "." +
command).newInstance().execute(commandArg);
[Casts removed for brevity.]
How's that sound?
Any advice wrt this ie improvements!?