You are on page 1of 23

6/29/20

INTRODUCTION TO SOFTWARE ENGINEERING


6. UNIFIED MODELING LANGUAGE

Outline
w Use-case diagrams
w Activity diagrams
w Sequence diagrams
w Class diagrams

1
6/29/20

How Would You Read This Diagram?


View Report Card

Course Catalog
Maintain Professor
Register for Courses Information

Student

Login Maintain Student


Information

Registrar

Select Courses to
Teach Close Registration

Professor

Submit Grades

Billing System

Relationships in use cases


w Between actor and use case
§ Actor uses
w Generalisation of actors
§ Types of users
w Use case stereotypes
§ <<extend>>
• Optional
§ <<include>>
• Mandatory
w Stereotypeis a UML extension mechanism to indicate a
type of behaviour

2
6/29/20

Use case variants: include and extend


w include relationship occurs when you have a chunk of behavior that is
similar across more than one Use Case
§ use in two or more separate Use Cases to avoid repetition
§ a significant part of a use case
§ <<include>>
w extend relationship where you have one Use Case which adds
functionality to another Use Case
§ any Use Case can have more than one extend
§ use when describing a variation on or in addition to normal behavior
§ OPTIONAL BEHAVIOUR
• Otherwise part of use case or
• <<include>>
§ <<extend>>

Example of Use Case Variants


additional
functionality

Place order <<extend>>


Open account Extension Point Place back order
Place back order

<<include>> <<include>>
<<include>>

Supply
Arrange delivery
Customer Data

shared functionality

3
6/29/20

Exercise 1 – Use Case Diagram


w Draw a use case diagram for the space invader game
below:

http://www.neav
e.com/games/in
vaders/

Exercise 1 Solution

Move Left

Move Right

Fire Laser
Player
View High Scores

Play Game

4
6/29/20

Exercise 2
Consider Sonic the
hedgehog.
1. What can sonic do?
2. What are the use
cases?
3. Are there any
relationships
4. Draw the use case
diagram

1. Move left
2. Move right
3. Jump
4. Jump left
5. Jump right
6. Spin Dash
7. Pause
http://www.ebaumsworld.com/games/play/1108/

Exercise 2 – Possible Solution

Sonic the hedgehog


Move Left

Move Right
<<extend>>
Player Jump Left
Jump <<extend>>

Spin Dash Jump Right

Pause Game

10

5
6/29/20

Outline
w Use-case diagrams
w Activity diagrams
w Sequence diagrams
w Class diagrams

11

Student Enrollment

System

IIT
Enrollment
Student Registrar
<<include>>

Course registration

12

6
6/29/20

SEIIT System
w Here different activities are:
§ Received enrollment form filled by the student
• Registrar checks the form
• Input data to the system
• System authenticate the environment
§ Pay fees by the student
• Registrar checks the amount to be remitted and prepare a bill
• System acknowledge fee receipts and print receipt
§ Hostel allotment
• Allot hostel
• Receive hostel charge
• Allot room
§ Medical check up
• Create hostel record
• Conduct medical bill
• Enter record
§ Issue library card
§ Issue identity card

13

Activity Diagram for the Use Case


Received form

Hostel
Payment fees Medical check
allotment

Issue identity Issue library


card card

14

7
6/29/20

Basic Components in an Activity Diagram


w Initial node
§ The filled circle is the starting point of
the diagram
Received form
w Final node
§ The filled circle with a boarder is the
ending point. An activity diagram can
have zero or more activity final state. Hostel
Payment fees Medical check
allotment
w Activity
§ The rounded circle represents activities
that occur. An activity is not necessarily
a program, it may be a manual thing Issue identity Issue library
also card card

w Flow/ edge
§ The arrows in the diagram. No label is
necessary

15

Basic Components in an Activity Diagram


Received form
w Fork
§ A black bar ( horizontal/vertical ) with
one flow going into it and several
leaving it. This denotes the beginning of Payment fees
Hostel
allotment
Medical check

parallel activities
w Join
§ A block bar with several flows entering Issue identity Issue library
card card
it and one leaving it. this denotes the
end of parallel activities
w Merge
§ A diamond with several flows entering
and one leaving. The implication is that
all incoming flow to reach this point
until processing continues

16

8
6/29/20

Basic Components in an Activity Diagram


w Difference between Join and Merge

§ A join is different from a merge in that the join synchronizes two inflows
and produces a single outflow. The outflow from a join cannot execute
until all inflows have been received

§ A merge passes any control flows straight through it. If two or more
inflows are received by a merge symbol, the action pointed to by its
outflow is executed two or more times

17

