UML Class Diagram Learning

Source: Internet
Author: User
Tags dashed line

!!! Excerpt from: http://www.cnblogs.com/silent2012/archive/2011/09/07/2169946.html

Several structure http://www.open-open.com/lib/view/open1328059700311.html in class diagram

1. What is a class diagram

Class diagram are mainly used to describe the structural design of a system. Class diagrams are also the most commonly used UML diagrams, with class diagrams showing classes, interfaces, and the static structure and relationships between them.

2. Elements of a class diagram

The following model elements are included in the class diagram: Class, Interface (Interface), dependency (Dependency) relationship, generalization (generalization) Relationship, Association (association) relationship, Aggregation relationships (Aggregation), composition relationships (composition), and implementation (realization) relationships.

Category 2.1 (Class)

In object-oriented (OO) programming, a class is an abstraction of a group of objects with the same characteristics in the real world.

2.2 Interface (Interface)

An interface is a special class that has the structure of a class but cannot be instantiated and can only be implemented (inherited). In UML, an interface is represented using a small circle with a name.

2.3 Dependency (Dependency) relationship

A dependency is a dependency between two or more classes, such as a plant class that relies on a soil class. Dependencies can also be subdivided into 5 types, which are bound (binding) dependencies, implementation (realization) dependencies, usage dependency, abstraction (abstraction) dependency, and Authorization (Permission) dependencies.

A dependency is represented by a dashed arrow that points to a dependent direction.

2.4 Generalization (generalization) relationship

Simply speaking, it is the inheritance relationship between classes. In UML, the generalization relationship is represented by a hollow triangle + solid line, and the arrow points to the parent class.

2.5 Aggregation (Association) relationship

An aggregation relationship is a weaker coupling between classes, such as a string array and a string that is an aggregation relationship. In UML class diagrams, aggregation relationships are represented by hollow Diamond + solid arrows, and arrows point to classes that are aggregated.

  

2.6 combination (Aggregation) relationship

A combinatorial relationship is a relationship between a whole and a part of a class, such as a frog with four legs, and a relationship between a frog and a frog's leg class. In a UML class diagram, a composite relationship is represented by a solid diamond + solid arrowhead, and the arrow points to the grouped class.

2.7 Association (composition) relationship

Association relationship is a kind of relationship between classes, the direction of influence is the direction of association. In a UML class diagram, a composite relationship is represented by a solid arrow.

2.8 Implementation (REALIZATION) relationship

In general, the implementation relationship is for the relationship between the class and the interface. In UML class diagrams, the implementation relationship is represented by a hollow triangle + dashed line.

3. Simple example of class diagram

Generalization  =  Implement > Combination > Aggregation > Associate > Dependent

The following UML diagram shows the various class diagram relationships in a more vivid way:

UML Class Diagram Learning

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.