Don't like the way the VimConnection class handles events with the VimListener class. A received event is fired to all Listeners but this is inefficient seeing as an event will/should only ever trigger one listener.
Just using a big array/hash map of keys (event strings) to handler classes or methods seems the better option. Or just a giant switch statement.
We can still keep the basic handling of an event architecture which fires it to all listeners, but make one listener handle all events instead of an event per listener.
Logged In: YES
user_id=576604
Originator: NO
Right, i noticed that too recently. So mean something like:
HashMap<String,Class> knownlisteners = new HashMap<String,Class>();
knownlisteners.add("insert",TextInsert.class);
// add Listener classes for all known events.
for (IVimListener listener : listeners) {
if (listener instanceof knownlisterns.get(ve.getEvent())
listener.handleEvent(ve);
}
That way, the handleEvent methods in the Listener classes will get even simpler ... I like simple code :-)