design patterns - (De/)Serialization as an interface for file-based data exchange in C++ -
I am trying to get some general understanding of the proper use of the serialization for data transfer. Imagine that we have two binarys in each binary, there are some internal representations of data that fit their internal use model and the presentation is different in binary. Now we want to pass some data from one binary to the other.
Two options:
- Use a support class, which has serialization / decarilization methods, class is optimized for storage and all file presentation logic is one place Keeps on
- Use custom readings / writing in a standard format separately from internal structures in each binary, it allows to avoid overhead to create an assist class installation and double copy.
Question:
- What should I speculate to understand the applicability of two views in a particular case?
- Is there any way to reconcile the solution in a way that protects the professionals of both of them?
The practical reality is that there is very little to separate the two ways suggested by you is. But many important implementations are trade-offs that you should consider. Include:
- Whether the serial format should be human readable or binary, can be human readable by CSV, XML, JSN, YAML. Binary ASN.1, custom format, can be output from the serialization libraries.
- How broad will the format be in relation to future changes? Do you need file format version number? Do you want permission for arbitrary area?
- Is it necessary to be on the basis of standards and in the future other applications also participate in this information exchange.
- Should it use SSL / TLS, the data should be encrypted etc.
- How reliable and / or performance dosage should be interchangeable XML data comes with XSD verification, but is not as fast as it is to parse as other formats. If you need reliable delivery, you should use message queue (activivac, msmq etc)?
- How to share binary data: Viewed folders, Memory mapped files, Named pipes, Sockets, Message queues, Boost :: asio, Thrift, XML RPC, HTTP, SOAP , REST etc.
Can you serialize a category using boost :: serialization or google protocol buffers or write that you write and read the manual XML DOM data The code for is a short description of the more important ideas of your design. However, in my experience, if you have the flexibility to use a custom data format using the serialization code, then it performs better, and less quality issues than home solutions.
Comments
Post a Comment