Use Value Objects to Separate Marshalling Code from Your Application Logic
Value objects are objects that contain data and very little behavior, aside from a few constructors that are convenient. They are encapsulations of information intended solely for communication between processes (they are more like structs in C or C++ than full-fledged objects). The idea behind using value objects is that by specifying remote interfaces, and then using data objects that play no further computational role, you separate the protocol definition (e.g., how the processes communicate) from the computational class structures (e.g., the objects and classes that the client or server needs to use to function effectively).
Building separate objects for data transmission might seem oppositional to standard object-oriented practices. And, to some extent, it is. But it’s not as contrary as you might think. Consider writing a stock-trading application. Your stock-trading application probably has an idea for a purchase order. But it’s not a single class—each part of the application deals with different aspects of the purchase order:
The client wants to help the customer enter data and verify the purchase order.
The networking infrastructure wants to send as little data as possible, in as efficient and robust a way as possible, to the server.
The server needs to validate the purchase order, execute it, and then store information in a database for auditing.
These are all aspects of the “purchase order idea.” ...