StarUML 7. Class diagram example of StarUML


Concepts in UML class diagrams

Class diagram relationships: generalization (inheritance), implementation, aggregation, composition, association, dependency

The detailed explanation of class diagram can be found on the Internet (recommended

It describes the relationship between objects and them in a system, which enables us to have a comprehensive understanding of the system before writing code correctly.
A separate class diagram describes a specific aspect of the system, and the collection class diagram represents the whole system. Basically, a class diagram represents a static view of the system.

1: Create a new project, or create according to the template (you can create a new project at the beginning),

2: In the model Explorer on the right, right-click the top node or model node, and select add classDiagram

3: Working on the leftDiagrams Click to activate the canvas to be modeled (there are usually multiple canvases in a projectDiagram, it needs to be determined which model is in the process of design

4: Select class in toolbox, double-click or drag the drawing view element in drawing area

5: As shown in the figure below, a view element of class is drawn, and a string attribute of type is added. Method 1 has a string parameter, and method 2 has a string parameter and needs to return a string result


Now we want to implement a class diagram design, the requirements are as follows

1: Interface – car; 2: implementation class – car, bicycle; 3: tire, engine class constitute car; 4: BMW is a kind of car; 5: students need to ride bicycle; 6: each student has ID card; 7: each student has class;

Design a class diagram according to the requirements.

New blank item, add classDiagram,

Interface car –——-Drag an interface to view element, name attribute to car, view element to add attribute method, and description to car



Realization of automobile and bicycle—As above, drag two view elements class, add connection line interface, point to vehicle interface, and represent the implementation of interface;

The style of view element lines can be adjusted in online properties



Realization tire and engine—For the same operation, drag two view elements class and add the connection line composition. The combination relationship line can set the relationship between two ends


 Implementation class BMW—As above, drag the view element class and add the connection line generation


The implementation operations of other requirements are basically the same, only connecting lines represent differences, and the figure below is the overall diagram after the implementation of the model

Multiplicity of skill Association:

1: 0.. * or*—In the relationship of view elements, connecting lines represent 0 to more than one;

2:  0..1In the relationship of view elements, the connecting lines represent 0 to 1;

3:  1—-In the relationship of view elements, the connecting line represents one;