Com 213 Note1
Com 213 Note1
COM 213
Introduction to UML
Unified Modeling Language
• UML is an object-oriented modeling language (or more
precisely, a collection of modeling languages) that is
• expressive
• semi-formal (UML 2.0 added much more formality)
• capable of supporting incremental development
• Elements can be hidden
• Certain elements can be left incomplete
• Inconsistencies can exist
• process independent
• UML can be used with a variety software development process
models
• Customizable and extensible
A Brief Timeline for OO and UML
• 60’s
• Birth of initial OO ideas
• 70’s
• Nurturing of OO ideas
• Introduction of a few more OO Programming Languages
• 80’s
• Maturing of fundamental OO concepts
• Emergence of more OOPL’s
• OOPL’s gain widespread use
A Brief Timeline for OO and UML
▪ 90’s
• The Method Wars Booch, Jacobson, Rumbaugh
• Efforts to unify concepts
• Introduction and standardization of UML
• Emergence of next-generation ideas, like Patterns
• Current
• Widespread use of UML
• Widespread use Full-Life-Cycle development tools
UML Building Blocks
• Modeling Elements
• Structural Student
• Behavioral major: String
• Organizational gpa: Real
standing: String
• Annotational Contacts
add(Course)
• Diagrams that drop(Course)
communicate ideas -- Handle a registration in
StudentS
name: String
major: String
GPA: real
standing: Scode
add(Course)
drop(Course)
-- Software representation of students;
support registration in courses
Implementation Perspective
StudentDialogBox Student
major: String
create()
GPA: Real
doDataExchange()
standing: String
onDelete()
onInsert() add(Course)
onOK() drop(Course)
-- Interact with user to add -- Handle a registration in
drop courses courses
0..1
1
Course
callNumber: Integer
CourseList department
number
-- Display a dynamic list section
courses title
Implementation Perspective
• Classes can represent software
Object components in frameworks,
libraries, or external systems
Frame
Window
Dialog ListBox
0..1 1
StudentDialogBox CourseList
18
Analysis Phase: What is it?
Three objectives:
• To describe what the customer requires
• To establish a basis for the creation of a software design
• To define a set of requirements that can be validated once the
software is built
19
Analysis Modeling Approaches
• Structural analysis:
• The data: The model defines their attributes and relationships.
• The processes that transform the data: The model shows how they
transform the data objects as they flow through the system.
• Object-oriented analysis:
• Focus: Classes and their inter-relationships
• UML is predominantly object-oriented
22
What is a Data Object?
24
Data Objects and Attributes
A data object contains a set of attributes that
act as an aspect, quality, characteristic, or
descriptor of the object
object: automobile
attributes:
make
model
body type
price
options code
26
Elements of the Analysis Model
Scenario-based Onward to data flow diagrams!
elements Flow-oriented elements
Use-case diagrams
Use cases - text Data-flow diagrams
Activity Diagrams Control flow diagrams
Swim lane diagrams Processing narratives
Analysis
Model
Class-based elements
Class diagrams Behavioral elements
State diagrams
Analysis Packages
Sequence diagrams
CRC Models
Collaboration Diagrams
27
Object Oriented Analysis (OOA)
28
Object-Oriented Concepts
• What are the basic object oriented concepts?
29
Object-Oriented Concepts
• What are the basic object oriented concepts?
30
Encapsulation/Hiding
The object encapsulates
both data and the logical
procedures required to
method method
manipulate the data #1 #2
data
method
method #3
#6
method method
#5 #4
31
Scenario Based Modeling:
Use-Cases
“[Use-cases] are simply an aid to defining what exists
outside the system (actors) and what should be
performed by the system (use-cases).” Ivar Jacobson
• a scenario that describes a “thread of usage” for a
system
• actors represent roles people or devices play as the
system functions
• users can play a number of different roles for a given
scenario
32
Class-Based Modeling
• Identify analysis classes by examining the problem
statement
• Use a “grammatical parse” to isolate potential classes
• Identify the attributes of each class
• Identify operations that manipulate the attributes
33
Grammatical Parsing
• Write an informal description of the problem. The customer
requirements document is one such description.
• Underline all nouns in the description
• Decide which of these are really objects which the project
requires and organize them in related clusters
34
Grammatical Parsing
University Bank will be opening in Oxford, Mississippi, in January,
2000. We plan to use a full service automated teller machine (ATM)
system.The ATM system will interact with the customer through a
display screen, numeric and special input keys, a bankcard reader, a
deposit slot, and a receipt printer.Customers may make deposits,
withdrawals, and balance inquires using the ATM machine, but the
update to accounts will be handled through an interface to the
Accounts system.Customers will be assigned a Personal Identification
Number (PIN) and clearance level by the Security system. The PIN can
be verified prior to any transaction.In the future, we would also like to
support routine operations such as a change of address or phone
number using the ATM
35
Grammatical Parsing
• University Bank will be opening in Oxford, Mississippi, in January,
2000. We plan to use a full service automated teller machine (ATM)
system.The ATM system will interact with the customer through a
display screen, numeric and special input keys, a bankcard reader, a
deposit slot, and a receipt printer.Customers may make deposits,
withdrawals, and balance inquires using the ATM machine, but the
update to accounts will be handled through an interface to the
Accounts system.Customers will be assigned a Personal
Identification Number (PIN) and clearance level by the Security
system. The PIN can be verified prior to any transaction.In the future,
we would also like to support routine operations such as a change of
address or phone number using the ATM
36
Typical Classes (a reminder)
• External entities - printer, user, sensor
• Things - reports, displays, signals
• Occurrences or events (e.g., interrupt, alarm)
• Roles (e.g., manager, engineer, salesperson)
• Organizational units (e.g., division, team)
• Places (e.g., manufacturing floor or loading dock)
• Structures (e.g., sensors, four-wheeled vehicles, or computers)
37
Selecting Classes—Criteria
retained information
needed services
multiple attributes
common attributes
common operations
essential requirements
38
CRC Modeling
39
Rules of Thumb
• The model should focus on requirements that are visible within the
problem or business domain. The level of abstraction should be
relatively high.
• Each element of the analysis model should add to an overall
understanding of software requirements and provide insight into
the information domain, function and behavior of the system.
• Delay consideration of infrastructure and other non-functional
models until design.
• Minimize coupling throughout the system.
• Be certain that the analysis model provides value to all
stakeholders.
• Keep the model as simple as it can be.
40
Use Cases
Introduction
• Use Case: “... a typical interaction between a user
and a computer system”, Booch
• Here, “user” is anything that needs or invokes the
functionality of the system
• “Computer system” is the system being modeled
• Use cases can capture and document the user-visible
functionality of a system
• Use cases capture how the system will benefit the
user
• Each use case achieves a discrete goal for the user
Goals
• Use cases help everyone come to a common
understanding of what the system should do
• Developers
• End-users
• Domain Experts
Teacher
Authorized Student
Staff Worker
Actors
• Actors are things outside the system that need to
interact with the system
• Actors carry out use cases
• Actors are represented as stick figures
• Although users are actors, not all actors are users
• Actors can be external software systems
• External hardware (sensors, actuators, etc.)
• Actors can be people that need the functionality of the
system, but may not be the ones who actually invoke
the software commands
Hints for Finding Actors
• Who or what will use the main functionality of the system?
• Who or what will provide input to this system?
• Who or what will use output from this system?
• Who will need support from the system to do their work?
• Are there any other software systems with which this one needs to interact
• Are there any hardware devices used or controlled by this system?
Hints for Modeling Actors
• An actor can be a role that a user plays with respect to
the system
• A single person may play different roles
• A single actor may perform many use cases
• A use case may be performed by many actors
• Show external systems as actors only when they are
the ones who need a use case
• Don’t worry too much about the details of an actor or
the relationship between actors and use cases
Relationships Between Actors
• Actors are Classifiers, meaning they are sets of
instances
• Therefore, an actor (a set of instances) can be a
subset of another actor (another set of instances)
• Generalization / Specialization
Student
Graduate
Student
Use Cases
• Each use case represents something the user
needs to do with the system – a goal
• A use cases is given a short name and textual
description (optional)
• Use cases can be large or small from a conceptual
perspective
• Use cases can relate to each other via
dependencies, such as
• <<extends>>
• <<includes>>
• Generalization or <<refines>> (“is a”)
Use Cases
• Extension point example:
• http://www.visualcase.com/kbase/usecase.jpg
Includes
Extends
Generalization
Hints for Finding Use Cases
• Try listing actors first and then look at the activities each
needs to perform and then try to express the goal that
represent these activities
• although this will uncover many valuable use cases, it will not find
them all
• Try listing external events and then look at what the
system needs to do in response to each one.
• This technique will find some additional use cases, but not all
• Be patient, allow the use cases to unfold
• Don’t over do it – Use Case Diagram should be broad-
brush characterizations of user goals
Hints for Modeling Use Cases
Establish the context of a user goal by
identifying the actors
For each actor, consider the behavior that it
expects or requires the system to provide
Name these common behaviors as use
cases
Factor common behavior into new use cases
Relate the use cases using the extend,
includes, and refines dependencies
Adorn uses cases with notes
Use-Case Relationships
• Extends dependency: defines a use-case that is a variation of another,
usually for handling an abnormal situation
<<extends>>
<<includes>>
<<refines>>