为什么人们谈论 DI 框架“实例化对象图”?而不是“实例化对象”?

发布于 2024-08-26 11:32:09 字数 60 浏览 6 评论 0原文

我正在读一本关于 DI 的书,里面总是谈论 DI 框架“实例化对象图”。为什么这样说而不是“实例化对象”?

I'm reading a book about DI that always talks about DI frameworks "instantiating an object graph". Why say it this way rather than "instantiating objects"?

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

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

发布评论

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

评论(3

江南烟雨〆相思醉 2024-09-02 11:32:09

对象图由持有彼此引用的对象组成。在这种情况下,图的另一个名称是网络。

如果 IOC 系统忘记设置对象之间的引用,那么它就没有多大用处! IOC 系统的全部价值在于对象自动获取它们所需的其他对象的引用的方式。

A graph of objects consists of objects that hold references to each other. Another name for a graph in this context is a network.

An IOC system wouldn't be much use if it forgot to set up the references between the objects! It's the way the objects automatically get references to other objects they need that is the whole value of an IOC system.

末が日狂欢 2024-09-02 11:32:09

术语“对象图”意味着您有一组将同时创建的对象。使用此术语可以帮助区分依赖注入模式(您通常仅在单个位置引用 DI 框架)和服务定位器模式(您将在其中引用使用它在整个应用程序的多个位置创建/访问对象)。

The term "object graph" implies that you have a set of objects that will be created at the same time. Using this term can help distinguish between the Dependency Injection pattern (where you will usually only refer to the DI framework in a single place) and the Service Locator pattern (where you will use it to create/access objects in multiple places throughout your application).

初熏 2024-09-02 11:32:09

图是一组互连的对象。因此,它的实例化可以代表几个单独对象的实例化。

为了区分单个对象的创建和一组对象的创建,我们使用术语“对象图”。它有助于传达Resolve操作的范围。

A graph is a set of interconnected objects. Thus, its instantiation may represent the instantiation of several individual objects.

To distinguish the creation of a single object from the creation of a set of objects, we use the term "object graph". It helps to communicate the scope of the Resolve operation.

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