0% found this document useful (0 votes)
9 views9 pages

COM 213 Lecture Note

This lecture note is on Unified Modeling Language and it is used for students in Computer Science
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views9 pages

COM 213 Lecture Note

This lecture note is on Unified Modeling Language and it is used for students in Computer Science
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CHAPTER 1

UML (UNIFIED MODELING LANGUAGE)


UML stands for Unified Modeling Language. It is a standardized language used in software engineering to
draw blueprints (visualize, specify, construct and document) for software. Just as an architect uses blueprints
to design a house before building it, software developers and business teams use UML diagrams to design a
software system before writing the code.
UML is not a programming language itself, but rather a graphical notation that provides a common visual
language, so everyone on a project—from the programmers to the project managers and clients—can
understand how the system is supposed to work.
UML diagrams come in many types, each with a different purpose. Some diagrams show the structure of the
system (like a Class Diagram, which shows the different parts of the code), while others show the behavior
(like a Sequence Diagram, which shows how those parts interact over time).

1.1 Key Purposes of UML


1. Communication: UML provides a common visual language for all people involved in a project, regardless
of their technical background. It bridges the gap between different teams and ensures everyone is on the
same page about the system's design.
2. Clarification: The process of creating UML diagrams forces designers to think through the details and
complexities of a system, which helps identify ambiguities, inconsistencies, and potential problems early
in the development lifecycle.
3. Analysis and Design: UML diagrams are used to analyze requirements and design a system's architecture
before writing code. This helps to create a robust and well-structured application from the start.
4. Documentation: A complete set of UML diagrams serves as living documentation of the system's
architecture and design, which is invaluable for new team members and for future maintenance and
updates.

1.2 Types of UML Diagram Tools


Here's a breakdown of the types of tools you can use to draw UML diagrams:
1. Web-Based & Online Tools
These are great for accessibility, collaboration, and simple diagrams. They are often a good starting point and
many offer free tiers.
 Lucidchart: A very popular and user-friendly online diagramming tool. It supports all major UML diagram
types, offers real-time collaboration, and integrates with platforms like Confluence and Jira.
 [Link] (also known as [Link]): A free and open-source diagramming application that runs in your
web browser. It's excellent for creating a wide range of diagrams, including UML, and is very flexible.
 Miro: A popular online whiteboard tool that has a dedicated set of features for creating UML diagrams,
including templates and symbols. It's particularly strong for team collaboration and brainstorming.
 Visual Paradigm Online: An online platform that offers a comprehensive set of diagramming tools,
including full support for UML. It provides features for team collaboration and a user-friendly interface.
 Canva: While known for graphic design, Canva also has templates and tools for creating various diagrams,
including UML. It's a great option if you need to create visually appealing and simple diagrams for
presentations or reports.

2. Desktop Software Tools


These applications are typically more powerful and offer advanced features like code generation, reverse
engineering, and project management capabilities. They are often used for large-scale, enterprise-level
projects.
 Microsoft Visio: A long-standing, powerful diagramming tool from Microsoft. It has a large library of
shapes and templates, including specific support for UML. It integrates well with other Microsoft Office
products.
 StarUML: A popular, cross-platform (Windows, macOS, Linux) desktop application specifically for creating
UML diagrams. It is known for its clean interface and support for UML 2.x standards. It has a free version
with some limitations.
 Enterprise Architect: A comprehensive and powerful modeling tool from Sparx Systems. It is widely used
in enterprise environments and supports not only UML but also other modeling languages like BPMN and
SysML. It's a professional-grade tool with a strong focus on project management and requirements
traceability.
 Astah: A lightweight, easy-to-use, and highly regarded UML modeling tool. It is known for its simplicity
and efficiency, making it a favorite among developers who want a powerful tool without a steep learning
curve.
 Visual Paradigm: A robust and feature-rich desktop application that offers a complete suite of modeling
tools for software development, including advanced UML capabilities.
 Wondershare EdrawMax: This is a very capable and popular application specifically designed for creating
a wide variety of diagrams, including all types of UML diagrams.

3. Text-Based Tools
These tools allow you to generate UML diagrams from a simple text or code-based syntax. They are a favorite
among developers and those who want to keep diagrams under version control alongside their code.
 PlantUML: A very popular open-source tool that generates a wide range of UML diagrams from a plain
text language. You describe the diagram in a simple syntax, and it generates the image. This is a great way
to embed diagrams in documentation and collaborate via source control.
 Mermaid: A JavaScript-based diagramming tool that also uses a simple text syntax to generate diagrams.
It's widely integrated into platforms like GitHub, GitLab, and many markdown editors, making it easy to
create and share diagrams directly in your documentation.
 [Link]: A web-based tool that uses keyboard commands and a text syntax to generate diagrams quickly.
It is designed for speed and is a good option for developers who prefer a code-first approach.

1.3 Types of UML Diagrams


UML is not just one type of diagram; it is a family of diagrams categorized into two main groups:
1. Structural Diagrams: These diagrams show the static structure of a system and its components. They are
like a system's skeleton.

 Class Diagram: The most common type, which you mentioned, showing classes, attributes, and
methods, and their relationships.
 Component Diagram: Shows how different software components are wired together to form a larger
system.
 Deployment Diagram: Illustrates the physical hardware and software on which the system runs.
 Object Diagram: Shows specific instances of classes at a particular moment in time.

2. Behavioral Diagrams: These diagrams show the dynamic behavior of a system and the flow of control and
data.
 Use Case Diagram: Describes how users (actors) interact with the system and what functions the
