views:

57

answers:

3

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"?

+4  A: 

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.

Daniel Earwicker
+3  A: 

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).

Ben Lings
+2  A: 

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.

Bryan Watts