You get a bonus - 1 coin for daily activity. Now you have 1 coin

6.1 Basic elements of class diagrams

Lecture



We give some definitions and describe the main elements of the notation of class diagrams.

An object is some kind of real world essence or conceptual

(abstract) essence.

Example. Examples of objects are house number 4 on Sadovaya Street, an employee of the company Ivan Petrov, your computer. Or something abstract: chemical formula, trade order number 456789, bank account of the client Peter Ivanov.

The object has clearly defined boundaries and significance for the system and is characterized by state, behavior and individuality.

The state of the object is one of the conditions in which it can be. The state usually changes over time and is characterized by a set of properties called attributes.

Example. The buyer is determined by his name, address, telephone, date of birth.

Behavior determines how an object responds to requests from other objects and what the object itself can do. Behavior is characterized by object operations.

Example. The buyer can add the item to the cart, browse the catalog, remove the item from the cart.

Individuality means that each object is unique, even if its state is identical to the state of another object.

Example. Objects Maria Petrova and Anna Sedova are unique, although each of them is a buyer of the store and has the same behavior and conditions.

As a rule, in the system there are many objects with the same behavior, taking the same state. For example, employees of the company, which may be several dozen, and the data about which are contained in the database, have the same attributes — last name, first name, middle name, date of birth, position, etc. — with different values ​​of these attributes, and may also have similar behavior - apply for vacation or transfer to another unit. Classes are used to group objects.

A class is a description of a group of objects with common properties (attributes), behavior (operations), relationships with other objects, and semantics.

Each class is a template for creating an object. And each object is an instance of a class. It is important to remember that each object can

be an instance of only one class!

Example. In relation to the Style store, we can group the store employees by describing the Employee class common to them. An object of this class, for example, Ivan Petrov, may include the following information: name, address, position, salary, in addition, this object can go on vacation.

In the UML notation, classes and objects are depicted as rectangles (see Figure 31). The class rectangle is always divided into three sections (sections), the class name is placed in the first section, each word in the class name is usually written with a capital letter. In the second and third sections, attributes and operations of the class can be specified, respectively; these sections can be empty. The names of classes are chosen in accordance with the concepts of the subject area. It should be a noun or phrase in the singular, most accurately describing the subject. A class must describe only one entity.

Figure 31. Picture of classes and objects

  6.1 Basic elements of class diagrams

Figure 32. Distinguished class name

The class name can be simple, as shown in Figure 31, or composite (see Figure 32). A compound class name consists of the class name itself and the name of the package to which the class belongs, separated by a colon. The class name must be unique within the package.

A compound object name also consists of an object name and a class name, separated by a colon. An object can be anonymous if its real name is unknown. Then, in the diagram, an object is depicted with a name that consists of a colon and the name of the class to which the object belongs. If a class whose instance is an object is not yet known, the name of the object after which the colon is displayed is displayed. Such an object is called "orphan" (see Fig. 33).

  6.1 Basic elements of class diagrams

Figure 34. Class and its object

Example. The Employee class and the object of this class — some employee — can be represented as shown in Figure 34.

We gave the class object Employee a name that matches the class name.

created: 2015-11-11
updated: 2021-03-13
266



Rating 9 of 10. count vote: 2
Are you satisfied?:



Comments

fvv
14-06-2022
Хорошо написано, но мало. Желаю дальнейших творческих успехов

To leave a comment
If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Computer Engineering Technologies

Terms: Computer Engineering Technologies