水合物体意味着什么? [英] What does it mean to hydrate an object?

查看:94
本文介绍了水合物体意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当有人谈论保湿对象时,这意味着什么?



我在网上看到一个名为Hydrate的Java项目,它在不同的表示之间转换数据(RDMS到OOPS到XML)。这是物体水化的一般含义;在表示之间转换数据?这可能意味着从存储的表示中重建对象层次结构吗?

解决方案

关于更通用的术语 hydrate



保护一个对象正在获取一个存在于内存中的对象,该对象尚未包含任何域数据(真实数据),然后填充它域数据(例如来自数据库,来自网络或来自文件系统)。



来自Erick Robertson对此答案的评论:


反序列化==实例化+水合作用


如果您不需要担心起泡性能,并且您没有调试数据访问API内部的性能优化,那么您可能不需要明确地处理水合作用。您通常会使用反序列化,这样您就可以编写更少的代码。有些数据访问API没有为您提供此选项,在这些情况下,您还必须自己明确调用水合步骤。



有关详细信息,请参阅水化的概念,请参阅同一问题上的 Erick Robertson的回答



关于名为水合物的Java项目



<你专门询问了这个框架,所以我调查了一下。



据我所知,我不认为这个项目使用了水合物这个词在一般意义上。我认为它在标题中的用法是序列化的近似同义词。如上所述,此用法并不完全准确:



请参阅: http://en.wikipedia.org/wiki/Serialization


将数据结构或对象状态转换为一种格式,可以在以后的相同或另一个计算机环境中存储和重建。


我找不到他们的名字直接出现在水合物常见问题解答上,但我得到了他们意图的线索。我认为他们选择了Hydrate这个名字,因为该库的目的与流行的声音相似的 Hibernate框架相似,但它的设计考虑了完全相反的工作流程。



大多数ORM,包括Hibernate,采用内存中面向对象模型的方法,数据库需要考虑。 Hydrate库采用面向数据库模式的方法,保留您的关系数据结构,让您的程序更加干净地工作。



隐喻地说,仍然尊重到这个图书馆的名字: Hydrate 就像正在准备使用(如重新补水干食品)。它与 Hibernate 的隐喻相反,它更像是为冬天放置一些东西(如动物休眠)。



据我所知,决定命名库Hydrate并不关心通用计算机编程术语水合物。



当使用通用计算机编程术语水合物时,性能优化通常是动机(或调试现有的优化)。即使库支持对对象填充数据的时间和方式进行精细控制,时间和性能似乎也不是名称或库功能的主要动机。该库似乎更关注实现端到端映射和模式保存。


When someone talks about hydrating an object, what does that mean?

I see a Java project called Hydrate on the web that transforms data between different representations (RDMS to OOPS to XML). Is this the general meaning of object hydration; to transform data between representations? Could it mean reconstructing an object hierarchy from a stored representation?

解决方案

With respect to the more generic term hydrate

Hydrating an object is taking an object that exists in memory, that doesn't yet contain any domain data ("real" data), and then populating it with domain data (such as from a database, from the network, or from a file system).

From Erick Robertson's comments on this answer:

deserialization == instantiation + hydration

If you don't need to worry about blistering performance, and you aren't debugging performance optimizations that are in the internals of a data access API, then you probably don't need to deal with hydration explicitly. You would typically use deserialization instead so you can write less code. Some data access APIs don't give you this option, and in those cases you'd also have to explicitly call the hydration step yourself.

For a bit more detail on the concept of Hydration, see Erick Robertson's answer on this same question.

With respect to the Java project called hydrate

You asked about this framework specifically, so I looked into it.

As best as I can tell, I don't think this project used the word "hydrate" in a very generic sense. I see its use in the title as an approximate synonym for "serialization". As explained above, this usage isn't entirely accurate:

See: http://en.wikipedia.org/wiki/Serialization

translating data structures or object state into a format that can be stored [...] and reconstructed later in the same or another computer environment.

I can't find the reason behind their name directly on the Hydrate FAQ, but I got clues to their intention. I think they picked the name "Hydrate" because the purpose of the library is similar to the popular sound-alike Hibernate framework, but it was designed with the exact opposite workflow in mind.

Most ORMs, Hibernate included, take an in-memory object-model oriented approach, with the database taking second consideration. The Hydrate library instead takes a database-schema oriented approach, preserving your relational data structures and letting your program work on top of them more cleanly.

Metaphorically speaking, still with respect to this library's name: Hydrate is like "making something ready to use" (like re-hydrating Dried Foods). It is a metaphorical opposite of Hibernate, which is more like "putting something away for the winter" (like Animal Hibernation).

The decision to name the library Hydrate, as far as I can tell, was not concerned with the generic computer programming term "hydrate".

When using the generic computer programming term "hydrate", performance optimizations are usually the motivation (or debugging existing optimizations). Even if the library supports granular control over when and how objects are populated with data, the timing and performance don't seem to be the primary motivation for the name or the library's functionality. The library seems more concerned with enabling end-to-end mapping and schema-preservation.

这篇关于水合物体意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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