0% found this document useful (0 votes)
68 views34 pages

CSC2073 - Lecture 36 (Software Design Practice)

The document discusses sequence diagrams and their notation. It provides details on: 1) Sequence diagrams show the interactions between objects over time by arranging object lifelines in a vertical time sequence. Messages are shown as arrows between the lifelines. 2) The notation includes boxes for objects, solid lines for messages, and dotted lines for object lifelines. Syntax for naming objects and including instance names is also defined. 3) Message types can be synchronous, asynchronous, create, or destroy. Synchronous messages block and asynchronous messages do not. Create and destroy messages instantiate or delete objects. The document uses examples and diagrams to demonstrate sequence diagram notation and how they can be used to model dynamic object

Uploaded by

Rana Ali Akbar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views34 pages

CSC2073 - Lecture 36 (Software Design Practice)

The document discusses sequence diagrams and their notation. It provides details on: 1) Sequence diagrams show the interactions between objects over time by arranging object lifelines in a vertical time sequence. Messages are shown as arrows between the lifelines. 2) The notation includes boxes for objects, solid lines for messages, and dotted lines for object lifelines. Syntax for naming objects and including instance names is also defined. 3) Message types can be synchronous, asynchronous, create, or destroy. Synchronous messages block and asynchronous messages do not. Create and destroy messages instantiate or delete objects. The document uses examples and diagrams to demonstrate sequence diagram notation and how they can be used to model dynamic object

Uploaded by

Rana Ali Akbar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 34

Software Engineering

Fundamentals
CSC-2073
Lecture No. 36
Dr. Muhammad Adeel
Department of Computer Science
National Textile University

[email protected]
Last Lecture Review

 Abbot’s Textual Analysis


 Interaction Diagrams

2 Software Engineering - CSC2073


Mechanisms for Dynamic Behavior

1) Sequence Diagrams: Provide a time-based


view

2) Collaboration Diagrams: Provide an


organization-based view of the system’s
dynamics

3 Software Engineering - CSC2073


The Sequence Diagram

 Illustrate how objects interacts with each


other and emphasize time ordering of
messages by showing object interactions
arranged in time sequence

 These can be used to model simple


sequential flow, branching, iteration, recursion
and concurrency

4 Software Engineering - CSC2073


The Sequence Diagram

 The focus of sequence diagrams is on objects


(and classes) and message exchanges
among them to carry out the scenarios
functionality

 The objects are organized in a horizontal line


and the events in a vertical time line

5 Software Engineering - CSC2073


Sequence Diagram - The Notation

 The boxes denote objects (or classes)

 The solid lines depict messages being sent


from one object to the other

 The dotted lines are called life-lines of objects


‒ The life line represents the object’s life during
interaction

6 Software Engineering - CSC2073


Sequence Diagram - The Notation

 The syntax used for naming objects in a


sequence diagram is as follows:
Syntax:[instanceName]:[ClassName]
 Name classes consistently with your class
diagram (same classes)

 Include instance names when objects are


referred to in messages or when several
objects of the same type exist in the diagram

7 Software Engineering - CSC2073


Sequence Diagram - The Notation

 If object obj1 sends a message to another


object obj2 an association must exist between
those two objects

 A message is represented by an arrow


between the life lines of two objects

 Self calls are also allowed. These are the


messages that an object sends to itself

 The time required by the receiver object to


8 Software Engineering - CSC2073
Sequence Diagram - The Notation

 If object obj1 sends a message to another


object obj2 an association must exist between
those two objects

 A message is represented by an arrow


between the life lines of two objects

 Self calls are also allowed. These are the


messages that an object sends to itself

 The time required by the receiver object to


9 Software Engineering - CSC2073
Sequence Diagram - The Notation
Object
Message
Role :Interface
:CoffeeCustomer

insertCoin()

Activation-box
Life line
machineReady() of object
Time
pressButton(b1)

pourCoffee()

10 Software Engineering - CSC2073


Sequence Diagram - The Notation
X-axis (objects)
Object
Message
Role :Interface
:CoffeeCustomer

insertCoin()

Activation-box
Life line
machineReady() of object
Time
pressButton(b1)

pourCoffee()

Y-axis (time)
11 Software Engineering - CSC2073
Sequence Diagram - Message Types

 Synchronous

 Asynchronous

<<create>>
 Create

<<destroy>>
 Destroy

12 Software Engineering - CSC2073


Synchronous Messages

 Synchronous messages are “call events”

 Denoted by the full arrow

 They represent nested flow of control which is


typically implemented as an operation call

 The caller waits for the called routine to


