Contents
Introduction to uml design and tools
   Jun 19, 2022     3 min read

Introduction: The design of UML is significant for software developer. The UML not only give you and your partner straightforward big picture of your project, but also save a lot of time in coding. Unified Modelling Language is a standard way to visualize the design of a system. And it’s also very helpful for learning design pattern. There are mainly two type of UML diagram: structural UML diagram and Behavioral UML diagram.

Structural UML diagrams:

  • Class diagram
  • Package diagram
  • Object diagram
  • Component diagram
  • Composite structure diagram
  • Deployment diagram
  • Behavioral UML diagrams

Behavioral UML diagrams:

  • Activity diagram
  • Sequence diagram
  • Use case diagram
  • State diagram
  • Communication diagram
  • Interaction overview diagram
  • Timing diagram

The article will introduce the design of class UML diagram and tools to design all kinds of UML.

Class diagram A class diagram represent the types of objects in your system and their relationship.

There are three groups of key elements that make up class diagram: classifiers, features and relationship.

  • Classifiers: It consists of class, interface and abstract class and so on. A classifier is identified as a box with three parts represent classiferiers name, field and methods respectively.
  • Features: Features usually means field and methods in object-oriented concept.
  • Relationship: Relationships show how these entities are related.

Tools recommand: PlantUML is an opne-source tool allowing users to create diagrams from a plain text language. I recomand using PalntUML in VSCode extension or online editor

Classifier

There are six type of classifiers:

Although PlantUML only support class, abstract class ,interface and enumeration, it almost enough to stand for other situation.

Features

In class diagram, a classifier contains property(field) and methods. Syntax for attributes:

visibility attribute-name: type multiplicity = default-value {property-modifier}
Example:
+ studentId: string [1]{id, readonly}

Visibility table: visibility table

Multiplicity It indicates how many instances of values will this attribute hold:

zero or more: *

one or more: 1..*

exactly one: 1

between m and n: m..n

Methods notation

visibility method-name (parameter-list): return-type {property-modifier}
Example:
+attendSession(event: EventClass):void

Relationship

There are mainly 5 relationship in class diagram.

  • Association is a ‘using’ relationship between two or more objects. In Association, all object has their separate lifecycle, and there is no owner. Example: A doctor can be associated with multiple patients. At the same time, one patient can visit multiple doctors.
  • Generalization: Generalization is the process of implement interface or abstract class.
  • Aggregation is a “has a” relationship between two class. Where “has a”, means has an object of the other class.
  • Composition is also a “has a” relationship between two class which can’t be use individually.Compostion relationship is a subset of aggregation relationship.

Example:

public class motherboard{
	private CPU cpu;
}
public class CPU{
	private int amtOfCores;
	private String brand;
}

  • Inheritance is a “is a” relationship.For example, Teacher class is subclass of Person class, so you can say “teacher is person”.

Here is cheatsheet for UML class diagram. There are some misspeeling in this picture.

Finally, if you would like to design UML using code, you need to try PlantUML.