UNDERSTANDING UML DIAGRAMS BY IMPLEMENTING A MESSAGING APPLICATION
Tags: programming, softwaredevelopment, computerscience, softwareengineering
Published: 2024-04-22 21:58:11

_“System modeling is the process of developing abstract models of a system, with each model presenting a different view or perspective of that system. System modelling now usually means representing a system using some form of graphical notation based on diagram types in the Unified Modelling Language (UML).”_ – Software Engineering (Somerville, 2015)

System modelling is a valuable practice in software engineering because it provides a structured approach to plan effectively and to improve development efficiency and productivity. 

In this article, a comprehensive overview of the design for a secure and user-friendly messaging application tailored specifically for businesses, is provided. This innovative app aims to streamline internal communication, fostering collaboration and boosting overall productivity.

Imagine a platform where employees can seamlessly:

**Connect Instantly:** Send and receive messages, images, videos, and other multimedia content for clear and efficient communication.

**Stay Informed:** Never miss a beat with real-time notifications for new messages and critical events.

**Organize Conversations:** Effortlessly manage your communication with features like message search and customizable profiles.

**Enhance Security:** Enjoy peace of mind knowing your messages are protected with robust security measures.

This article details the application's design using a type of system model known as a Unified Modelling Language (UML) diagram, to illustrate the functionalities and underlying structure. The UML diagrams to be discussed here are the Use case and class diagrams.

## What is UML?

In simple terms, a Unified Modelling Language (UML) is a visual modelling language used in Software Engineering, as a means to provide a standard way to visualize the design of a system. The UML can be basically divided into three main groups: 

- **Structure models** - This describes the structure of the data that is processed by the system.

- **Behavior models** - This portrays the dynamic behaviour of the system and how it responds to events.

- **Interaction models** - This illustrates the interactions between a system and its environment.

Class diagrams and Use case diagrams are grouped under Structure models and interaction models, respectively. 
While Class diagrams are used when developing an object-oriented system model, in order to show the classes in a system and the associations between these classes, Use case diagrams are simple descriptions of what a user expects from a system.

We will be visualizing the workings of a “Simple Messaging Application” using a Use case diagram and a Class diagram.

## Use case Diagram

![Use case diagram of a Messaging Application](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uiyeon05ogxbwg65x3ck.png)

The Use case diagram describes how users interact with a system. In this system (Messaging App), the primary actors – New User and Existing User, interacts directly with the Messaging App. Their roles are further explained below: 

**Existing User:** Represents employees within the company who have already created an account and can access the full functionalities of the application.
**New User:** Represents new employees who need to register for an account before utilizing the app's features.

The secondary actor – Notification Service, provides services or sends notifications for different usage scenarios, the primary actors may encounter while using the App.

From the diagram above, we can see that various functionalities (use cases) are depicted. Some of these functionalities are creating accounts, logging into an account, sending and receiving messages, and even managing contacts. 

## Class Diagram

![Class diagram of a Messaging Application](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gd042uqwlpf8s972gfh1.png)

The diagram above, describes the classes in the system, their attributes and their methods. Each class, has its own unique functionality encapsulated within it. 

The Class Diagram focuses on the core functionalities of the application and the classes that represent them. These classes include:

**Account class:** This class Manages user accounts (creation, login, profile management)

**Message class:** This class represents sent and received messages.

**Message History class:** This class stores the history of messages exchanged between users.

**Notification class:** This class Handles sending notifications to users about new messages or events.

**Media content class:** This class handles media contents like videos, pictures and audio messages.

Classes are also related with each other by specifying different relationships. 

In a **one to many** relationship, one class can be associated with multiple classes of another type. This is the most common type of relationship. 

In a **many to many** relationship, multiple classes can be associated with multiple classes of another type. 

Lastly, in a **one to one** relationship, one class can only be associated with another class. 

By utilizing both the use case and class diagrams, a comprehensive understanding of your system’s functionality and structure is gained. While they serve different purposes, they work together to provide a better design and development.

## References
[1]. Wikipedia.[2024] Wikipedia [Online]. Available at:
https://en.wikipedia.org/wiki/Unified_Modeling_Language

[2]. Ian Somerville, E.(2015). Software Engineering. Pearson.