I am creating a simple P2P file sharing system, where one peer can send some Objects (e.g., String, custom objects, etc...) to another peer.
The peer, that receives the Object, can then manipulate it, extract information from it and store it.
To receive and send objects, the classes Sender and Receiver are used, and these two compose my Network Layer. These two classes implement Sockets and TCP communication.
I tried to decouple the Network Layer from the Business Logic, but I am facing a design problem: whenever a serialized object is received by the Receiver and is sent to the Business Logic, where should be (and by which actor) mapped into a known Class?
Should it be the responsibility of the Network Layer to understand the class of this incoming serialized object, our should it be the Business Logic that (maybe using an "instanceof") converts the incoming objects to a well-known object?
Is there any pattern or best practice to apply in this situation?