UML class diagram design pattern and the relationships between classes

FIG class system is described classes and static view of the relationship between classes. It allows us to write code right before a comprehensive understanding of the system. The class diagram is a model type, specifically, is a static model type. FIG Class represent classes, interfaces and synergies between them.

The following class diagram is drawn with Visio, because the structure of teacher this semester system test report enforce the use of this software drawing.

FIG class consisting of

General Category

A class diagram consists of three parts.

  • The first part is the class name;

  • The second part is the attribute that member variable. The format 可见性 属性名称:类型[ = 缺省值]is: .
  • The third part is operating, i.e. methods. The format 可见性 方法名称(参数列表)[ : 返回类型]is: .

In [] is optional, default attribute value is an initial value, no return type constructor.

Method's parameter list, some write 参数名称:参数类型, some writing 参数类型 参数名称.

Including visibility +(public), -(Private), #(protected), `` (default).

Underlined attribute or method is static.

Abstract class

The difference between abstract classes and ordinary classes is this: abstract class names in italics, abstract methods are also in italics.

interface

Plus the interface on the class name <<interface>>.

Relations between classes

Generalization (inheritance)

Used to describe the relationship between parent and child classes, in UML generalization triangular hollow rectilinear band to represent.

achieve

Class implements interfaces in the UML, implemented with a hollow relation with dotted line.

Related

For indicating association between a class object associated with another object, usually a class object as a member variable of another class.

Association is divided into two-way association, unidirectional association.

  • Bidirectional associations

    By default, the association is bidirectional connection is represented by a solid line.

  • Way association, also referred to as direct correlation, indicated by solid lines with arrows.

  • Associated special way, there may be some of the attributes of the object type in the system class of the class itself, this special relationship called autocorrelation.

polymerization

Aggregation relationship is a special case of the relationship, which reflects a part of the whole, have (has - a) relation; in this case the whole portion is separable, they may have their life cycle, i.e. can disengaged portion overall exist independently. In UML, an aggregation relationship is represented by a straight line with a hollow rhombus. When the relationship between the code effect polymerization, generally as a structural member of the object method, business method Setter method or parameters are injected into the entire object.

combination

Is a special case combining relationship association relationship, which reflects the integral part, comprising (contains - a) relationship; relationship stronger than the polymerization, also called polymerization strong; in this case integral with are inseparable part of the overall end of life that is part of the life cycle means that those ends. In UML, diamond linear relationship with composition with solid representation.

rely

Use, a class uses another class, and this relationship is used very weak, usually just a local variable. In UML dependencies indicated by broken lines with arrows.

summary

Association is a relationship, all objects have their own life cycle, not the owner.

Polymerization is a special form of association, in which all objects have their own life cycle.

Combinations are also specialized form of aggregation, we could call relationship "death." It is a powerful aggregate type. No child object life cycle, if you delete the parent object, you will also delete all child objects.

Polymerization combination

  • The polymerization of which is associated with a combination of just more than a full relationship with the portion.
  • Aggregation is has - a relationship is the combination contains - a relationship.
  • Aggregation relationship, the whole is removed, and does not lead member deleted; may share a plurality of integral member.
  • Combining relationship overall is deleted will be deleted member; a plurality of integral non-shared components.

Strong or weak

Combinations> polymerization> related> dependent.

Guess you like

Origin www.cnblogs.com/qiu_jiaqi/p/UML.html