| Serialization |
Articles about Serialization |
Information AboutSerialization |
| CATEGORIES ABOUT SERIALIZATION | |
| programming constructs | |
| data structures | |
| data serialization formats | |
|
In Computer Science , in the context of data storage and transmission, serialization is the process of saving an Object onto a storage medium (such as a File , or a memory buffer) or to transmit it across a Network connection link in Binary form. The series of bytes or the format can be used to re-create an object that is identical in its internal state to the original object (actually a clone). This process of serializing an object is also called deflating or ''' Marshalling ''' an object. The opposite operation, extracting a data structure from a series of bytes, is '''deserialization''' (which is also called '''inflating''' or '''unmarshalling'''). USES Serialization has a number of advantages. It provides:
For some of these features to be useful, architecture independence must be maintained. For example, for maximal use of distribution, a computer running on a different hardware architecture should be able to reliably reconstruct a serialized data stream, regardless of Endianness . This means that the simpler and faster procedure of directly copying the memory layout of the data structure cannot work reliably for all architectures. Serializing the data structure in an architecture independent format means that we do not suffer from the problems of Byte Ordering , memory layout, or simply different ways of representing data structures in different Programming Language s. One issue that comes up in many serialization schemes is that, because the encoding of the data is serial, extracting one part of the serialized data structure requires that the entire object be read and reconstructed. Even on a single machine, primitive Pointer objects are too fragile to save, because the objects to which they point may be reloaded to a different location in memory. To deal with this, the serialization process includes a step called '' Unswizzling '' or ''pointer unswizzling'' and the deserialization process includes a step called '' Pointer Swizzling ''. CONSEQUENCES Serialization, however, breaks the Opacity of an Abstract Data Type by potentially exposing private implementation details. To discourage competitors from making compatible products, publishers of Proprietary Software often keep the details of their programs' serialization formats a Trade Secret . Some deliberately Obfuscate or even Encrypt the serialized data. Yet, interoperability requires that applications be able to understand the serialization of each other. Therefore Remote Method Call architectures such as CORBA define their serialization formats in detail and often provide methods of checking the consistency of any serialized stream when converting it back into an object. HUMAN-READABLE SERIALIZATION In the late markup language was used to produce a human readable text-based encoding. Such an encoding can be useful for persistent objects that may be read and understood by humans, or communicated to other systems regardless of programming language. It has the disadvantage of losing the more compact, byte stream based encoding, which is generally more practical. A future solution to this dilemma could be transparent compression schemes (see Binary XML ). XML is today often used for asynchronous transfer of structured data between client and server in Ajax web applications. An alternative for this use case is JSON , a more lightweight text-based serialization protocol which uses JavaScript syntax but is supported in numerous other programming languages as well. PROGRAMMING LANGUAGE SUPPORT Several Object-oriented Programming languages directly support ''object serialization'' (or ''object archival''), either by Syntactic Sugar elements or providing a standard Interface for doing so. Some of these programming languages are Ruby , Smalltalk , Python , Objective-C , Java , and the .NET family of languages. There are also libraries available that add serialization support to languages that lack native support for it. .NET Framework In the .NET languages, classes can be serialized and deserialized by adding the Serializable attribute to the class. 'VB Example // C# Example {Link without Title} class Employee If new members are added to a serializable class, they can be tagged with the OptionalField attribute to allow previous versions of the object to be deserialized without error. This attribute affects only deserialization, and prevents the runtime from throwing an exception if a member is missing from the serialized stream. A member can also be marked with the NonSerialized attribute to indicate that it should not be serialized. This will allow the details of those members to be kept secret.To modify the default deserialization (for example, to automatically initialize a member marked NonSerialized), the class must implement the IDeserializationCallback interface and define the IDeserializationCallback.OnDeserialization method.Objects may be serialized in binary format for deserialization by other .NET applications. The framework also provides the SoapFormatter and XmlSerializer objects to support serialization in human-readable, cross-platform XML.Objective-C In the Objective-C programming language, serialization (most commonly known as ''archival'') is achieved by overriding the write: and read: methods in the Object root class. (NB This is in the GNU runtime variant of Objective-C. In the NeXT-style runtime, the implementation is very similar.) Example The following example demonstrates two independent programs, a "sender", who takes the current time (as per time in the C Standard Library ), archives it and prints the archived form to the standard output, and a "receiver" which decodes the archived form, reconstructs the time and prints it out. When compiled, we get a sender program and a receiver program. If we just execute the sender program, we will get out a serialization that looks like: GNU TypedStream 1D@îC¡ |
|
|