UML Diagram

Jun 29, 2026

Tags: uml
Categories: tutorial

Table of Contents

Unified Modeling Language (UML) diagram is a standardized visual diagram used to design and document the structure and behavior of complex software systems. Here is YouTube video that talks about the diagram usage. There are many different types of diagram, and here I keep a record of them for my personal usage.

UML Diagrams in Org-Mode

One of the ways to create a UML diagram in Org-Mode is to use PlantUML , a simple language used for writing UML diagrams.

To use PlantUML, first install the language. On Fedora, do

1sudo dnf install plantuml

Now set up the emacs config file to set the path to the plantuml.jar file. You can find where that is via

1rpm -ql plantuml | grep -i jar

Now in the emacs config file, put

1;; Set the path. Put whatever the previous command gives
2(setq org-plantuml-jar-path "/usr/share/java/plantuml.jar")
3
4;; Loads the language plantuml language
5(org-babel-do-load-languages
6 'org-babel-load-languages
7 '((plantuml . t)))

Now we can run plantuml code in the org src code block.

1#+begin_src plantuml :file class_diagram.png
2class User {
3- String username
4- String password
5+ login()
6+ logout()
7}
8#+end_src

Now we can evalaute the src block via C-c C-c.


Class Diagram

A UML diagram gives you a visual relation between different classes. See this YouTube video for more detail.

A basic class object in the class diagram looks like:

Each class have different attributes, 2nd row, and different methods, 3rd row, which ends with (). Now both attribute or method can have different levels of visibility.

  1. - private
  2. # protected
  3. + public
  4. ~ package/default

Now all we need to do is to connect different classes together to create our diagram. There are different types of relation between different classes. Let’s describe the common types:

RelationshipArrow TypeDescription
InheritanceHollow TriangleOne class is the subclass of another
AssociationStraight LineWeakly related with each other
AggregationHollow DiamondThe part can exist independently of the whole
CompositionFulfilled DiamondThe part CANNOT exist withou the whole

Inheritance

If a class is a subclass of another class – inheritance. Then we should connect the two via a hollow triangular arrow pointing from the child class to the parent class. Here is an example

Association

If a class is only weakly associated with another class, we can simply draw a line between them. This can be used to indicate that class A uses class B is some way. This is typically when class B is not directly stored in class A, but class A uses class B as some argument in one of the methods. To expand upon the previous example, we can say Customer buys Product.

Aggregation

Aggregation is when a class (A) can exist independently of the whole (B). This is denoted by a hollow diamond shape where the diamond is connected from class A to class B. This likely when class B is stored as part of the attribute, and it is created as an argument during initialization. So that class B was already created. We can again expand upon the previous example, where we introduce a new class called ShoppingCart. Now ShoppingCart can contain 0 to many Product, but Product itself can live perfectly fine without ShoppingCart. This is called an aggregation.

Composition

Lastly, we have composition. This relation is similar to aggregation. However, in this case the part (A) CANNOT exist without the whole (B). This is denoted by a solid diamond shape. This is when class A directly calls class B and stores it as an attribute or somehow uses it inside class A. From the previous example, consider an Order object. This depends on the Customer. But without Customer there won’t be any Order. This is then a composition.