什么是序列化的概念在编程语言中的意思? [英] What is the meaning of serialization concept in programming languages?

查看:211
本文介绍了什么是序列化的概念在编程语言中的意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是序列化概念的含义,编程语言?

What is the meaning of serialization concept in programming languages?

当我们使用序列化属性的类以上,是什么意思?

when we use Serializable attribute above a class, what is the meaning?

推荐答案

假设你有两个不同的物理机器上运行两个应用程序。两个应用程序的需要交换由通常用于两个应用程序的数据。这些应用相互交谈共享一些介质中的数据,这些介质可以是一个文件系统,TCP或UDP连接或任何其它合适的网络协议,或者可以是直接在内存中的数据交换。任何这些介质的只会理解,在一系列的比特的形式描述的数据。因此,当一个应用程序需要一个价值10发送到另一个,值10将被送到它的二进制再presentation 1010也将通过描述1010的一些信息,这些元信息也将是一系列的位的其他应用程序可以很容易地理解。这很简单,但。

Say you have two applications that run on two different physical machines. Both of the applications need to exchange data that is commonly used by both applications. These application talk to each other to share the data with some mediums, these mediums could be a file-system, tcp or udp connections or any other suitable network protocol or may be direct in-memory data exchange. Any of these mediums would only understand data that is described in the form of a series of bits. So when one application needs to send a value 10 to another, the value 10 would be sent as its binary representation 1010 and you would also pass some information that describes 1010. This meta information will also be a series of bits that the other application can easily understand. That was easy though.

让我们再举一个例子,其中这两个应用程序需要交换一个更复杂的,非原始数据类型。比方说,他们需要交换的类型书的对象,其中书是在应用程序中的自定义定义的类和这两个应用程序具有的类型书的定义。

Lets take another example, wherein these two apps need to exchange a more complex, non primitive data-type. Lets say they need to exchange the objects of type Book where Book is a custom defined class in your application and both the applications have the definition of type Book.

public class Book
{
    Book() { }

    public long BookId { get;set; }
    public string Author { get;set; }
    public string Title { get;set; }
}

您将如何交换的两个应用程序之间类型的书的对象?为了能够在两个应用程序之间共享的对象,你需要能够把书的对象为二进制重新presentation。这是序列化到图片

How will you exchange the objects of type book between the two applications? To be able to share the object between two apps, you will need to be able to convert the Book objects into binary representation. This is where serialization comes into the picture.

通过系列化的帮助下,你可以定义一个对象可以被转换成其二进制重新presentation。接收应用程序执行相反的过程,也就是反序列化,即构造一个Book对象从它的二进制重新presentation。

With the help of Serialization you can define how an object can be converted into its binary representation. The receiving application would do the reverse process, that is De-Serialization, that constructs a Book object from its binary representation.

这篇关于什么是序列化的概念在编程语言中的意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