1/15
Object-Oriented Software Engineering
Prof. Moheb Ramzy Girgis
Department of Computer Science Faculty of Science
Minia University
(3) Introduction to the UML
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
Introduction to the UML
The Unified Modeling Language (UML) is a
language for specifying, visualizing, constructing, and documenting the artifacts of software
systems, as well as for business modeling and other non-software systems.
The UML enables OO system builders to create blueprints that capture their visions in a standard, easy-to-understand way and communicate them to others.
The UML provides a standard design notation that
is accepted by analysts, developers, and clients.
2/15
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
The Components of the UML
The UML consists of a number of graphical elements that combine to form diagrams
The purpose of the diagrams is to present multiple views of a system, and this set of multiple views is called a model .
A UML model describes what a system is supposed to do. It doesn't tell how to
implement the system.
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
Most common diagrams of the UML
Class Diagram
Object Diagram
Use Case Diagram
State Diagram
Sequence Diagram
Activity Diagram
Collaboration Diagram
Component Diagram
Deployment Diagram
Some Other UML Features
• Packages
• Notes
• Stereotypes
3/15
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
Class Diagram
A class diagram is static model that shows the classes and relationships among classes that remain constant in the system over time.
The class icon:
name attributes operations
A class diagram consists of a number of these icons connected by lines that
show how the classes relate to one another.
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
Class Diagram for Manage Appointment
4/15
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
Class Diagram Syntax
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
Multiplicity
5/15
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
Aggregation and Generalization Associations
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
Object Diagram
An object diagram shows the objects and their relationships with one another.
The object icon:
object name : Class name
6/15
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
Use Case Diagram
A use case is a collection of scenarios of system use.
Every use case is initiated by an entity, called an actor , which can be a person or another system.
The use case is a valuable tool for gathering system requirements from a user's point of view.
Actor Use case
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
Use Case Diagram for Appointment
System
7/15
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
Syntax for Use-Case Diagram
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
Use Case Diagram for Hospital Management System
The <<include>>
relationship indicates that the use case at the arrow head is always called when the use case at the arrow tail is executed.
The <<extend>>
relationship indicates that
the use case at the arrow
head is optional. Note that
the use case at the arrow
tail is able to execute on its
own even if the extending
use case is not called.
8/15
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
State Diagram
At any time, an object is in a particular state.
The state of an object is defined by the value of its properties and its relationships with other objects at a particular point in time.
For example, a patient might have a state of new, current or former.
A state diagram is a dynamic model showing changes of state of a single object over time in response to events along with its responses and actions.
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
State Diagram for a Hospital Patient
9/15
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
Syntax for State Diagram
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
Sequence Diagram
In a functioning system, objects interact with one another, and these interactions occur overtime.
The UML sequence diagram shows the time- based dynamics of the interaction.
It visualizes how the objects in a system
interact with one another overtime.
10/15
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
Sequence Diagram Example
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
Syntax for Sequence Diagram
11/15
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
Collaboration Diagram
The UML collaboration diagram is another way of visualizing how objects work together over time.
Objects may be anywhere in the diagram.
Messages from one object to another appear as lines connecting the objects.
Each line is numbered according to its placement in the sequence of messages and shows information that pertains to the nature of the message.
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
A Collaboration Diagram Example
A client initiates the interaction sequence by inserting his/her card, and messages occur in the sequence represented by the collaboration diagram.
2: Verify PIN 1: Insert card 6. Enter amount to deposite 9. Enter amount to withdraw
:ATM
:Client
4: Eject card 5. Request amount 12. Close transaction
:Controller : Database
7: Deposite amount 8. Update account 10. Withdraw if balance is sufficient
3: Invalid PIN 11: Inform client if
balance is insufficient
12/15
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
Activity Diagram
The UML activity diagram shows the steps and decision points that occur within the behavior of an object, or within a business process.
The state diagram shows the states of an object and represents activities as arrows connecting the states.
The activity diagram highlights the activities
Each step is a rounded rectangle and each decision point is a diamond.
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
An activity diagram for the “creating and
printing a document”
activity
[tables not needed]
[tables needed]
[graphics not needed]
[graphics needed]
print(file) print(file)
:Printer Open Word Processing Package
Create File
Save the File Type the Document
Open and Use Graphics Package
Open and Use Spreadsheet Save File
Print Hardcopy
Exit Office Suite
13/15
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
Syntax for Activity Diagram
print(file) print(file) [graphics needed]
:Printer
Step Transition Decision point Condition Sending a signal Receiving a signal
Transition between sending and receiving a signal steps Object
The start point The end point
Symbol Purpose
Save the File
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
Some Other UML Features
The UML provides more features that enable us to organize and extend the diagrams.
Packages
Sometimes we need to organize the elements of a diagram into a group.
For example, in order to show that a number of classes or components are part of a
particular subsystem, we group them into a
package , represented by a tabbed folder.
14/15
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
Notes
The UML note is helpful when a part of a diagram requires some explanation.
It is represented by a rectangle with a folded corner, and explanatory text inside it.
The note is attached to a diagram element by connecting a dotted line from the element to the note.
Package 1
Class 1
Class 2 Class 3
A UML package
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University
Stereotypes
Sometimes, the designer of a system may need some tailor-made items.
Stereotypes enable us to take existing UML elements and turn them into new ones.
A stereotype is represented as a name enclosed in two pairs of angle brackets («»), called
guillemets.
Class 1
Some explanatory text about class1
A UML note
15/15
OO Software Engineering- Prof. Moheb Ramzy Girgis Dept. of Computer Science - Faculty of Science
Minia University