UML class diagram describes

UML ( Unified Modeling Language ) that is the Unified Modeling Language, is the OMG ( Object Management Group ) published iconic software design language.

UML features:

Visualization: Use a chart to show the physical relationship or business relationship, can promote understanding and solve problems.

Description: the UML provides a versatile, proficient, unambiguous communication mechanism.

Built: UML by its own rules of grammar makes it possible through the use of modeling tools to map the design pattern onto a language.

Built Documentation: Using UML to design the system can generate design documents simultaneously.

UML include:

              Use case diagram ( the Use Case Diagrams )               class diagram ( Class Diagrams )               a sequence diagram ( Sequence Diagrams )

              Figure Cooperation ( Collaboration the Diagrams )       state diagram ( Statechart the Diagrams )   activity diagram ( Activity the Diagrams )

              FIG member ( the Component Diagrams )           deployment diagram ( the Deployment Diagrams )

Class ( Class ) . Package ( the Package ) . Interface ( Interface )

Common relations are: generalization relationship, to achieve the relationship, the relationship between the polymerization, the synthesis relationships and dependencies. Different relationships in different connection shown in FIG.

1 generalization relationship ( the Generalization )

In some books and materials it is also called "generalization." Generalization relationships represent inheritance relationships between classes and classes, interfaces and interface. Arrow relationship to parent class by subclasses. In Java, use extends keyword to indicate a direct relationship.

public abstract class Employee{
}

public class Programmer extends Employee{
}

2 realization ( Realization )

Examples of a contract to specify the relationship between the two entities. In other words, an entity definition of a contract, while another entity to ensure fulfillment of the contract. Relationship by arrows class implements the interface point of interface is implemented. In Java, the relationship can be achieved directly implements keyword to represent.

or

public interface CollegePerson{
}

public class Professor implements CollegePerson{
}

3 association ( Association or )

It represents the connection between class and class. It makes a class of visible properties and methods used by another class. Association may be bidirectional or unidirectional. Bidirectional arrows association is optional, or unidirectional traversal direction arrow pointing query. In Java, the use of instance variables related to implementation. Additional base may be used in the described relationship between the number of the corresponding class.

Cardinal number

meaning

0..1

Zero or one instance of

0 .. * or *

There is no limit, any

1

There is one and only one instance

1..*

At least one instance

Common base

 

 public class UserGroup{
     private UserRole uRole ;
            ......
   }

public class UserRole{
}

Example: in a user group rights, user roles, for example, a user role can belong to one or more user groups, the user group may comprise a plurality of user roles. If the user group using the following method to obtain user role permissions ...

 

Note: a relationship is often a synthetic polymeric relationship or relationship.
Note: a relationship is often a synthetic polymeric relationship or relationship.

4 polymerization ( Aggregation )

It is a polymeric form of association, global / local representative of the relationship between two classes. Implies that the entire polymerization in a conceptual level higher than the local, suggesting the association of two classes in the same level in the concept. In Java, the polymerization is accomplished using instance variables.

The difference between correlation and aggregation of purely conceptual, resolved on Java syntax does not come out. Examples of the polymerization also implies that the loop does not exist in FIG. In other words, only a one-way relationship.

 

 

public class Car{
      private Tyres tyres;
}

public class Tyres{
}

 

5 Synthesis of ( Composition )

Synthesis is a special form of aggregation, suggesting that "local" in the survival of the "whole" internal duties. Synthesis of relationship can not be shared. So, although not necessarily with the partial destruction of the whole is destroyed, but the whole or partial responsible for maintaining the survival of the state, or be responsible for their destruction. Not shared with other local overall. However, the overall ownership can be transferred to another object, which then will assume the duties of survival.

 

public class Man{
      private Legs legs;
}

public class Legs{
}

6依赖(Dependency

依赖也是类与类之间的连接,并且依赖总是单向的。实体之间一个“使用”关 系暗示一个实体的规范发生变化后,可能影响依赖于它的其他实例。更具体地说,它可转换为对不在实例作用域内的一个类或对象的任何类型的引用。其中包括一个 局部变量,对通过方法调用而获得的一个对象的引用(如下例所示),或者对一个类的静态方法的引用(同时不存在那个类的一个实例)。也可利用“依赖”来表示包和包之间的关系。由于包中含有类,所以你可根据那些包中的各个类之间的关系,表示出包和包的关系。

public class Employee{
      public void calcSalary(Calculator cSalary)
      {
      }
}

 

 

 

转载于:https://www.cnblogs.com/JoannaQ/archive/2012/09/06/2672781.html

Guess you like

Origin blog.csdn.net/weixin_33924770/article/details/93058210