Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of UML object Graph

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article shares with you the content of a sample analysis of UML object graphs. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

1.UML object graph

The object graph is used to describe the structured information between the model element instances of the modeled system, which expresses some or all of the structural views of the modeled system at a particular time. A UML object graph focuses on specific object instances and their slots, as well as connections between instances. There can be multiple object diagrams corresponding to the same class diagram, and multiple object diagrams together show the object state of the system at different points in time. Compared with the abstraction of the class diagram, the object diagram is specific, and it is usually used to provide an example of the structure of the corresponding class diagram, or as a test case for the corresponding class diagram. It should be said that each object map has its own focus, therefore, each object map should only focus on expressing what it focuses on.

In UML, object instances are represented by instance specification (instancespecification, see 1.1), the structural properties of object instances (feature) are represented by slots (slot, see 1.2), and the relationship between object instances and object instances is represented by connections (link, see 1.3). Compared with the class diagram, the instance corresponds to the class object, the slot corresponds to the instance of the class attribute, and the connection corresponds to the instance associated between the class. With these corresponding relations, in the case of mastering the class diagram, it is easier to understand and master the object diagram.

Figure 1.1 is the syntax definition of the modeling elements related to the object graph in the UML specification, which we will explain in more detail later when we explain the specific concepts.

Figure 1.1 Syntax of class diagram elements in the UML specification

1.1 instance specification

The UML object Graph instance specification (instancespecification, see Section 7.3.22 of USS) is used to represent the instance entities in the modeled system, which describes some or all of the model instance entities. When we program, the instance that we talk about verbally is called instance specification in UML. The content described by the instance specification may include:

1) the classifier to which one or more instances belong. In the instance specification, if a classifier is a class, it describes the objects of the class; if a classifier is an association, then it describes a connection of the association.

2) the value of the structured property. The structured properties correspond to the attributes of the class used to describe the structural composition of the class. The behavioral characteristics are represented by operation in the class diagram, but not in the object graph. In the instance specification, we do not have to represent all the structured features of all instances.

3) how to calculate, deduce or construct an example.

An instance specification is used to indicate the entities that exist in the modeled system. The information in the case specification can be incomplete and only focuses on expressing the information of concern. The following information can be obtained from figure 1.1:

1) an instance specification is a packagable element because an InstanceSpecification is a PackageableElement.

2) an instance specification can contain any number of slots, as can be seen from its slots composition property.

3) an instance specification can contain at most one value specification (valuespecification, see Section 7.3.54 of USS), as can be seen from its specification composition attribute. In a nutshell, the value specification represents what is the range of values available for an object.

4) an instance specification can contain any number of classifiers, as can be seen from its classifiers association attribute.

An example specification can include slots, and each slot is actually an expression of a structured feature. The instance specification in UML object graph is an object instance of one or more classifiers, so it follows the structure or / and behavior specification defined by the classifier. The specification of an instance without slots does not mean that it does not have structural features, because it is possible that those structural properties are not of concern to this object graph.

It should be noted that the instance specification is not an accurate description of the run time of the modeled system, but an example, which only represents the relevant structural information. We cannot derive any details of the runtime object structure from the instance specification.

Figure 1.2 is an example of using an instance specification, where each rectangle is an instance specification. Figure 1.3 is the corresponding class diagram. Where my_car is an instance without slots, while other Window instances are with two slots. You will notice that the representation of the instance specification is similar to the classes in the class diagram, but with the following differences:

1) there is an underscore under its name, and the name of the instance and the classifier to which it belongs are marked on the line). The instance name and the classifier are segmented by':', and if there are multiple classifiers, then the classifiers are separated by commas. All the instance specifications in figure 1.2 have only one classifier. For example, the classifier to which my_car belongs is the Car class, which means that my_car is an instance of the Car class, while front_left, front_right, rear_left, and rear_right are all instances of the Window class.

2) slots correspond to attributes in the class, but they all have values in the instance specification. If there is no value, it is usually not expressed in the instance specification.

Figure 1.2 an example of using the instance specification

Figure 1.3 the class diagram corresponding to the object diagram in figure 1.2

Figure 1.2 is a relatively simple UML object graph, but in practical applications, we can use multiple object graphs to show the state of the same instance at different points in time, and different states are expressed by different values of slots. For example, we can use object graph to represent an algorithm, and different object graphs to represent the state of each instance of the same algorithm at different time points (different values in slots).

1.2 slot

Slots (slot, see Section 7.3.48 of USS) are values used to represent the structural characteristics of the modeled entities in the instance specification. Slots correspond to the attributes of the class in the class diagram and are instances of class attributes, which are descriptions of the structured properties of the class. As you can see from figure 1.1, a slot has three properties:

1) definingFeature indicates what the structural characteristics of this slot are.

2) owningInstance indicates which instance specification this slot belongs to.

3) value indicates what the value of the slot is.

Each Window instance specification in figure 1.2 has two slots. The definingFeature of the name slot should be the name of the window. Obviously, the owningInstance of the name slot is each Window instance, while the value is different for each Window instance, some are called "frontleft", and some are called "rearleft". Similarly, is_automatic slots are used to indicate whether each window is automatic.

1.3 connection

There is no chapter devoted to link in the UML specification, but it is mentioned in the example specification section. It defines the relationship between instance specifications. From the point of view of class diagram, a connection is an instance of an association relationship. Figure 1.2 illustrates four connections between the Car class instance specification and the Window class instance specification. Comparing figure 1.2 and figure 1.3, we can see that the four connections in figure 1.2 are examples of associations in figure 1.3.

Thank you for reading! This is the end of this article on "sample Analysis of UML object Graph". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report