I have a basic class that takes a socket connection and sends different messages depending on which of the overloaded methods are called
public void send(byte[] message) {...}
public void send(String message) {...}
...
Each method parameter eventually gets converted to a byte array to be sent over the socket depending on the protocol. I was looking into the strategy pattern and it seems like it could be applicable. Instead of having one class with a number of overloaded methods, I could have different send strategies. The only question I have is how do I account for the different message parameter types? Or if there is a better way that I am missing, please let me know.
Aucun commentaire:
Enregistrer un commentaire