AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
![]() ![]() Spent in 10% of the code, which means there won’t be any practical performance benefit unless your “CPU meter” is You intend to do serialization and/or unserialization on an inner loop/bottleneck. However that is relevant only if your application is CPU bound and Binary format typically uses fewer CPU cycles.Output you can open the serialized output with a text editor to see if it looks right. Text format is easier to “desk check.” That means you won’t have to write extra tools to debug the input and.There is no “right” answer to this question it really depends on your goals. How do I decide whether to serialize to human-readable (“text”) or non-human-readable (“binary”) format? This whole area of serialization has far more variantsĪnd shades of gray than can be covered in a few questions/answers. So please do not think of these categories as somehow sacred - they’re somewhat arbitrary, and you areĮxpected to mix and match the solutions to fit your situation. However in practice it often (not always) works out Theoretical reason for #2 to be any less sophisticated than #3-5. One more thing: the issues of inheritance and of pointers within the objects are logically unrelated, so there’s no More sophisticated technique than is minimally required. Remember: feel free to mix and match, to add to the above list, and, if you can justify the added expense, to use a Else if the graph of pointers within your objects don’t containĬycles and if the only joins are to terminal (leaf) nodes, use.Else if the graph of pointers within your objects contain neither.Else if your objects don’t contain pointers to other objects, use solution #2.If your objects aren’t part of an inheritance hierarchy and don’t contain pointers, use solution.The first step is to make an eyes-open decision between text- and.Here’s that same information arranged like an algorithm: Other objects, and when those pointers form a graph that might have Use the most sophisticated solution when the objects to be serialized contain pointers to.Use the fourth level of sophistication when the objects to be serializedĬontain pointers to other objects, and when those pointers form a graph with noĬycles, and with joins at the leaves only.Pointers to other objects, but when those pointers form a tree with no Use the third level of sophistication when the objects to be serialized contain. ![]() Inheritance hierarchy, but when they don’t contain pointers to other objects. Use the second level of sophistication when the objects to be serialized are part of an.Of an inheritance hierarchy (that is, when they’re all of the same class) and when they don’t contain pointers to Use the least sophisticated solution when the objects to be serialized aren’t part.Types in text format and how to write simple types in binary Decide between human-readable (“text”) and non-human-readable (“binary”)įormats.So think of this list merely as a good starting point. Might be wise to use a more sophisticated technique than is minimally needed if you believe future changes will require You will probably end up mixing ideas from several techniques.Īnd certainly you can always use a more sophisticated (higher numbered) technique than is actually needed. You are, of course, not limited to those five techniques. Simplified it to a decision between using human-readable (“text”) or non-human-readable (“binary”)įormat, followed by a list of five techniques arranged more-or-less in increasing Because I have a finite amount of time (translation: I don’t get paid for any of this), I’ve There are lots and lots (and lots) of if’s, and’s and but’s, and in reality there are a whole continuum of techniques The original complicated “something.” How do I select the best serialization technique? Like the Transporter on Star Trek, it’s all about taking something complicated and turning it into a flat sequence of 1sĪnd 0s, then taking that sequence of 1s and 0s (possibly at another place, possibly at another time) and reconstructing Mechanisms are to flatten object(s) into a one-dimensional stream of bits, and to turn that stream of bits back into Mechanism, then later, perhaps on another computer, reverse the process: resurrect the original object(s). It lets you take an object or group of objects, put them on a disk or send them through a wire or wireless transport Serialization and Unserialization What’s this “serialization” thing all about?
0 Comments
Read More
Leave a Reply. |