[Static] UML diagram - class diagram

Foreword

    After completion of the use case diagram of the system, it can be used in accordance with the embodiment of FIG participants performed by the UML static design and, respectively, the static FIG class diagrams, object diagrams and package of FIG.

    FIG class is described classes, interfaces, collaboration and a relationship between them, the static structure of the system used to display each class.

text

   FIG class contains seven elements: classes, interfaces, collaboration, dependency, generalization, and association relationships achieve.

    FIG other UML modeling, classes may also include annotations and FIG constraints. FIG class may also contain packages and subsystems.

 A class diagram elements - classes

    Based on the map is rectangular, it is divided into three parts: top - part name (the Name), mid - portion attributes (the Attribute), the bottom - an operation portion (Operation, the method may be referred to). At the same time, the operation may have different properties and visibility, the visibility of the property described is visible to other classes, and whether other classes can be cited, and not only was visible where the attribute class.

    Attribute visibility include: public (Public), private (Private), protected (Protected).

    Visibility operations include: public (Public), private (Private), protected (Protected), the public packet (Package).

 Second, the class diagram elements - Interface

    An interface comprising operations but does not contain attributes, and it is not visible to the outside world association. A class can implement one or more interfaces, and all of them can be implemented in the operator interface. In the class diagram, inheritance is used between the interfaces inherited by the class symbol.

    Two representations interfaces, as follows:

 Third, the class diagram elements - relationship

   1. dependent (the Dependency) relationship: dependency relationship expressed between two or more semantic model elements. It represents such a situation, for an element (provider) Some changes may affect or provide information to other elements (customers), that is, customers in some way dependent on other classes yuan.

For chestnut: people rely on water

   2. Generalization (the Generalization) Relationship: generalization relationship is a relationship exists between the classification elements of the general and specific elements. Special elements compatible with the general elements, and also contain additional information. Those places are generally allowed to use elements of an instance can be used instead of specific element, but not vice-versa. Generalization relationship only in the type, rather than on an instance, as a class can inherit another class, but not inherit one object to another object.

     . A single inheritance: a sub-class has one and only one parent class

     . B Multiple inheritance: a subclass have two or more parent classes

   3. association (Association or) the relationship: describes a group having common structural features, behavior characteristics, link relationships, and semantics.

In addition to the basic form of association, there are six kinds of modifications applied to the associated, respectively name, role, multiplicity, polymerization, and combinations of navigation.

   ① Name (Name). Association may have a name that describes the nature of the relationship.

   ② role. When a class is associated with a particular end, the class will play a particular role in this relationship. In particular, the role is in a class relationship responsibilities for the performance of another class.

   ③ multiplicity (Multiplicity). Constraints are one of three UML extension mechanism, which is the multiplicity of a constraint, the constraint is the most widely used.

For chestnut:

A school can have one or more students, but students may also study in a 0 or more schools.

The following table shows some examples of multiplicity syntax:

  Modify

Semantic

0

Exactly 0

0…1

0 or 1

0…n

0 or more

1

Just 1

1…n

1 or more

n

0 or more

   ④ polymerization (Aggregation). It represents an integral part of the relationship between the association.

     University is composed of a plurality of college.

   ⑤ composition (Composition). The polymerization is a special case of the relationship, is stronger in the form of the polymerization, the polymerization is also known as strong.

     Menus and buttons can not exist independently from the window object, if the combination is destroyed, then one member objects will not continue to exist.

   ⑥ of navigation (Navigation). Can be applied in association arrow indicates the direction of navigation. In only one direction may be associated with navigable way association, a solid line with an arrow to represent; in both directions can be associated navigation bidirectional association with a solid line arrow is not represented.

   4.实现(Realization)关系:将一种模型元素与另一种模型元素连接起来,比如类和接口。

下图是我基于对机房的理解所画的类图,欢迎提出宝贵的建议。

 

 

 

 

 

 


  

 

 

发布了70 篇原创文章 · 获赞 17 · 访问量 1万+

Guess you like

Origin blog.csdn.net/hsm_Jasmine/article/details/90141823