complete its operation before moving forward
13 Software Engineering - CSC2073
Synchronous Messages

:object1 :object2
Caller Blocked

areYouOK( ) Return

yes

14 Software Engineering - CSC2073


Asynchronous Messages

 Asynchronous messages are “signals”

 They are denoted by a half arrow

 They do not block the caller

 Occurs in multi-threaded or multiprocessing


applications where different execution threads
may pass information to one another by
sending asynchronous messages to each
other
15 Software Engineering - CSC2073
Asynchronous Messages

 Asynchronous messages typically perform the


following actions:
‒ Create a new thread
‒ Create a new object
‒ Communicate with a thread that is already
running

16 Software Engineering - CSC2073


Object Creation & Destruction

 An object may create another object via a


<<create>> message

 An object may destroy another object via a


<<destroy>> message

 An object may also destroy itself

 Should be use only when memory


management is critical
17 Software Engineering - CSC2073
Object Creation & Destruction

courseForm CurManage aCourse


:Registrar
:CourseForm :CurriculmManager :Course

1:setCourseInfo

2: process

3: addCourse

4: <create>>

18 Software Engineering - CSC2073


Object Creation & Destruction

:object1 :object2

<<destroy>>

19 Software Engineering - CSC2073


Practice Task - Statement

 Draw a class diagram representing a book


defined by the following statement: “A book is
composed of a number of parts, which in turn
are composed of a number of chapters ,
which in turn are composed of a number of
Sections.

20 Software Engineering - CSC2073


Practice Task - Statement

 Draw a class diagram representing a book


defined by the following statement: “A book is
composed of a number of parts, which in turn
are composed of a number of chapters ,
which in turn are composed of a number of
Sections.

21 Software Engineering - CSC2073


Practice Task - Solution

Book Parts

Chapters Sections

22 Software Engineering - CSC2073


Agenda – What will you Learn Today?

Software Design Practice

23 Software Engineering - CSC2073


Software Design Practice

24 Software Engineering - CSC2073


Practice Task 1 - Statement

 “Consider the world of libraries. A library has


books, videos, and CDs that it loans to its
users. All library material has an ID and a title.
In addition, books have one or more authors,
videos have one producer and one or more
actors, while CDs have one or more
entertainers.”

25 Software Engineering - CSC2073


Practice Task 1 - Statement

 “Consider the world of libraries. A library has


books, videos, and CDs that it loans to its
users. All library material has an ID and a title.
In addition, books have one or more authors,
videos have one producer and one or more
actors, while CDs have one or more
entertainers.”

26 Software Engineering - CSC2073


Practice Task 1 - Statement

 “Consider the world of libraries. A library has


books, videos, and CDs that it loans to its
users. All library material has an ID and a title.
In addition, books have one or more authors,
videos have one producer and one or more
actors, while CDs have one or more
entertainers.”

27 Software Engineering - CSC2073


Practice Task 1 - Statement

LibraryItem Person
- id - name
- title

1..* author
1..* entertainer
1 producer
Book Video CD

1..* actor
0..* 0..* 0..*

28 Software Engineering - CSC2073


Practice Task 2 - Statement

 A hockey league is made up of at least four hockey


teams. Each hockey team is composed of six to
twelve players, and one player captains the team.
A team has a name and a record. Players have a
number and a position. Hockey teams play games
against each other. Each game has a score and a
location. Teams are sometimes lead by a coach. A
coach has a level of accreditation and a number of
years of experience, and can coach multiple
teams. Coaches and players are people, and
people have names and addresses.

29 Software Engineering - CSC2073


Practice Task 2 - Statement

 A hockey league is made up of at least four hockey


teams. Each hockey team is composed of six to
twelve players, and one player captains the team.
A team has a name and a record. Players have a
number and a position. Hockey teams play games
against each other. Each game has a score and a
location. Teams are sometimes lead by a coach. A
coach has a level of accreditation and a number of
years of experience, and can coach multiple
teams. Coaches and players are people, and
people have names and addresses.

30 Software Engineering - CSC2073


Practice Task 2 - Solution
Person
name
address

Game Coach Player


Score Level Number
location Experience position

League Team Captain


name
record

31 Software Engineering - CSC2073


Practice Task 2 - Solution
Person
name
address

Game Coach Player


Score Level Number
location Experience position

* 0..1 6..12
1
1 2 *
4..*
League Team Captain
name 1 1
record

32 Software Engineering - CSC2073


Recap

 Software Design Practice

33 Software Engineering - CSC2073


Questions

34 Software Engineering - CSC2073

You might also like