Jump to content

Object diagram: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
KenSWebb (talk | contribs)
added link to main UML page
added links to other wikipedia pages; typo
Line 1: Line 1:
A [[Unified Modeling Language]] (UML) '''object diagram''' shows a complete or partial view of the structure of a modeled system, at a specific point in time. This snapshot focuses on some particular set of object instances and attributes, and the links between the instances. A correlated set of object diagrams can provide insight into how some arbitrary part of a system is expected to evolve over time. They are more concrete than UML class diagrams, and are often used to provide examples, or as test cases for the class diagrams. Only those aspects of a model that are of current interest need be shown on the object diagram.
A [[Unified Modeling Language]] (UML) '''object diagram''' shows a complete or partial view of the structure of a modeled system, at a specific point in time. This snapshot focuses on some particular set of [[Object (computer science)|object]] [[Instance (programming)|instance]]s and [[Attribute (computing)|attribute]]s, and the links between the instances. A correlated set of object diagrams can provide insight into how some arbitrary part of a system is expected to evolve over time. They are more concrete than UML [[class diagram]]s, and are often used to provide examples, or as test cases for the class diagrams. Only those aspects of a model that are of current interest need be shown on the object diagram.


==Instance specifications==
==Instance specifications==
Each object and link on an object diagram is represented by an ''InstanceSpecification''. This can show an object's classifier (e.g. an abstract or concrete class) and instance name, as well as attributes and other structural features using ''slots''. Each ''slot'' corresponds to a single attribute or feature, and may include a value for that entity.
Each object and link on an object diagram is represented by an ''InstanceSpecification''. This can show an object's classifier (e.g. an abstract or concrete [[Class (computer science)|class]]) and instance name, as well as attributes and other structural features using ''slots''. Each ''slot'' corresponds to a single attribute or feature, and may include a value for that entity.


The name on an instance specification optionally shows an instance name, a ':' separator, and optionally one or more classifier names separated by commas. The contents of slots, if any, are included below the names, in a separate attribute compartment.
The name on an instance specification optionally shows an instance name, a ':' separator, and optionally one or more classifier names separated by commas. The contents of slots, if any, are included below the names, in a separate attribute compartment.


A link is shown as a solid line, and represents an instance of an assocication.
A link is shown as a solid line, and represents an instance of an [[Association (object-oriented programming)|association]].


==Object diagram example==
==Object diagram example==
Line 26: Line 26:
==Working with object diagrams==
==Working with object diagrams==


If you are using a UML modeling tool, you will typically draw object diagrams using some other diagram type, such as on a class diagram. An object instance may be called an ''instance specification'' or just an ''instance''. A link between instances is generally referred to as a ''link''. Other UML entities, such as an aggregation or composition symbol (a diamond) may also appear on an object diagram.
If you are using a [[UML tool|UML modeling tool]], you will typically draw object diagrams using some other diagram type, such as on a [[class diagram]]. An object instance may be called an ''instance specification'' or just an ''instance''. A link between instances is generally referred to as a ''link''. Other UML entities, such as an [[Aggregation (object-oriented programming)|aggregation]] or [[Object composition|composition]] symbol (a diamond) may also appear on an object diagram.


==External links==
==External links==

Revision as of 02:26, 11 August 2006

A Unified Modeling Language (UML) object diagram shows a complete or partial view of the structure of a modeled system, at a specific point in time. This snapshot focuses on some particular set of object instances and attributes, and the links between the instances. A correlated set of object diagrams can provide insight into how some arbitrary part of a system is expected to evolve over time. They are more concrete than UML class diagrams, and are often used to provide examples, or as test cases for the class diagrams. Only those aspects of a model that are of current interest need be shown on the object diagram.

Instance specifications

Each object and link on an object diagram is represented by an InstanceSpecification. This can show an object's classifier (e.g. an abstract or concrete class) and instance name, as well as attributes and other structural features using slots. Each slot corresponds to a single attribute or feature, and may include a value for that entity.

The name on an instance specification optionally shows an instance name, a ':' separator, and optionally one or more classifier names separated by commas. The contents of slots, if any, are included below the names, in a separate attribute compartment.

A link is shown as a solid line, and represents an instance of an association.

Object diagram example

As an example, consider one possible way of modeling production of the Fibonacci sequence.

File:ObjectDiagram Initial.png
Initially, when n = 2, and f(n-2) = 0, and f(n-1) = 1, then f(n) = 0 + 1 = 1.

In the first UML object diagram on the right, the instance in the leftmost instance specification is named v1, has IndependentVariable as its classifier, plays the NMinus2 role within the FibonacciSystem, and has a slot for the val attribute with a value of 0. The second object is named v2, is of class IndependentVariable, plays the NMinus1 role, and has val = 1. The DependentVariable object is named v3, and plays the N role. The topmost instance, an anonymous instance specification, has FibonacciFunction as its classifier, and may have an instance name, a role, and slots, but these are not shown here. The diagram also includes three named links, shown as lines. Links are instances of an association.

File:ObjectDiagram 2.png
After the first iteration, when n = 3, and f(n-2) = 1, and f(n-1) = 1, then f(n) = 1 + 1 = 2.

In the second diagram, at a slightly later point in time, the IndependentVariable and DependentVariable objects are the same, but the slots for the val attribute have different values. The role names are not shown here.

File:ObjectDiagram N.png
After several more iterations, when n = 7, and f(n-2) = 5, and f(n-1) = 8, then f(n) = 5 + 8 = 13.

In the last object diagram, a still later snapshot, the same three objects are involved. Their slots have different values. The instance and role names are not shown here.

Working with object diagrams

If you are using a UML modeling tool, you will typically draw object diagrams using some other diagram type, such as on a class diagram. An object instance may be called an instance specification or just an instance. A link between instances is generally referred to as a link. Other UML entities, such as an aggregation or composition symbol (a diamond) may also appear on an object diagram.