Object graph

In computer science, in an object-oriented program, groups of objects form a network through their relationships with each other—either through a direct reference to another object or through a chain of intermediate references. These groups of objects are referred to as object graphs.

An object graph is a view of an object system at a particular point in time. Whereas a normal data model such as a UML class diagram details the relationships between classes, the object graph relates their instances. Object diagrams are subsets of the overall object graph.

Object-oriented applications contain complex webs of interrelated objects. Objects are linked to each other by one object either owning or containing another object or holding a reference to another object. This web of objects is called an object graph and it is the more abstract structure that can be used in discussing an application's state.

Physical representation

An object graph is a directed graph, which might be cyclic. When stored in RAM, objects occupy different segments of the memory with their attributes and function table, while relationships are represented by pointers or a different type of global handler in higher-level languages.

Examples

For instance, a Car class can compose a Wheel one. In the object graph a Car instance will have up to four links to its wheels, which can be named frontLeft, frontRight, backLeft and backRight. Example of an adjacency list representation: c:Car → {frontLeft:Wheel, frontRight:Wheel, backLeft:Wheel, backRight:Wheel}.

gollark: - `make`/`new` are basically magic- `range` is magic too - what it does depends on the number of return values you use, or something. Also, IIRC user-defined types can't implement it- Generics are available for all of, what, three builtin types? Maps, slices and channels, if I remember right.- `select` also only works with the built-in channels- Constants: they can only be something like four types, and what even is `iota` doing- The multiple return values can't be used as tuples or anything. You can, as far as I'm aware, only return two (or, well, more than one) things at once, or bind two returns to two variables, nothing else.- no operator overloading- it *kind of* has exceptions (panic/recover), presumably because they realized not having any would be very annoying, but they're not very usable- whether reading from a channel is blocking also depends how many return values you use because of course
gollark: What, you mean no it doesn't have weird special cases everywhere?
gollark: It pretends to be "simple", but it isn't because there are bizarre special cases everywhere to make stuff appear to work.
gollark: So of course, lol no generics.
gollark: Well, golang has no (user-defined) generics, you see.

See also

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.