You are on page 1of 38

MODULE:VI

OBJECT ORIENTED DESIGN & UML


DIAGRAMS

Object-Oriented Concepts
Object-oriented (OO) design techniques
are becoming popular:
Inception in early 1980s and nearing maturity.
Widespread acceptance in industry and academics.
Unified Modeling Language (UML) already an
ISO standard for modeling OO systems.

12/17/15

MODULE-VI OOSD& UML

UML

A model is required to capture only important


aspects
UML a graphical modeling tool
Easy to understand and construct
Helps in managing complexity

12/17/15

MODULE-VI OOSD& UML

UML

Nine diagrams are used to capture different


views of a system.
Provide different perspectives of a software
system.
Diagrams can be refined to get the actual
implementation of a system.

12/17/15

MODULE-VI OOSD& UML

UML

Views of a system:
Users view
Structural view
Behavioral view
Implementation view
Environmental view

12/17/15

MODULE-VI OOSD& UML

UML DIAGRAMS

12/17/15

MODULE-VI OOSD& UML

Use Case Model

Consists of set of use cases


An important analysis and design artifact
The central model
Other models must confirm to this model
Not really an object-oriented model
Represents a functional or process model

12/17/15

MODULE-VI OOSD& UML

USE CASE
Different ways in which a system can be used
by the users
Corresponds to the high-level requirements
Represents transaction between the user and
the system
Defines external behavior without revealing
internal structure of system

12/17/15

MODULE-VI OOSD& UML

USE CASE

Represented by use case diagram


A use case is represented by an ellipse
System boundary is represented by a
rectangle
Users are represented by stick person
icons (actor)
Communication relationship between
actor and use case by a line
External system by a stereotype

12/17/15

MODULE-VI OOSD& UML

USE CASE MODELS

12/17/15

MODULE-VI OOSD& UML

10

USE CASE MODELS

12/17/15

MODULE-VI OOSD& UML

11

IDENTIFY THE ACTORS

12/17/15

MODULE-VI OOSD& UML

12

A Case
Study
:
LAS
Library
uses

Borrow books
extends

Checking Library Card


uses

Inter library loan


Circulation Clerk

Return Books

Member

Performing research
Reading books
Newspaper

Supplier

Purchasing Supplies
12/17/15

MODULE-VI OOSD& UML

13

Naming a Use Case

Use case name should provide a general


description of the use case function.
The name should provide what happens when
an instance of the use case is performed.
Jacobson recommend that the name should be
active, often expressed in the form of a
verb(Borrow) or verb & noun (Borrow books).

12/17/15

MODULE-VI OOSD& UML

14

Uses and Extends

12/17/15

MODULE-VI OOSD& UML

15

Identifying Actors
Actors can be found through following ques:
Who is using the system or affected by it ?
Who (or which group) affects the system ?
Which external hardware or other system(if
any) use the system to perform tasks ?
What problems does this application solve ?
(i.e for whom ?)
Finally, how do users use the system (use
case) ? What are they doing with the system.
12/17/15

MODULE-VI OOSD& UML

16

Class Diagram
Describes static structure of a system
Main constituents are classes and their
relationships:
Generalization
Aggregation
Association
Various kinds of dependencies
12/17/15

MODULE-VI OOSD& UML

17

Class Diagram
Entities with common features, i.e. attributes
and operations
Classes are represented as solid outline
rectangle with compartments
Compartments for name, attributes, and
operations.
Attribute and operation compartments are
optional depending on the purpose of a diagram.

12/17/15

MODULE-VI OOSD& UML

18

Example of Class Diagram

12/17/15

MODULE-VI OOSD& UML

19

Association Relationship
Enables objects to communicate with each
other
A class can be associated with itself (recursive
association)
An arrowhead used along with name, indicates
direction of association

12/17/15

MODULE-VI OOSD& UML

20

Association Relationship

12/17/15

MODULE-VI OOSD& UML

21

Aggregation Relationship
Represents whole-part relationship
Represented by a diamond symbol at the
composite end
-Cannot be reflexive(i.e. recursive)
-Not symmetric
-It can be transitive

12/17/15

MODULE-VI OOSD& UML

22

Aggregation Relationship

12/17/15

MODULE-VI OOSD& UML

23

Generalization and
Specializations

12/17/15

MODULE-VI OOSD& UML

24

Interaction Diagram

Models how groups of objects collaborate to realize


some behavior.
Typically each interaction diagram realizes behavior
of a single use case

12/17/15

MODULE-VI OOSD& UML

25

Interaction Diagram
Two kinds: Sequence and Collaboration diagrams.
Two diagrams are equivalent
Portray different perspectives
These diagrams play a very important role in the
design process.

12/17/15

MODULE-VI OOSD& UML

26

Sequence Diagram
Shows interaction among objects as a two
dimensional chart
Objects are shown as boxes at top
If object created during execution then shown
at appropriate place
Objects existence are shown as dashed
lines (lifeline)
Objects activeness, shown as a rectangle on
lifeline

12/17/15

MODULE-VI OOSD& UML

27

Sequence Diagram
Messages are shown as arrows
Each message labeled with corresponding
message name
Each message can be labeled with some
control information
Two types of control information

12/17/15

condition ([ ])
iteration (*)
MODULE-VI OOSD& UML

28

Example of Sequence Diagram

12/17/15

MODULE-VI OOSD& UML

29

Collaboration Diagram
Shows both structural and behavioral aspects
Objects are collaborator, shown as boxes
Messages between objects shown as a solid line
A message is shown as a labeled arrow placed
near the link
Messages are prefixed with sequence numbers to
show relative sequencing

12/17/15

MODULE-VI OOSD& UML

30

Example : Collaboration Diagram

12/17/15

MODULE-VI OOSD& UML

31

Activity Diagram
Not present in earlier modeling techniques, possibly
based on event diagram of Odell [1992]
Represents processing activity, may not correspond
to methods
Activity is a state with an internal action and
one/many outgoing transitions
Somewhat related to flowcharts
12/17/15

MODULE-VI OOSD& UML

32

Activity Diagram vs Flow Chart


Can represent parallel activity and synchronization
aspects
Swim lanes can be used to group activities based on
who is performing them
Example: academic department vs. hostel

12/17/15

MODULE-VI OOSD& UML

33

Activity Diagram
Normally employed in business process modeling.
Carried out during requirements analysis and
specification stage.
Can be used to develop interaction diagrams.

12/17/15

MODULE-VI OOSD& UML

34

Activity Diagram

12/17/15

MODULE-VI OOSD& UML

35

State Chart Diagram


Based on the work of David Harel [1990]
Model how the state of an object changes in its
lifetime
Based on finite state machine (FSM)
formalism

12/17/15

MODULE-VI OOSD& UML

36

State Chart Diagram

Elements of state chart diagram


Initial State: A filled circle
Final State: A filled circle inside a larger circle
State: Rectangle with rounded corners
Transitions: Arrow between states, also boolean
logic condition (guard)

12/17/15

MODULE-VI OOSD& UML

37

Example: State Chart Diagram

12/17/15

MODULE-VI OOSD& UML

38