[Previous] [Next]
Passing or returning an object by value results in the following consequences:
- Supports sharing of object copies between systems using different types of objects A key participant of the Object By Value design pattern is the ObjectTransformer class. It would not be too difficult to envision using a Conduit mechanism (such as COM or MSMQ) that is supported by dissimilar object systems to transport a data stream. Once the data stream is accepted by the recipient process, a native object transformer could produce a copy of the original object by correctly implementing the object conversion specification you, as the designer, set forth. For example, a Visual Basic object transformer could convert a Visual Basic object to a data stream, and a Pascal object transformer could convert the stream into a Pascal object copy of the original Visual Basic object.
- Encapsulates the internal state of an object Because the data stream is a byte array, you are not forced to explicitly expose the state of an object by deprivatizing that object. The persistable object contains the inherent functionality for updating its state from a byte array.
- No compile-time type checking Because the data stream is a byte array, there is no type checking at compile time. Therefore the potential for sending a byte array of invalid data to a recipient process is possible, wasting valuable processing cycles.
- Passing an object by value is not a language feature Although not terribly difficult to implement, significant programmer intervention and cooperation is required to adhere to the specification defined for implementation of the Object By Value design pattern.