UML class diagram I

Source: Internet
Author: User

The basic purpose of a class chart is to display the types of modeling systems, including: classes, interfaces, data types, components, etc.

UML creates a classifier for these types. Classifier can be used as a class, but technically, classifier is a more common term.

Class Name

Class UML represents a rectangle, vertically divided into three areas, the top area shows the class name. The intermediate area lists the attributes of a class. Method of listing classes at the bottom.

Class Attribute list

The attribute section of a class lists the attributes of each class on the separator line. An attribute is optional. When it is used, it contains each attribute displayed in the list of classes.

Each parameter uses the following format: "parameter name: parameter type" or "parameter name: parameter type = default value"

Inheritance

 

Association

During system modeling, specific objects are associated with each other, and these associations must be clearly modeled. There are five associations.

Bidirectional (standard) Association

A bidirectional Association is represented by a solid line between two classes. One role name and multiple values are placed at either end of the online group.

Multiple values and their representation:

Possible multi-value descriptions
Indicates Description
0 .. 1 0 or 1
1 Only one
0 ..* 0 or more
* 0 or more
1 ..* One or more
3 Only three
0 .. 5 0 to 5
5. 15 5 to 15

Unidirectional Association

Two classes are related, but only one class knows the existence of this association.

A unidirectional link is a solid line with an open arrow pointing to a known class. Like a standard link, a one-way link includes a role name and a gold value description. However, unlike the standard and backward relationship, a one-way link only contains the role name and gold weight description of a known class.

Software Package,

Modeling in a large system or a large business field will have many different classifiers in the model. Managing all classes is very troublesome. Therefore, UML provides an organizational element called a package. The software package enables the modeler to organize the model classifier into the namespace.

There are two methods to indicate a software package. There are no rules for which labels are required, depending on the individual's judgment: Which type chart is easier for you to draw. Both methods start with a small rectangle nested in a large rectangle. The Modeler must determine how the package members represent it,

1. If the modeler decides to display the software package members in a large rectangle, all the Members must be placed in the rectangle. In addition, the names of all software packages must be placed in the smaller rectangle of the software package.

2. If the modeler decides to display the software package members outside the large rectangle, all the members displayed on the graph will be placed outside the rectangle. In order to display the classifier belonging to the software package, draw a line from each classifier to the circumference with the plus sign inside. These circles are attached to the software package.

Interface

A class is different from an interface: A class can have real instances of its form. However, an interface must have at least one class to implement it. In UML2, an interface is considered as a special element of class modeling. Therefore, the interface is drawn just like a class. But there is an "interface" in the top area of the rectangle ".

 

An interface and a specific implementation class are inherited by a solid line with a closed one-way arrow.

Association class

In associated modeling, other classes need to be included in some cases because they contain valuable information about the Association. In this case, the association class is used to bind your basic association. The associated class is the same as the general class. The difference is that the main class and the associated class are connected by a relatively point line.

 

 

Aggregation

Aggregation is a special type of association used to describe the relationship from population to locality. In the basic aggregation relationship, the lifecycle of a partial classification is independent of the lifecycle of the entire class.

1. Basic Aggregation

A class is part of another class. In an aggregation relationship, the subclass instance can be longer than the parent class. to present an aggregation relationship, draw a solid line from the parent class to the partial category, draw an unfilled prism at the end of the parent class association.

2. Combined Aggregation

A combination of aggregation relationships is another form of aggregation relationships, but the lifecycle of a subclass instance depends on the lifecycle of the parent instance. For example, a company class instance must have at least one department class instance.

3. Reflection Association

Class can also be associated with it using anti-Shooting Association.

Visibility

UML recognizes four types of visibility: public, protected, private, and package.

UML-supported visibility type flag

Flag Visibility type
+ Public
# Protected
- Private
~ Package

 

Conclusion

There are at least two important reasons for understanding class diagrams. The first is to display the static structure of the system classifier. The first reason is that the diagram provides the basic mark for other structural diagrams described by UML. Developers will think that class diagrams are specially set up by them, but other team members will find that they are also useful.

Business analysts can use class diagrams to model the business vision of the system.

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.