I have a mental problem on this subject because I do not know about patterns or best practices that fulfill this task (please, enlighten me on this subject).
My context is the following, using Sockets (concretely java.net.Socket
and java.net.SocketServer
) I have a client that makes requests to a server. These requests can be of different types (imagine a hypothetical class called peticion
from which different subclasses inherit), so the server has different methods declared to collect the information, depending on the type of the request. This information is treated through the implementation of REST, Jersey, the purpose of the requests is only to cause the execution of methods on the server to update the REST server information.
My problem is that I do not know how to differentiate the types of requests that arrive at the server and, according to this one, execute one method or another to update the information.
The custiones are as follows : is it a bad design if in the request class I set a variable String
called tipoPeticion
to help me process those requests? If not, what is the correct form? Is this defined in a pattern? Am I wrong and am I wrong?
They can answer any of the questions, but the one that would interest me the most is the second one.
I'm delighted to edit the thread if you think it's formulated!