Jump to content

Object diagram: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Cydebot (talk | contribs)
m Robot - Speedily moving category UML diagrams to Category:Unified Modeling Language diagrams per CFDS.
m Corrected my typo.
 
(43 intermediate revisions by 30 users not shown)
Line 1: Line 1:
{{Short description|Diagram showing the structure of objects in a system}}
[[File:Object diagram.png|thumb|320px|Example of a Object diagram.]]
[[File:Object diagram.png|thumb|Example of an object diagram.]]

In [[object-oriented programming]], an '''object diagram'''<ref>{{cite book
|chapter=Object Diagram
|title=Unified Modeling Language 2.5.1
|series=[[Object Management Group |OMG]] Document Number formal/2017-12-05
|date=December 2017
|publisher=[[Object Management Group]] Standards Development Organization (OMG SDO)
|page=735
|url=https://www.omg.org/spec/UML/2.5.1/PDF
}}
</ref>
in the [[Unified Modeling Language]] (UML) is a [[diagram]] that shows a complete or partial view of [[Object graph|the structure]] of a modeled [[system]] at a specific time.

== Overview ==
{{UML diagram types}}
{{UML diagram types}}
In the [[Unified Modeling Language]] (UML), an object diagram focuses on some particular set of [[Object (computer science)|objects]] and [[Attribute (computing)|attributes]], and the links between these instances. A correlated set of object diagrams provides insight into how an arbitrary view of a system is expected to evolve over time. Early UML specifications described object diagrams as such:<ref>[[Object Management Group]] (2001) [http://www.omg.org/spec/UML/1.4 UML specification 1.4], September 2001</ref><ref>Anne Banks Pidduck, [[John Mylopoulos]], Carson C. Woo (2002) ''Advanced Information Systems Engineering''. p.776.</ref>
An '''object diagram''' in the [[Unified Modeling Language]] (UML), is a [[diagram]] that shows a complete or partial view of the structure of a modeled [[system]] at a specific time.
<blockquote>"An object diagram is a graph of instances, including objects and data values. A static object diagram is an instance of a class diagram; it shows a snapshot of the detailed state of a system at a point in time. The use of object diagrams is fairly limited, namely to show examples of data structure."</blockquote>
The latest UML 2.5.1 specification does not explicitly define object diagrams,<ref name=OMG>{{cite book
|title=Unified Modeling Language 2.5.1
|series=[[Object Management Group |OMG]] Document Number formal/2017-12-05
|date=December 2017
|publisher=[[Object Management Group]] Standards Development Organization (OMG SDO)
|url=https://www.omg.org/spec/UML/2.5.1/PDF
}}
</ref>
but provides a notation for "instances" of classifiers.<ref name=OMG/>{{rp|126}}


An Object diagram focuses on some particular [[Set (computer science)|set]] of [[Object (computer science)|object]] [[Instance (programming)|instances]] and [[Attribute (computing)|attributes]], and the links between the instances. A [[Correlation|correlated]] set of object diagrams provides insight into how an arbitrary view of a system is expected to evolve over time. Object diagrams are more concrete than [[class diagram]]s, and are often used to provide examples, or act as test cases for the class diagrams. Only those aspects of a model that are of current interest need be shown on an object diagram.
Object diagrams and class diagrams are closely related<ref>Marcus Fontoura, Wolfgang Pree & [[Bernhard Rumpe]] (2002) ''The UML profile for framework architectures''. p.19</ref> and use almost identical notation.<ref>Kassem A. Saleh (2009) ''Software Engineering''. p.47</ref> Both diagrams are meant to visualize static structure of a system. While class diagrams show [[Class (computer programming)|classes]], object diagrams display instances of classes ([[Object (computer science)|objects]]).<ref>Bianca Scholten (2007) ''The Road to Integration: A Guide to Applying the ISA-95 Standard in Manufacturing''. p.155</ref> Object diagrams are more concrete than [[class diagram]]s. They are often used to provide examples or act as test cases for class diagrams. Only aspects of current interest in a model are typically shown on an object diagram.


==Object diagram topics==
==Object diagram topics==

===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 (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.
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.
Line 15: Line 41:
[[Image:Object Diagram Initial.png|thumb|right|400px|Initially, when n=2, and f(n-2) = 0, and f(n-1) = 1, then f(n) = 0 + 1 = 1.]]
[[Image:Object Diagram Initial.png|thumb|right|400px|Initially, when n=2, and f(n-2) = 0, and f(n-1) = 1, then f(n) = 0 + 1 = 1.]]


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


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.
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.
Line 31: Line 57:


==References==
==References==
{{reflist}}
{{Refimprove|date=February 2009}}


==External links==
==External links==
{{Commonscat|Object diagrams}}
{{Commons category|Object diagrams}}
* [http://www.uml.org/ General information on UML] including the official UML 2.0 specification. See especially the section on InstanceSpecification.
* [http://www.uml.org/ General information on UML] including the official UML 2.0 specification. See especially the section on InstanceSpecification.
* [http://advanceduml.wordpress.com/2008/09/26/what-a-month-in-the-financial-sector/ The Expressive Power of Object Diagrams], an illustration from the real world
* [http://advanceduml.wordpress.com/2008/09/26/what-a-month-in-the-financial-sector/ The Expressive Power of Object Diagrams], an illustration from the real world
* [http://www.se-rwth.de/materials/mod/ Modal object diagrams], an extension of object diagrams with existential/universal and positive/negative modes.


{{UML}}
{{UML}}
Line 42: Line 69:
{{DEFAULTSORT:Object Diagram}}
{{DEFAULTSORT:Object Diagram}}
[[Category:Unified Modeling Language diagrams]]
[[Category:Unified Modeling Language diagrams]]

{{uml-stub}}

[[de:Objektdiagramm]]
[[es:Diagrama de objetos]]
[[fr:Diagramme d'objets]]
[[it:Object Diagram]]
[[pl:Diagram obiektów]]
[[pt:Diagrama de objetos]]
[[fi:Oliokaavio]]
[[tr:Nesne Diyagramı]]
[[uk:Діаграма об'єктів]]

Latest revision as of 06:29, 11 June 2024

Example of an object diagram.

In object-oriented programming, an object diagram[1] in the Unified Modeling Language (UML) is a diagram that shows a complete or partial view of the structure of a modeled system at a specific time.

Overview

[edit]

In the Unified Modeling Language (UML), an object diagram focuses on some particular set of objects and attributes, and the links between these instances. A correlated set of object diagrams provides insight into how an arbitrary view of a system is expected to evolve over time. Early UML specifications described object diagrams as such:[2][3]

"An object diagram is a graph of instances, including objects and data values. A static object diagram is an instance of a class diagram; it shows a snapshot of the detailed state of a system at a point in time. The use of object diagrams is fairly limited, namely to show examples of data structure."

The latest UML 2.5.1 specification does not explicitly define object diagrams,[4] but provides a notation for "instances" of classifiers.[4]: 126 

Object diagrams and class diagrams are closely related[5] and use almost identical notation.[6] Both diagrams are meant to visualize static structure of a system. While class diagrams show classes, object diagrams display instances of classes (objects).[7] Object diagrams are more concrete than class diagrams. They are often used to provide examples or act as test cases for class diagrams. Only aspects of current interest in a model are typically shown on an object diagram.

Object diagram topics

[edit]

Instance specifications

[edit]

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

[edit]
Initially, when n=2, and f(n-2) = 0, and f(n-1) = 1, then f(n) = 0 + 1 = 1.

Consider one possible way of modeling production of the Fibonacci sequence.

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.

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.

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.

Usage

[edit]

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.

References

[edit]
  1. ^ "Object Diagram". Unified Modeling Language 2.5.1. OMG Document Number formal/2017-12-05. Object Management Group Standards Development Organization (OMG SDO). December 2017. p. 735.
  2. ^ Object Management Group (2001) UML specification 1.4, September 2001
  3. ^ Anne Banks Pidduck, John Mylopoulos, Carson C. Woo (2002) Advanced Information Systems Engineering. p.776.
  4. ^ a b Unified Modeling Language 2.5.1. OMG Document Number formal/2017-12-05. Object Management Group Standards Development Organization (OMG SDO). December 2017.
  5. ^ Marcus Fontoura, Wolfgang Pree & Bernhard Rumpe (2002) The UML profile for framework architectures. p.19
  6. ^ Kassem A. Saleh (2009) Software Engineering. p.47
  7. ^ Bianca Scholten (2007) The Road to Integration: A Guide to Applying the ISA-95 Standard in Manufacturing. p.155
[edit]