0% found this document useful (0 votes)
17 views62 pages

OOSD Unit2

Uploaded by

ayushsingh.bui
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)
17 views62 pages

OOSD Unit2

Uploaded by

ayushsingh.bui
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
You are on page 1/ 62

UNIT 2

BASIC
STRUCTURAL
MODELLING
UML Diagrams
• Types of UML Diagrams:
Use Case Diagram
Class Diagram
Sequence Diagram
Collaboration Diagram
State Diagram
Activity Diagram
Introduction
• Use case diagrams
– Describe the functional behavior of the system as seen by the
user
• Class diagrams
– Describe the static structure of the system: Objects, attributes,
associations
• Sequence diagrams
– Describe the dynamic behavior between objects of the system
• State-chart diagrams
– Describe the dynamic behavior of an individual object
• Activity diagrams
– Describe the dynamic behavior of a system, i.e. The
Workflow.
Use-Case Diagrams
• A use-case diagram is a set of use cases
• A use case is a model of the interaction
between
 External users of a software product (actors) and
 The software product itself
 More precisely, an actor is a user playing a specific role

• describing a set of user scenarios


• capturing user requirements
• contract between end user and software
developers
Use-Case Diagrams
• Actors: A role that a user plays with
respect to the system, including human users
and other systems. e.g., inanimate physical
objects (e.g. robot); an external system that
needs some information from the current
system.
• Use case: A set of scenarios that describing
an interaction between a user and a system,
including alternatives.
• System boundary: rectangle diagram
representing the boundary between the
actors and the system.
Class diagram
• A class diagram depicts classes and their
interrelationships
• Used for describing structure and behavior in the
use cases
• Provide a conceptual model of the system in terms
of entities and their relationships
• Used for requirement capture, end-user interaction
• Detailed class diagrams are used for developers
• Depict the detailed design of object-oriented or
object-based software
Class Diagram
• Each class is represented by a rectangle subdivided
into three compartments
• Name
• Attributes
• Operations

• Modifiers are used to indicate visibility of attributes and


operations.
• ‘+’ is used to denote Public visibility (everyone)
• ‘#’ is used to denote Protected visibility (friends and
derived)
• ‘-’ is used to denote Private visibility (no one)
• By default, attributes are hidden and operations are
visible.
Class Diagram
OO Relationship
 There are two kinds of Relationships
 Generalization (parent-child relationship)
 Association (student enrolls in course)

 Associations can be further classified as


 Aggregation
 Composition
OO Relationships: Generalization

• Inheritance is a required feature of object orientation


• -Generalization expresses a parent/child
relationship among related classes.
- Used for abstracting details in several layers
OO Relationships: Association

 Represent relationship between instances


of classes
 Student enrolls in a course
 Courses have students
 Courses have exams
 Etc.
 Association has two ends
 Role names (e.g. enrolls)
 Multiplicity (e.g. One course can have many students)
 Navigability (unidirectional, bidirectional)
Aggregation vs. Composition
 Composition is really a strong form of
association
 components have only one owner
 components cannot exist independent of their owner
 components live or die with their owner
 e.g. Each car has an engine that can not be shared with other cars.

 Aggregations
– may form "part of" the association, but may not be essential to it.
They may also exist independent of the aggregate. e.g. Apples may
exist independent of the bag.
Interaction Diagrams
• show how objects interact with one another

• UML supports two types of interaction diagrams


 Sequence diagrams
 Collaboration diagrams
Sequence Diagram(make a phone call)

Caller Phone Recipient

Picks up

Dial tone

Dial

Ring notification Ring

Picks up

Hello
Sequence Diagram:Object interaction
A B
Self-Call: A message that an
Object sends to itself. Synchronous

Condition: indicates when a


Asynchronous
message is sent. The message is
sent only if the condition is true. Transmission
delayed

[condition] remove()
Condition
*[for each] remove()
Iteration

Self-Call
Sequence Diagrams – Object Life
Spans
• Creation A
 Create message
 Object life starts at that point Create
B
• Activation
 Symbolized by rectangular stripes
 Place on the lifeline where object is
activated.
 Rectangle also denotes when object
is deactivated. Activation bar X
Return
• Deletion Deletion
 Placing an ‘X’ on lifeline
Lifeline
 Object’s life ends at that point
Sequence Diagram
Message
•Sequence diagrams demonstrate User Catalog Reservations
the behavior of objects in a use case
by describing the objects and the
1: look up ()
messages they pass.
2: title data ()

3: [not available] reserve title ()


•The horizontal dimension shows the
objects participating in the interaction. 4 : title returned ()

5: hold title ()

•The vertical arrangement of 5 : title available ()


messages indicates their order.
6 : borrow title ()

6 : remove reservation ()
•The labels may contain the seq. # to
indicate concurrency.
What is a Collaboration Diagram

• Collaboration diagrams illustrate interactions


between objects
• The collaboration diagram illustrates messages
being sent between classes and objects (instances).
• Collaboration diagrams express both the context
of a group of objects (through objects and links)
and the interaction between these objects (by
representing message broadcasts)
Purpose of the Collaboration
Diagram
• They are very useful for visualizing the
relationship between objects collaborating to
perform a particular task
• They provide a good view – albeit static - view
of interaction between objects which may be
difficult to see at the class level
Collaboration Diagram
• Represents a Collaboration and Interaction
• Collaborationset of objects and their
interactions in a specific context
• Interactionset of messages exchanged in a
collaboration to produce a desired result
Components
• Objects
• Actor
• Links
• Messages

• Also known as Communication Diagrams


Ex. Collaboration Diagram
Sequence Diagram VS Collaboration
Actor System Diagram
:ClassA :ClassB
System Op
SystemOp
Operation:xxx message1()
+
Precondition:..

Sequence Contract
Diagram Collaboration
Diagram
Activity diagrams
• Useful to specify software or hardware system behaviour
• Based on data flow models – a graphical representation (with a
Directed Graph) of how data move around an information
system

[order reject]

Receive Fill Ship Close


Order Order Order Order
[order
accepted]

Send Accept
Invoice Make Payment
Invoice Payment
40
Some definitions
• Flow: permits the interaction between two nodes of the activity
diagram (represented by edges in activity diagram)
• State: a condition or situation in the life of an object during which it
satisfies some conditions, performs some activities, or waits for
some events
• Type: specifies a domain of objects together with the operations
applicable to the objects (also none); includes primitive built-in
types (such as integer and string) and enumeration types
• Token: contains an object, datum, or locus of control, and is present
in the activity diagram at a particular node; each token is distinct
from any other, even if it contains the same value as another
• Value: an element of a type domain

41
State Diagrams
State Diagrams show the sequences of states an object
goes through during its life cycle in response to stimuli,
together with its responses and actions; an abstraction
of all possible behaviors.

Start End
Unpaid Paid
Invoice created paying Invoice destroying
Time Diagram
• show interactions between primary with time
• focus on conditions changing within and
among lifelines
• describe behavior of individual classifiers and
interactions of classifiers,
• focusing attention on time of events
Component Diagram
• used to break down a large object-oriented
system into the smaller components
• models the physical view of a system such as
executables, files, libraries, etc.
• visualizes the relationships as well as the
organization between the components present
in the system
• A component is a single unit of the system,
which is replaceable and executable
component diagram for an online
shopping system
Deployment Diagram
• shows the execution architecture of a system
• visualize the physical hardware and software
of a system
• model the hardware topology of a system
(logical components of a system)

You might also like