Reputation:
I vaguely understand the concept of an object graph. Does it only apply to in memory objects built via composition; or is inheritance a structual attribute of the graph as well?
Upvotes: 0
Views: 440
Reputation: 21836
Inheritance has nothing to do with an object graph. Think of an object graph as an "instance graph", where vertices are instances, and (directed) edges are references between instances. The type of a particular instance has no bearing whatsoever on the graph; and yes, it is generally only built via composition.
The inheritance structure of a class is an entirely different concept that is often drawn as a graph (actually, with single-inheritance, it's a tree). This is just a coincidence.
Upvotes: 2
Reputation: 46148
The static inheritance tree is entirely separate to the runtime graph of object references from the GC roots. You can have a look at the structural graph by using the 'View Class Diagram' feature in VS, and look at the memory graph by using a memory profiler, of which other questions discuss the pros/cons of the ones available.
Upvotes: 0
Reputation: 19476
Personally I would only use the term "object graph" for in memory objects, and use a term like "class graph", "inheritance tree", etc. for the class structure tree.
Upvotes: 0