Basic Components in an Activity Diagram


w Decision
§ A diamond with one flow entering
and several leaving. The flow
leaving includes conditions as yes/
no state
w Flow final
§ The circle with X though it. This
indicates that Process stop at this
point
w Swim lane Received form

§ A partition in activity diagram by Payment fees


Hostel
Medical check

means of dashed line, called swim


allotment

lane. This swim lane may be Issue identity


card
Issue library
card

horizontal or vertical

18

9
6/29/20

Detailed Activity Diagram of SEIIT

1
Received form

Hostel
Payment fees Medical check
allotment

2
Issue identity Issue library
card card

19

Detailed Activity Diagram of SEIIT


Fill-in Check
form form

[Incorrect]
Regret message
[Correct]

Display student [Not Found]


screen
Verify the [Found]

Input student applications


information
Create record 1
Search for Student [Match]
selection list [No Match]

Regret
registration

20

10
6/29/20

Detailed Activity Diagram of SEIIT

Display Calculate
1 enrollment form registration fees

Dispaly fees
payable screen
Process
payment
Pay fee 2
Print receipt

21

Activity Diagram of SEIIT with Swim Lane


Student

Fill-in
form
Verify the [Found]

[Incorrect]
applications
[Not Found]

Check
Regret message
Registrar

form
[Correct]

Display student
screen

Create record
System

Input student
information
[Match]
1
Search for Student
selection list [No Match]

Regret
registration

22

11
6/29/20

What Is a Sequence Diagram?


• A sequence diagram is an interaction diagram that
emphasizes the time ordering of messages.
• The diagram shows:
• The objects participating in the interaction.
• The sequence of messages exchanged.

Sequence Diagram

23

Example: Sequence Diagram

: Student :RegisterForCoursesForm :RegistrationController :CourseCatalogSystem : Course Catalog

1: create schedule( )
2: get course offerings( )
3: get course offerings(forSemester)
4: get course offerings( )

5: display course offerings( )

6: display blank schedule( )

ref
Select Offerings

24

12
6/29/20

Sequence Diagram Contents: Objects


:RegisterForCoursesForm :RegistrationController SWTSU Catalog :
CourseCatalogSystem

Anonymous Objects Named Object

Lifelines

25

Sequence Diagram Contents: Actor


:RegisterForCoursesForm :RegistrationController SWTSU Catalog :
CourseCatalogSystem
: Student : Course Catalog

Actor instances

26

13
6/29/20

Sequence Diagram Contents: Messages


:RegisterForCoursesForm :RegistrationController SWTSU Catalog :
CourseCatalogSystem
: Student : Course Catalog

1: create schedule( )

2: get course offerings( )


3: get course offerings(for Semester)

4: get course offerings( )

5: display course offerings( )

6: display blank schedule( )


Message
Reflexive
Messages

27

Sequence Diagram Contents: Execution Occurrence

:RegisterForCoursesForm :RegistrationController SWTSU Catalog :


CourseCatalogSystem
: Student : Course Catalog

1: create schedule( )

2: get course offerings( )

3: get course offerings(for Semester)

4: get course offerings( )


5: display course offerings( )

6: display blank schedule( )

Execution
Occurrence

28

14
6/29/20

Sequence Diagram Contents: Event Occurrence

:RegisterForCoursesForm :RegistrationController SWTSU Catalog :


CourseCatalogSystem
: Student : Course Catalog

1: create schedule( )

2: get course offerings( )

3: get course offerings(for Semester)

4: get course offerings( )


5: display course offerings( )

6: display blank schedule( )

Event Occurrence

29

Sequence Diagram Contents: Interaction Occurrence


:RegisterForCoursesForm :RegistrationController SWTSU Catalog :
CourseCatalogSystem
: Student : Course Catalog

1: create schedule( )

2: get course offerings( )

3: get course offerings(for Semester)

4: get course offerings( )


5: display course offerings( ) Interaction
Occurrence
6: display blank schedule( )

ref
Select Offerings

30

15
6/29/20

Outline
w Use-case diagrams
w Activity diagrams
w Sequence diagrams
w Class diagrams

31

What Is a Class Diagram?


• Static view of a system

CloseRegistrationForm Schedule CloseRegistrationController


- semester
+ open() + is registration open?()
+ close registration() + commit() + close registration()
+ select alternate()
+ remove offering()
+ level() Professor
+ cancel() - name
Student + get cost() - employeeID : UniqueId
+ delete() - hireDate
+ submit() - status
+ get tuition()
+ save() - discipline
+ add schedule()
+ any conflicts?() - maxLoad
+ get schedule()
+ create with offerings()
+ delete schedule()
+ update with new selections() + submitFinalGrade()
+ has pre-requisites()
+ acceptCourseOffering()
+ setMaxLoad()
+ takeSabbatical()
+ teachClass()

