ARTICLE AD BOX
I'm making a program where a server listens for requests from a client. My problem arises when the client sends a request and the server has to determine which kind of request it is in order to handle it.
My naive approach is to use a serializable object that wraps an enum representing the request type along with the data needed to process it, and then use switch statements to handle each specific request. But what if the program scales? It becomes cumbersome to write a lot of switch statements.
I found another way where each request type has a class linked to an action through an interface, and I handle them using a HashMap. Is this approach efficient, or is it too much overhead? Maybe I’m confusing things.
Please give me some guidelines on how to work with this. Thanks!
