延迟加载、急切加载、显式加载实际上是什么意思?

发布于 2024-11-02 14:35:57 字数 161 浏览 2 评论 0原文

我最近在参加我的新项目会议时开始了解惰性加载、显式加载和急切加载? 但是,我不明白为什么我们要研究这个? 我当时正在从事一个 silverlight 项目,其中还包括 WCF RIA 服务。我的导师正在解释这些类型的加载。 任何人都可以帮助我,以便我可以研究它们并向我的导师表明我对分配给我的任务有多么认真。

i recently came to know about lazy,explicit and eager loading as i was attending meeting for my new project?
But,i didn't get that why we are studying that?
I was to work on a silverlight project which also include WCF RIA services.My mentor was explaining these types of loading.
Can any one help me out so that i can study them and show my mentor that how serious i am in a task which is assigned to me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

三月梨花 2024-11-09 14:35:57

假设您有一个 CustomerOrder 类,并且该类具有 MyCustomer 属性和 MySalesOrderLines 属性。 MyCustomer 属性包含对表示订单客户的 Customer 类的引用,而 MySalesOrderLines 属性包含对订单的订单行集合的引用。在延迟加载中,这些属性返回的数据库记录只有在通过代码实际调用时才会从数据库中检索。即,当从数据库检索延迟加载的CustomerOrder实例时,只有当有一行代码引用CustomerOrder.MyCustomer时,才是从数据库检索的Customer实例。在预先加载中,这些属性是在从数据库检索 CustomerOrder 记录的同时从数据库检索的。

Say you have a CustomerOrder class, and this class has a MyCustomer property and a MySalesOrderLines property. The MyCustomer property contains a reference to the Customer class that represents the customer of the order, while the MySalesOrderLines property contains a reference to a collection of order lines for the order. In Lazy Loading, the databse records that these properties return are not retrieved from the database until they are actually called via code. ie, When retrieving a Lazy-Loaded CustomerOrder instance from the database, only when there is a line of code that refers to CustomerOrder.MyCustomer is the Customer instance retrieved from the database. In eager loading, these properties are retrieved from the database at the same time as when the CustomerOrder record is retrieved from the database.

水中月 2024-11-09 14:35:57

延迟加载就像我们在之前滚动时加载图像一样

lazy loading is like images load when we do scrolling not before than that

缱倦旧时光 2024-11-09 14:35:57

哦,既然你提到了 WCF RIA,我想你的老板正在谈论资源获取方面的这些模式。您还可以在实例化(对象)、加载(共享库)、状态(对象状态初始化)、评估(在使用结果之前不评估表达式)方面谈论惰性。同样的事情可能适用于不同用例中的其他模式名称。如果它与资源管理有关,那么......

这些是与对象获取相关的模式,并在 [POSA3 面向模式的软件架构:资源管理模式,第 3 卷][1] 中详细描述。

资源管理(您可以认为对象,但资源是一个更好的术语)分为四个阶段:查找、获取、生命周期和释放。您要求的模式是资源获取模式。

成功查找资源后,您有 4 种获取资源的策略可供选择:

  • 显式获取,即在请求时完全获取资源;这不是模式,而是正常用例

  • 延迟获取,当资源的获取可以推迟到稍后的时间点,即访问对象属性时(您最初将返回一个代理对象)。

  • 急切获取策略允许您进行预测性资源获取(即,您希望立即获取一组您知道在请求的初始资源的生命周期中将被请求的资源

  • 部分获取策略允许您进行分阶段获取;考虑大内存/未知大小的对象,最初您只想部分获取对象

Oh, since you mentioned WCF RIA I suppose your boss was talking about these patterns in terms of resource acquisition. You could also talk about laziness in terms of instantiation (objects), loading (shared libraries), state (object state initialization), evaluation (expressions not being evaluated until the result is used). Same thing probably applies to the other pattern names in different use cases. If its about resource management then...

These are patterns related to object acquisition and are described in detail in [POSA3 Pattern Oriented Software Architecture: Patterns for Resource Management, vol 3][1].

Resource management (you can think objects but resource is a better term) is organized in four stages: lookup, acquisition, lifecycle and release. The patterns you are asking for are resource acquisition patterns.

After you successfully lookup a resource, you have 4 strategies to choose from for acquiring the resource:

  • explicit acquisition, when the resource is to be fully acquired when requested; this is no pattern but a normal usecase

  • lazy acquisition, when the acquisition of the resource can be deferred in a later point in time, at the moment when the object properties are accessed (you will return a proxy object initially).

  • eager acquisition strategy allows you do predictive resource acquisition (that is, you want to acquire immediately a set of resources that you know will be asked for in the lifecycle of initial resource being requested

  • partial acquisition strategy allows you to do staged acquisition; think of big-memory/uknown-size objects, initially you will want to acquire the object only partially

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文