0% found this document useful (0 votes)
75 views88 pages

2023 Structural Models and Behavioral Model

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)
75 views88 pages

2023 Structural Models and Behavioral Model

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/ 88

The Use of Models

• Systems analysts
– use functional models
• to describe the external behavioral view of an
information system,
– use structural models
• to depict the static view of an information system,
– use behavioral models
• to represent the internal behavior or dynamic view of
an information system.

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
1
Chapter 6:
Class Diagrams

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Objectives
• Understand the rules and style guidelines for
creating CRC cards, class diagrams, and object
diagrams.
• Understand the processes used to create CRC
cards, class diagrams, and object diagrams.
• Be able to create CRC cards, class diagrams,
and object diagrams.
• Understand the relationship between the
structural and use case models.
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Structural Model
• A formal way of representing the objects that
are used and created by a business system
– People
– Places
– Things
• Drawn using an iterative process
– First drawn in a conceptual, business-centric way
– Then refined in a technology-centric way
describing the actual databases and files
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
STRUCTURAL MODELS

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Structural Models
Main goal: to discover the key data contained
in the problem domain and to build a
structural model of the objects

Structural
Modeling

Solution Domain
Problem Domain

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
A Common Language
• Structural models create a well-defined
vocabulary shared by users and analysts
– Classes created during analysis are not the classes
that programmers develop during implementation
– This refinement comes later
• Typical structural models:
– CRC cards
– Class (and Object) diagrams

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Classes, Attributes, & Operations
• Classes
•Templates for instances of people,
places, or things
• Attributes
•Properties that describe the state
of an instance of a class (an object)
• Operations
•Actions or functions that a class
can perform

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Relationships
• Describe how classes relate to one another
• Three basic types in UML
1. Generalization
Enables inheritance of attributes and operations
2. Aggregation
Relates parts to wholes
3. Association
Miscellaneous relationships between classes

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Relationships
• Generalization
– Enables inheritance of attributes and operations
– Ex:
• A CUSTOMER class and an EMPLOYEE class can be
generalized into a PERSON class by extracting the
attributes and operations in common
– It is represented with the a-kind-of relationship

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Cont..
– Generalization (bottom-up approach)
– Motivated by identifying similarities and common
features among classes
• “Part-time Instructor” derived from “Instructor” and
“Student” while modeling a department
• “User” derived from “Customer”, “Bank Manager” and
“Teller” while modeling an ATM system
• “Material” derived from “Book”, “Journal” and
“Magazine” while modeling a library catalog system

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Cont..
– We can use “specialization” (top-down approach)
• “Employee”, “ Secretary”, “Engineer”
• “ Student”, “Full-time Student”, “Part-time Student”
• “TV”, “Plasma TV”, “Flat Panel TV”

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Relationships (Cont..)
• Aggregation
– Relates parts to wholes
– A part of or has parts
• A door is a part of a car
• An employee is a-part of a department
• Association
– Miscellaneous relationships between classes
– A patient – an appointment

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
CRC CARDS

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Responsibilities & Collaborations
• Responsibilities
– Knowing
– Doing
• Collaboration
– Objects working together to service a request

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Front-Side of a CRC Card

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Back-Side of a CRC Card

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
A CRC Card
Front:

Class name: Patient ID: 3 Type: Concrete

Description:

Responsibilities: Collaborators:
Make appointment Appointment
Calculate visit

Back:

Attributes: Amount (double), Insurance carrier (text)

Relationships:

Generalization (a-kind-of): Person

Aggregation (has-parts): Medical history

Other Associations: Appointment


PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Deriving components of a class diagram from a
usecase diagram
• Actors are potential candidates for classes
– Sometimes, an actor may not be modeled as a
class
• Generalization or specialization between
actors will end up in generalization or
specialization relationship between the
corresponding classes

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
• Two actors will be related if they are
connected through a series of use cases
– The classes corresponding to these actors will thus
have an association
– The ATM example – the actor “User” is related to
“Account” because of the use cases “deposit” and
“update account”

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
CLASS DIAGRAMS

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Elements of a Class Diagram

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Attribute Visibility
• Attribute visibility can be specified in the class
diagram
– Public attributes (+) are visible to all classes
– Private attributes (-) are visible only to an instance
of the class in which they are defined
– Protected attributes (#) are like private attributes,
but are also visible to descendant classes
• Visibility helps restrict access to the attributes
and thus ensure consistency and integrity
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Operations
• Constructor
– Creates object
• Query
– Makes information about state available
• Update
– Changes values of some or all attributes

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Class diagram – basic syntax
Association Class name
Class name
name
Attributes Attributes

Methods

aggregation Component

Aggregate Class name


specialization

Class name
This is a
Attributes subclass
comments
Methods
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
More Elements of Class Diagrams

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Multiplicities
Department Boss Exactly one:
A department has one
1 1 and only one boss

Employee Child Zero or more:


An employee has zero
1 0..* to many children

Boss Employee One or more:


A boss is responsible for
1 1..* one or more employees

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
More Multiplicities
Employee Spouse Zero or one:
An employee can be
1 0..1 married to 0 or 1 spouse

Employee Vacation Specified range:


An employee can take 2
1 2..4 to 4 vacations each year

Employee Committee Multiple disjoint ranges:


An employee can be in 1
1 1..3, 5 to 3 or 5 committees

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Sample Class Diagram

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Association –syntax
Association label Direction of association
customer uses
Account
User
1 Account number
n
Manager 1 Balance
cardinality Overdraft
Get accountID ()
Role names
Update balance()
{xor} Return balance()
Unary association

Corporate Account
n with UML, 3rd Edition
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Association Class
User Account

Transaction

Employee Job

Salary

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Simplifying Class Diagrams
• Fully populated class diagrams of real-world
system can be difficult to understand
• Common ways of simplifying class diagrams:
– Show only concrete classes
– The view mechanism shows a subset of classes
– Packages show aggregations of classes (or any
elements in UML)

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Object Diagrams

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
CREATING CRC CARDS AND CLASS
DIAGRAMS
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Object Identification
• Textual analysis of use-case information
– Nouns suggest classes
– Verbs suggest operations
• Creates a rough first cut
• Common object list
• Incidents
• Roles

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Patterns
• Useful groupings of classes that recur in
various situations
• Transactions
– Transaction class
– Transaction line item class
– Item class
– Location class
– Participant class

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
7 Steps to Structural Models
1. Create CRC Cards
2. Examine common object lists
3. Role-play the CRC cards
4. Create the class diagram
5. Review the class diagram
6. Incorporate patterns
7. Review the model

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Summary
• Structural Models
• CRC Cards
• Class Diagrams
• Creating CRC Cards and Class Diagrams

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Behavioral Modeling

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Objectives
• Understand the rules and style guidelines for
sequence and communication diagrams and
behavioral state machines.
• Understand the processes used to create
sequence and communication diagrams and
behavioral state machines.
• Be able to create sequence and communication
diagrams and behavioral state machines.
• Understand the relationship between the
behavioral models and the structural and
functional models.
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Behavioral Modeling
• Behavioral models describe the internal dynamic aspects of an IS
that supports the business processes in an organization.
– During the analysis phase, behavioral models describe what the
internal logic of the processes is without specifying how the processes
are to be implemented.
– In the design and implementation phases, the detailed design of the
operations contained in the object is fully specified.
• Three UML 2.0 diagrams that are used in behavioral modeling
will be described:
– sequence diagrams, communication diagrams, behavioral state
machines.

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Behavioral Modeling
• Creating behavioral models
– an iterative process
• iterating over the individual behavioral models (e.g.,
interaction (sequence and communication) diagrams
and behavioral state machines)
• iterating over the functional and structural models.
• As the behavioral models are created, making
changes to the functional and structural
models may berequired.
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
42
BEHAVIORAL MODELS

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Key Ideas
• Behavioral models describe the internal
dynamic aspects of an information system
that supports business processes in an
organization
• Key UML behavioral models are: sequence
diagrams, collaboration diagrams, and
statechart diagrams

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Behavioral Models
• Systems have static &dynamic characteristics
– Structural models describe the static aspects of
the system
– Behavioral models describe the dynamics and
interactions of the system and its components
• Behavioral models describe how the classes
described in the structural models interact in
support of the use cases.

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
INTERACTION DIAGRAMS

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
INTERACTION DIAGRAMS

• Differences between the class diagrams and the interaction


diagrams:
• class diagrams • interaction diagrams
– describes structure – describes behavior,
– the modeling focus is at the – modeling focus is at the
class level, object level.
• Next we review objects, operations, and messages and we
cover the two different diagrams
– sequence diagrams
– communication (collaboration) diagrams
that can be used to model the interactions that take place
between the objects in an information system.

47
INTERACTION DIAGRAMS

used to describe some type of interactions among the different


elements in the model. So this interaction is a part of dynamic
behaviour of the system.
Purposes of interaction diagram:
– To capture dynamic behaviour of a system.
– To describe the message flow in the system.
– To describe structural organization of the objects.
– To describe interaction among objects.
Interaction Diagram Components

• Object
– an instantiation of a class,
• an actual person, place, event, or thing about which we want to
capture information.
– If we were building an appointment system for a doctor’s office,
classes might include doctor, patient, and appointment. The specific
patients like Jim Maloney, Mary Wilson, and Theresa Marks are
considered objects—that is, instances of the patient class.
– Each object has attributes
• describing information about the object,
– such as a patient’s name, birth date, address, and phone number.
• Each object also has behaviors.
• In the development of the evolving system, the behaviors are
described by operations.

49
• Operation
– an action that an object can perform.
– For example,
• an appointment object likely can schedule a new appointment, delete
an appointment, and locate the next available appointment.
– Each object also can send and receive messages.
• Messages
– information sent to objects to tell an object to execute one of its
behaviors.
– a message is a function or procedure call from one object to
another object.
– For example,
• if a patient is new to the doctor’s office, the system will send an
insert message to the application. The patient object will receive the
instruction (the message) and do what it needs to do to go about
inserting the new patient into the system (the behavior). 50
Interaction Diagram Components
❑Class diagrams focus on the class level
❑Interaction diagrams focus on the object level.
❑Objects
❑Operations
❑Messages

Slide 51
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Interaction Diagram Components
• Objects
an instantiation of a class
• Operations
the behaviors of an instance of a class
• Messages
information sent to objects to tell them to execute
one of their behaviors

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Sequence Diagrams
• Illustrate the objects that participate in a use-
case
• Show the messages that pass between objects
for a particular use-case

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Sequence Diagram Syntax
AN ACTOR

AN OBJECT
anObject:aClass

A LIFELINE

A FOCUS OF CONTROL

A MESSAGE
aMessage()

OBJECT DESTRUCTION x
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
SlideCopyright
54 © 2009 John Wiley & Sons, Inc. All rights reserved.
Example Sequence Diagram for the Make
Appointment Use Case

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
SlideCopyright
55 © 2009 John Wiley & Sons, Inc. All rights reserved.
❑Actors and objects are placed across the top
❑aPatient, aReceptionist, Patients, UnpaidBills,
Appointments, and an Appt
❑Not placed in any particular order
❑For each object, the name of class is given after
the object’s name
• Patients:List
– Patients is an instance of the List class that contains individual
patient objects.

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
❑A dotted line
• To show the lifeline of the actors/objects over time
• Temporary objects have X (destruction)
– Shopping cart
– Execution occurrence (to show when the classes are sending and
receiving messages)
• It shows when an object is sending or receiving messages
– Operation Call
• Solid lines connecting two objects
• The order of messages goes from top to bottom
– Return message
• Dashed line

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
❑Condition
❑It is placed in front of the message name
❑[aPatient Exists] LookupBills()
❑An object can create another object
❑The message is sent directly to an object instead
of its lifeline.

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Sequence diagram – syntax
Two different objects from the
Obj1 : ClassA same class
constructor of B
: ClassB
()
return
constructor of A () Obj2 : ClassA

message to
self
X

return
[condition] method(parameters)

return
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Steps to Build Sequence Diagrams
1. Set the context
2. Identify which objects will participate
3. Set the lifeline for each object
4. Lay out the messages from top to bottom of the
diagram based on the order in which they are sent
5. Add execution occurrence to each object‘s lifeline
6. Validate the sequence diagram

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Example: CD Selections

Normal Flow of Events:

1. Customer submits a search request to the system.


2. The system provides the customer a list of recommended CDs.
3. The customer chooses one of the CDs to find additional
information.
4. The system provides the customer with basic information &
CD Reviews
5. The customer calls the maintain order use case.
6. The customer iterates over 3 through 5 until finished shopping.
7. The customer executes the checkout use case.
8. The customer leaves the website.
61
Sequence Diagram for the Places Order Use Case

62
Communication Diagram

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
63
Communication Diagrams

• provide a view of the dynamic aspects of an OO system.


• very useful to show process patterns
– i.e., patterns of activity that occur over a set of collaborating
classes.
• A communication diagram
– an object diagram that shows message passing relationships
instead of aggregation or generalization associations.
• Communication diagrams
– emphasize the flow of messages through a set of objects
• Sequence diagrams
– focus on the time ordering of the messages being passed.

64
Communication Diagrams

• Therefore,
• if you are interested in understanding the flow of control over a
set of collaborating objects,
– you should use a communication diagram.
• if you are interested in the time ordering of the messages,
– you should use a sequence diagram.
• In some cases, you will want to use both to more fully
understand the dynamic activity of the system.

65
Communication Diagram Syntax

An Actor:
• Is a person or system that derives benefit
from and is external to the system
• Participates in a collaboration by sending
and/or receiving messages

An Object:
• Participates in a collaboration by sending
and/or receiving messages
• placed across the top of the diagram

66
Communication Diagram Syntax

An Association:
• Shows an association between actors
and/or objects
• Messages are sent over associations
A Message:
• Conveys information from one object to
another one
• Direction is shown using an arrowhead
• Sequence is shown by a sequence number
A Frame:
• Indicates the context of the
communication diagram

67
Example Communication Diagram

68
Building a Communication Diagram

1. Set the context.


• The context of the diagram
– can be
• a system,
• a use case,
• a scenario of a use case,
• an operation of a class.
– depicted as a labeled frame around the diagram
2. Identify which objects (actors) and the associations between the
objects participate in the collaboration.
• the objects that participate in the collaboration are instances of
the classes identified during the development of the structural
model.
69
Building a Communication Diagram

• Since the underlying development process is iterative and


incremental, it is likely that additional objects, and hence
classes, may be discovered.
• One useful technique to identify potential collaborations is
CRUD analysis.
– a matrix in which each interaction among objects is labeled with
a letter for the type of interaction:
• C for Create,
• R for Read or Reference,
• U for update,
• D for Delete.
• In an OO approach, a class-by-class matrix is used.
– Each cell in the matrix represents the interaction between
instances of the classes.
70
Building a Communication Diagram
• For example in the previous figure, an instance of SearchReq created an instance of
CDList.
– As such, assuming a Row:Column ordering, a “C”would be placed in the cell
SearchReq:CDList.
– Also, an instance of CD references an instance of MktInfo. In this case, an “R”would be placed
in the CD:Mkt- Info cell.
• The following figure shows the CRUD matrix based on the Place Order use case.

71
Building a Communication Diagram
• Once a CRUD matrix is completed for the entire system, the
matrix can be scanned quickly to ensure that each and every class
can be instantiated.
• Furthermore, each type of interaction can be validated for each
class.
– For example, if a class only represents temporary objects, then the
column in the matrix should have a D in it somewhere.
– Otherwise, the instances of the class will never be deleted.
3. lay out the objects (actors) and their associations on the
communication diagram
• by placing them together based on the associations that they have
with the other objects in the collaboration.
• By focusing on the associations between the objects (actors) and
minimizing the number of associations that cross over one
another, the understandability of the diagram can be increased. 72
Building a Communication Diagram
4. Add messages to the associations between the objects.
• by adding the name of the message(s) to the association link
between the objects and an arrow showing the direction of the
message being sent.
• each message has a sequence number associated with it to portray
the time-based ordering of the message
5. Validate the communication diagram.
• The purpose of this step is to guarantee that the communication
diagram faithfully portrays the underlying process(es).
• This is done by ensuring that all steps in the process are depicted on
the diagram

73
Example: CD Selections

• Communication Diagram for the Place Order Use Case

74
BEHAVIORAL STATE MACHINES

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
BEHAVIORAL STATE
MACHINES

The behavioral state machine (BSM)


– a dynamic model showing
• the different states of the object
• what events cause the object to change from one state to another, along
with its responses and actions.
Behavioral State Machines
• A dynamic model that shows the different
states through which a single object passes
during its life in response to events, along with
its responses and actions
• Typically not used for all objects
– Just for complex ones

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
BSMs

• BSMs are used to further define complex objects to help


simplify the design of algorithms for their methods.
• CRUD analysis can be used to identify complex objects.
– The more (C)reate, (U)pdate or (D)elete entries in the column
associated with a class, the more likely the instances of the class
will have a complex life cycle.
• As such, these objects are candidates for state modeling with a BSM.
• In comparison to the interaction diagrams,
– BSMs should be used
• if you are interested in understanding the dynamic aspects of a single
class and how its instances evolve over time,
• not with how a particular use case scenario is executed over a set of
classes.

78
Components of State Machines
• States
values of an object’s attributes at a point in time

• Events
change the values of the object’s attributes

• Transitions
movement of an object from one state to another

• Actions
atomic, non-decomposable processes

• Activities
non-atomic, decomposable processes

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Statechart Diagram Syntax

aState
A STATE

AN INITIAL STATE

A FINAL STATE

AN EVENT anEvent

A TRANSITION
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
SlideCopyright
80 © 2009 John Wiley & Sons, Inc. All rights reserved.
Example Statechart Diagram

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
SlideCopyright
81 © 2009 John Wiley & Sons, Inc. All rights reserved.
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
SlideCopyright
82 © 2009 John Wiley & Sons, Inc. All rights reserved.
Steps to Build a State Machine
1. Set the context
2. Identify the initial, final, and stable states of
the object
3. Determine the order in which the object will
pass through the stable states
4. Identify the events, actions, and guard
conditions associated with the transitions
5. Validate the behavioral state machine
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
CRUD ANALYSIS

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
CRUD Analysis
❑A technique for identifying potential
collaboration
❑It is a class-by-class matrix
• Labels object interaction in 4 possible ways
– Create
– Read
– Update
– Delete

Slide 85
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
CRUD Analysis
• Matrix representation of objects and
interactions
• Most useful as a system-wide representation
▪ Temporary objects have a D in the matrix

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Sample CRUD Matrix

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.
Summary
• Behavioral Models
• Interaction Diagrams
• Behavioral State Machines
• CRUD Analysis

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright © 2009 John Wiley & Sons, Inc. All rights reserved.

You might also like