我开始与面向对象编程(OOP)和想知道:什么是序列化的意义在面向对象的说法?


当前回答

序列化必须将二进制对象转换为XML(或其他字符串)表示形式,以便将其存储在数据库/文件中或通过web服务调用通过网络发送。反序列化是相反的过程——将XML/字符串转换回对象。

其他回答

When instantiating (constructing) the actual object(the thing) from a class (blueprint) there is a need to save the object (thing) by serializing it (breaking it down to its basic atomic structure) to a space in memory. (Kind of like Star Treks Transporter). You break the thing down into it stream of information that can be transported somewhere and stored. Then when you want to reconstruct the thing you just pull the atomically stored instance back into the object. Different from instaniation.

什么是序列化?

图片类比解释:

简介:

序列化意味着将某物(例如我的狗Rex)转换成一系列的1和0 -可以运输/存储等。我的海外朋友可以把这些1和0翻译成小狗的完美表现(反序列化)。

类比澄清

朋友们,这是个类比。我认为你还不能连载一只小狗。您可以序列化数据结构或其他复杂对象。(我写这个答案是为了让您能够以一种有趣的方式,在不到3秒的时间内理解这个概念,而不用绞尽脑汁去理解一个核心的技术定义),但如果您更喜欢一个规范的定义,请查看维基百科关于序列化的条目。

序列化必须将二进制对象转换为XML(或其他字符串)表示形式,以便将其存储在数据库/文件中或通过web服务调用通过网络发送。反序列化是相反的过程——将XML/字符串转换回对象。

序列化是将Java、c#或任何其他(OOP语言)支持的对象转换为可移植形式的过程。通过这种方式,它可以通过网络传输或存储在磁盘上。对于可序列化的类,它必须实现可序列化的接口。

序列化是将对象转换为字节流以存储对象或将其传输到内存、数据库或文件的过程。它的主要目的是保存对象的状态,以便在需要时能够重新创建它。