32

16
6/29/20

Class Diagram Usage


• When modeling the static view of a system, class
diagrams are typically used in one of three ways, to
model:
• The vocabulary of a system
• Collaborations
• A logical database schema

33

Example: Class Diagram


• Is there a better way to organize class diagrams?
LoginForm RegistrationController
RegisterForCoursesForm

Schedule
CloseRegistrationForm CloseRegistrationController

Professor
Student
Course CourseOffering

CourseCatalogSystem
BillingSystem

34

17
6/29/20

35
E.g. Class diagram for UC “Register for course”
<<interface>>
RegistrationController ICourseCatalogSystem
0..* 1
+ // submit schedule () + courseCatalog + getCourseOfferings ( [in] forSemester : Semester) : CourseOfferingList
+ // save schedule ()
+ // create schedule with offerings ()
+ // get course offerings () 0..1
Schedule
0..1
- semester : Semester
0..1
+ submit ()
+ currentSchedule + //save ()
# any conflicts? ()
0..1 + registrant 1 0..* + //create with offerings()

0..* 0..*
Student
alternateCourses + primaryCourses
- name 0..2 0..4
- address
- StudentID : int
CourseOffering
+ addSchedule ( [in] aSchedule : Schedule )
+ getSchedule ( [in] forSemester : Semester ) : Schedule - number : String = "100"
+ hasPrerequisites ( [in] forCourseOffering : CourseOffering ) : boolean - startTime : Time
# passed ( [in] aCourseOffering : CourseOffering ) : boolean - endTime : Time
- day : String
+ addStudent ( [in] aStudentSchedule : Schedule)
+ removeStudent ( [in] aStudentSchedule : Schedule)
+ new ()
+ setData ()
PartTimeStudent FullTimeStudent
+ maxNumCourses + gradDate

35

Review: What Is a Package?


• A general purpose mechanism for organizing elements
into groups.
• A model element that can contain other model elements.
• A package can be used:
• To organize the model under development
• As a unit of configuration management

University
Artifacts

36

18
6/29/20

Example: Registration Package

Registration

CloseRegistrationForm CloseRegistrationController

RegisterForCoursesForm RegistrationController

37

What Is an Association?
• The semantic relationship between two or more classifiers
that specifies connections among their instances.
• A structural relationship specifying that objects of one thing
are connected to objects of another thing.

Student Schedule Course

38

19
6/29/20

What Is Multiplicity?
• Multiplicity is the number of instances one class
relates to ONE instance of another class.
• For each association, there are two multiplicity
decisions to make, one for each end of the
association.
• For each instance of Professor, many Course Offerings
may be taught.
• For each instance of Course Offering, there may be either
one or zero Professor as the instructor.
instructor
Professor CourseOffering
0..1 0..*

39

Multiplicity Indicators

Unspecified
Exactly One 1

Zero or More 0..*

Zero or More *

One or More 1..*

Zero or One (optional value) 0..1

Specified Range 2..4

Multiple, Disjoint Ranges 2, 4..6

40

20
6/29/20

Example: Multiplicity

1
RegisterForCoursesForm RegistrationController
1

0..1

0..1

1 0..*
Student Schedule CourseOffering
0..* 0..4

41

What Is an Aggregation?
• A special form of association that models a whole-part
relationship between the aggregate (the whole) and its
parts.
• An aggregation is an “is a part-of” relationship.
• Multiplicity is represented like other associations.

Whole 1 Part

0..1

42

21
6/29/20

Example: Aggregation
1
RegisterForCoursesForm RegistrationController
1

0..1

0..1

1 0..*
Student Schedule CourseOffering
0..* 0..4

43

Review: What Is Generalization?


• A relationship among classes where one class shares the
structure and/or behavior of one or more classes.
• Defines a hierarchy of abstractions where a subclass
inherits from one or more superclasses.
• Single inheritance
• Multiple inheritance
• Is an “is a kind of” relationship.

44

22
6/29/20

Example: Single Inheritance


• One class inherits from another.
Ancestor
Account
- balance
Superclass - name
(parent) - number

+ withdraw()
+ createStatement()

Generalization
Relationship

Subclasses
Savings Checking
(children)

Descendents

45

Example: Multiple Inheritance


• A class can inherit from several other classes.

FlyingThing Animal

Multiple Inheritance

Airplane Helicopter Bird Wolf Horse

Use multiple inheritance only when needed and


always with caution!

46

23

You might also like