title: Java Socket Programming: Dealing with multiple types of messages
body: <p>I'm developing a simple Multicast networked program, and was just curious on the best class structure and OOD patterns that best suit a client/server or client/client network.  My dilemma is that I will be sending different kind of messages via datagram, and the receiver just sees a bunch of bytes coming at them.  Now, I already implemented a sort of "ID" placeholder as the first byte of all of my byte arrays to distinguish between a message containing "hello world" and one containing the coordinates of a user for instance.  The only option seems to be to just have a huge set of case statements in my "receive" method based on what the "ID" is but this seems like bad practice.  Just looking for ideas to take advantage of Java's OOD patterns and all-around good coding practice.</p>
  
  <p>On a side note (I think this is somewhat related...)  would it be advantageous for me to ues object streams instead?  It seemed to me that I would still be checking instancof on everythign coming in. Thanks!</p>