title: Is passing different types of objects through an ObjectInputStream a good use case for instanceof?
body: <p>I'm new to java and programming and I've been learning over the last few days or so.</p>
  
  <p>I've read about how using the instanceof operator is bad practice, and I kind of understand why in their examples. However, I'm trying to write a client-server communication program and I'm trying to figure how to make a versatile platform for communication between them. So I made a messenger class and subclasses that extend it that hold different data types for communication.</p>
  
  <p>I'm trying to figure out how the server can tell which of these subclasses that I've created is sent with the ObjectInputStream without using the instanceof operator to tell. Is using instanceof okay in this situation, or should the object sent through the ObjectInputStream always be known so that it can be casted? Am I on the right track, or does the structure of my program need rethinking?</p>