I have a switch statement that currently handles around 20 different numerical event types. The event ID ranges from 1000-5000. The switch
statement is becoming more difficult to maintain and read.
My idea is to put each event type into its own class and then store it into an EnumMap
. This approach will make the code maintainable and easier to read but what am I really sacrificing here?
Each client (ranging from 1000-5000 clients) that connects will have its own initialization of this EnumMap
along with the all the event type classes. This is a lot of overhead, is it not?
In regards to performance, is there any downside to using an EnumMap
over a switch
? Does javac
compile them similarly? There will be times where every millisecond counts.