system performs.
 Sequence Diagram: Shows the step-by-step interactions between objects in a time-ordered sequence.
 Activity Diagram: Similar to a flowchart, it shows the flow of control from activity to activity.
 State Machine Diagram: Models the behavior of an object as it transitions through different states in
response to events.

CHAPTER 2
CLASS DIAGRAM
A UML (Unified Modeling Language) Class Diagram is a static structure diagram that describes the structure
of a system by showing the system's classes, their attributes, methods, and the relationships among them.

Classname ----- CLASSNAME


visibility attributeName: attributeType ----- ATTRIBUTES
visibility methodName(parameterList): returnType ----- METHODS
2.1 ClassName
The class name is the unique identifier of the class. It is always placed in the top compartment of the class
rectangle and is written in TitleCase (e.g., Student, Car, Order).

2.2 Attributes
An attribute represents a data value held by each object of the class. It is listed in the second compartment of
the class rectangle.
The standard notation is: visibility attributeName: attributeType
 Visibility: This indicates the accessibility of a class member (attribute or method) to other classes. It is
denoted by a symbol placed before the member's name.

Symbol Visibility Description


The member is visible to and accessible by all
+ Public
other classes.
The member is only visible and accessible within
- Private its own class. This is the default for attributes to
support encapsulation.
The member is visible to its own class and its
subclasses (derived classes).
This is about inheritance. It gives access to the
# Protected class itself and any class that inherits from it
(subclass). It doesn't matter if the subclass is in
the same package or a different one. The key is
the "relationship".
The member is visible only within the same
package.
This is about location. It gives access to the class
~ Package/Default itself and all other classes that are physically
located within the same package. It doesn't
matter if the other class is a subclass or not. The
key is being in the same "folder."

 attributeName: The name of the attribute, typically written in camelCase (e.g., name, age, modelYear).

 attributeType: The data type of the attribute (e.g., String, int, boolean, Date).

Example: [+ name: String], [- age: int], [# registrationDate: Date]

2.3 Methods
A method represents the behavior or operations that an object of the class can perform. It is listed in the
bottom compartment of the class rectangle.
The standard notation is: visibility methodName(parameterList): returnType
 methodName: The name of the method, typically in camelCase (e.g., getName, calculateArea).

 parameterList: A list of input parameters the method accepts, with their data types (e.g., [width: double,
height: double]). If a method has no parameters, the parentheses are empty ().

 returnType: The data type of the value the method returns. If the method does not return a value (a void
method), the return type is often omitted or specified as void.

Example: [+ getAge(): int], [- calculateSalary(base: double, bonus: double): double], [+ setAddress(newAddress:


String): void]
Now let’s put everything together into a class diagram;

Dog
- Color: String
- Height: int
- Length: int
- Weight: double
- Age: int
+ getColor(): String
+setColor(): void
+getLength(): int
+setLength(): void
+getAge(): int
+setAge(): void

2.4 Relationships
Relationships define how classes interact with each other. The most common relationships are:

2.4.1 Association
Represents a structural relationship where objects of one class are connected to objects of another.
Notation: A solid line between the classes.

 Multiplicity: Indicates how many objects of one class are linked to objects of another class. It's shown
as a number or a range near the end of the line.
1: One to One
1...*: One to Many
*...*: Many to Many
Student * Teaches 1
Tutor
1 Learns from *

One to One
1

One to Many
1…*

Many to Many
*

 Navigability: An arrow on the association line indicates the direction of the relationship. A single
arrow means the relationship is one-way (unidirectional). No arrow means it's two-way (bidirectional).

Unidirectional

ClassA ClassB
- myB
+ doSomething() + actionB()

Bidirectional

ClassA ClassB
+ myA - myB
+ doSomething() + actionB()

Example: Student --- * --- Course (A student can be associated with multiple courses, and a course can have
multiple students.)
2.4.2 Inheritance (Generalization/Specialization)
These represents an "is-a" relationship, where one class (the subclass or child) inherits attributes and methods
from another class (the superclass or parent).
Notation: A solid line with a hollow arrowhead pointing from the subclass to the superclass.

Shape

Square Rectangle Circle

Example: A Car is a Vehicle. Vehicle is the superclass, and Car is the subclass.

2.4.3 Aggregation
A special form of association that represents a "whole-part" relationship. It denotes a relationship where one
class (the whole) contains another class (the part). In this kind of relationship, the child can exit independently
of its parent class.
Notation: A solid line with a hollow diamond on the side of the "whole" class.

Office Workspace

Table Chair Fan


Example: A Department has Employees. The employees can exist even if the department is disbanded.

2.4.4 Composition
This is a stronger form of aggregation, representing a "has-a" relationship where the parts cannot exist
without the whole. If the whole is destroyed, the parts are also destroyed.
Notation: A solid line with a filled diamond on the side of the "whole" class.

Human Body

Kidney Liver Brain

Example: A Car has Engine. If the car is destroyed, the engine is also considered part of that destroyed unit.

2.4.5 Dependency
This represents a "uses-a" relationship, where one class uses another class. It's a temporary or transient
relationship. A change in one class may affect the other.
Notation: A dashed line with an open arrowhead pointing from the dependent class to the class it uses.

Person Book
+ hasReadBook(): boolean

Example: A Student class might have a printTranscript() method that creates and uses an object of a Printer
class. The Student is dependent on Printer.
2.4.6 Realization
This indicates that a class implements the features of an interface. It is often used in cases where class realizes
the operations defined by an interface.
Notation: A dashed line with an open arrowhead pointing from the implementing class to the interface.

<<Interface>>
Owner
+ buy(property)
+ sell(property)

Person Corporation
- current
- real
- fixed
- tangible
- longTerm
- intangible
- intangible

Example: A Printer class realizing a Printable interface.

You might also like