1 Basic introduction to UML

  1. UML (Unified Modeling Language) is a language tool for software system analysis and design. It is used to help software developers think and document the results of ideas.
  2. UML itself is a set of notation, like mathematical notation and chemical notation, that describes the elements of a software model and their relationships, such as classes, interfaces, implementations, generalizations, dependencies, compositions, aggregations, and so on.

2 a UML diagram

Drawing UML diagram is similar to writing an article, both are to describe their own ideas to others, the key lies in thinking and organization, UML diagram classification:

  1. Use Case Diagrams.
  2. Static structure diagram: class diagram, object diagram, package diagram, component diagram, deployment diagram.
  3. Dynamic behavior diagram: interaction diagram (sequence diagram and collaboration diagram), state diagram, activity diagram.

Description:

  1. Class diagrams, which describe the relationships between classes, are at the core of UML diagrams.
  2. When we talk about design patterns, we inevitably use class diagrams.

3 the UML class diagram

  1. Used to describe the composition of the classes (objects) themselves and the various static relationships between the classes (objects) in the system.
  2. Relationships between classes: dependencies, generalizations (inheritance), implementations, associations, aggregations, and compositions.
  3. Class diagram for a simple example
Public class Person{// private Integer id; private String name; public void setName(String name){ this.name=name; } public String getName(){ return name; }}

4 Kinds of Graphs — Dependencies

As long as the other person is used in the class, there is a dependency between them. Without the other side, we couldn’t even get through the programming.

public class PersonServiceBean { private PersonDao personDao; } public void save(Person Person){} public void modify(){Department;} public void modify(){Department department = new Department(); } } public class PersonDao{} public class IDCard{} public class Person{} public class Department{}

1) The class uses each other; 2) If it is a member attribute of the class; 3) If it is the return type of the method; 4) is the type of parameter received by the method; 5) method.

Generalization relation of five types of graphs

Generalization relation is actually inheritance relation, which is a special case of dependency relation

public abstract class DaoSupport{ 
    public void save(Object entity){}
    public void delete(Object id){} 
}
public class PersonServiceBean extends Daosupport{}

Summary: 1) Generalization relation is actually inheritance relation; 2) If class A inherits class B, we say that there is A generalization relationship between A and B.

6 types of diagrams — Implementation relations

Implementing relationships are essentially class A implementing interfaces B, which is A special case of dependencies

public interface PersonService { 
    public void delete(Interger id);
}
public class PersonServiceBean implements PersonService { 
    public void delete(Interger id){}
}

Class 7 Diagrams – Association (Association)

Association relationship is the relationship between classes, which is a special case of dependency relationship. Associations are navigational: that is, bi-directional or unidirectional.

Eight types of diagrams – Aggregation

Introduction: Aggregation represents the relationship between the whole and parts, which can be separated. Aggregation relation is a special case of association relation, so it has the navigability and multiplicity of association (who aggregates who). For example, a computer is composed of keyboard, monitor, mouse and so on. The parts that make up the computer can be separated from the computer and are represented by solid lines with hollow diamonds.

9 Types of Diagrams — Composition

Combinatorial relation: it is also the relation between the whole and the parts, but the whole and the parts cannot be separated. Let’s take another example: in the program we define entities: Person and IDCard, Head, then Head and Person are combination, IDCard and Person is aggregate.

However, if a cascading deletion of IDCard is defined in the Person entity in the program, that is, when the Person is deleted along with the IDCard, then the IDCard and Person are combined.