Clever Geek Handbook
πŸ“œ ⬆️ ⬇️

Serialization

Serialization (in programming) is the process of translating a data structure into a sequence of bits . The inverse of the serialization operation is the deserialization (structuring) operation β€” the restoration of the initial state of the data structure from a bit sequence.

Serialization is used to transfer objects over the network and to save them to files . For example, you need to create a distributed application , the different parts of which must exchange data with a complex structure. In this case, for the types of data that are supposed to be transmitted, code is written that performs serialization and deserialization. The object is filled with the necessary data , then the serialization code is called, the result is, for example, an XML document. The result of serialization is transmitted to the receiving party by, say, email or HTTP . The receiving application creates an object of the same type and calls the deserialization code, resulting in an object with the same data as was in the object of the sending application. Such a scheme works, for example, by serializing objects via SOAP in Microsoft .NET .

Content

Application

Any of the serialization schemes is inherent in the fact that the encoding of data is sequential by definition, and the extraction of any part of the serialized data structure requires that the entire object be read from beginning to end and recreated. In many applications, this linearity is useful because it allows the use of simple general-purpose I / O interfaces to store and transfer the state of an object. In applications where high performance is important, it may make sense to use a more complex, non-linear, organization of data storage.

Serialization provides several useful features:

  • a method for implementing object persistence , which is more convenient than writing their properties to a text file on disk and reassembling objects by reading files;
  • a method for making remote procedure calls , such as in SOAP ;
  • a method for distributing objects, especially in component-oriented programming technologies such as COM and CORBA ;
  • A method for detecting changes in data that change over time.

To make the most of these capabilities, you must maintain independence from architecture. For example, you must be able to reliably recreate a serialized data stream regardless of the byte order used in this architecture. This means that the simplest and fastest procedure for direct copying of the memory area in which the data structure is located cannot work reliably for all architectures. Serialization of data structures in an architecture-independent format means that there should be no problems due to different byte ordering, memory allocation mechanisms, or differences in the representation of data structures in programming languages.

Weaknesses

Serialization violates the opacity of the abstract data type, potentially revealing the private details of the implementation. Trivial implementations that serialize all data elements can break encapsulation.

To puzzle competitors with similar products, patented software developers often keep secret the details of their serialization formats. Some intentionally confuse or even encrypt serialized data. However, compatibility requires that applications be able to understand each other's serialization formats. Therefore, remote method invocation architectures such as CORBA specify their serialization formats in detail.

Array serialization in PHP

In PHP, an array is serialized using the serialize ($ array) function, where $ array is the array and the return value of the function is a text string. After that, the string can be turned back into an array using the unserialize ($ string) function, where $ string is the serialized array (string), and the return value of the function is the initial array.

Serialization of scientific data

For scientific datasets with a large volume, such as data obtained from satellites, or numerical models of climate, weather, and oceans, special binary serialization standards were developed, for example, HDF , netCDF, and the older GRIB .

See also

  • Marshaling
  • Json

Links

  • Serialization of data in C ++.
  • Serialization of PHP objects through the eyes of a hacker
Source - https://ru.wikipedia.org/w/index.php?title=Serialization&oldid=96927724


More articles:

  • Simeonovskaya church (Pereslavl)
  • Ludwig I (King of Bavaria)
  • Ukraine Transitional Football League 1992/1993
  • 1940 USSR Football Championship (Group A)
  • Busan University of Foreign Languages ​​- Wikipedia
  • Novoselkino rural settlement
  • Temporal Logic
  • Futsal national team of Belgium
  • Kleine Scheidegg
  • Solar Mass

All articles

Clever Geek | 2019