6 - Uml
6 - Uml
Requirements Analysis
and the Unified Process
What is UML?
A brief history of UML and its origins.
Understanding the basics of UML.
UML diagrams
UML Modeling tools
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 2
What is UML?
UML: Unified Modeling Language
An industry-standard graphical language for
specifying, visualizing, constructing, and
documenting the artifacts of software systems,
as well as for business modeling.
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 3
Why UML for Modeling?
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 4
History
Time
Year Version
2003: UML 2.0
2001: UML 1.4
1999: UML 1.3
1997: UML 1.0, 1.1
1996: UML 0.9 & 0.91
1995: Unified Method 0.8
Booch ‘91
OMT - 1
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 5
Types of UML Diagrams
Sequence Diagram:
Displays the time sequence of the objects participating in the
interaction.
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 6
Types of UML Diagrams (Cont.)
Collaboration Diagram
Displays an interaction organized around the objects
and their links to one another.
State Diagram
Displays the sequences of states that an object of an
interaction goes through during its life in response to
received stimuli, together with its responses and
actions.
Component Diagram
Illustrate the organizations and dependencies of the
physical components in a system. A higher level than
class diagrams.
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 7
Use Case Diagrams
Borrow
Employee
Client
Order Title
Fine Remittance
Supervisor
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 9
Use Case Diagram (core components)
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 10
Use Case Diagram(core relationship)
employee
waitress
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 11
Use Case Diagram(core relationship)
<<uses>>
or in MS Visio
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 12
Use Case Diagram (core relationship)
<<uses>> <<extends>>
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 13
Use Case Diagrams(cont.)
(TogetherSoft, Inc)
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 14
Use Case Diagrams(cont.)
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 15
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.
The last two compartments may be omitted to simplify the
class diagrams
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 16
An example of Class
Name
Account_Name
- Custom_Name
Attributes
- Balance
+AddFunds( ) Operations
+WithDraw( )
+Transfer( )
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 17
C++ Class Example
class Checking {
private:
char Customer_name[20];
float Balance;
public:
AddFunds(float);
WithDraw(float);
Transfer(float);
set_name(string);
get_name();
set_balance(float);
get_balance();
};
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 18
Notation of Class Diagram: association
Uni-directional association
e.g. Order and item
notation:
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 19
Association: Multiplicity and Roles
student
1 *
University Person
0..1 *
employer teacher
Multiplicity
Symbol Meaning Role
Role
1 One and only one “A given university groups many
0..1 Zero or one people; some act as students, others
M..N From M to N (natural as teachers. A given student
language) belongs to a single university; a
* From zero to any positive given teacher may or may not be
integer working for the university at a
0..* From zero to any positive
particular time.”
integer
1..* From one to any positive
integer
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 20
Notation of Class Diagram: Generalization
Regular Loyalty
Customer Customer
Subtype1 Subtype2
or: Customer
Generalization expresses a
relationship among related
classes. It is a class that
includes its subclasses.
Regular Loyalty
Customer Customer
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 21
Notation of Class Diagram: Composition
COMPOSITION Composition: expresses a relationship among instances
Whole Class of related classes. It is a specific kind of Whole-Part
Class W relationship.
Apples Milk
Aggregations may form "part of" the aggregate, but may not be
essential to it. They may also exist independent of the aggregate.
Less rigorous than a composition.
e.g. (1)Apples may exist independent of the bag.
(2)An order is made up of several products, but the
products are still there even if an order is
cancelled.
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 24
Class Diagram example
Name Order class
-dateReceived
Multiplicity: mandatory
Attributes -isPrepaid Customer
-number :String
-price : Money
* 1 -name
-address
+dispatch() Association +creditRating() : String()
Operations +close()
1
{if Order.customer.creditRating is Generalization
"poor", then Order.isPrepaid must
be true }
A B
[condition] remove()
Condition
*[for each] remove()
Iteration
Self-Call
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 26
Sequence Diagrams – Object Life Spans
Lifelines
The dotted line that extends down the
vertical axis from the base of each
object.
A
Messages
Labeled as arrows, with the arrowhead
indicating the direction of the call. Create
B
Activation bar
The long, thin boxes on the lifelines are
method-invocation boxes indicting that
indicate processing is being performed
by the target object/class to fulfill a
message.
Activation bar
Rectangle also denotes when object is X
deactivated. Return
Deletion
Deletion Lifeline
Placing an ‘X’ on lifeline
Object’s life ends at that point
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 27
Sequence Diagram
Us er Message Catalog Res ervations
1: look up ()
2: title data ()
4 : title returned ()
5: hold title ()
5 : title available ()
6 : borrow title ()
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 29
Interaction Diagrams: Collaboration
diagrams (cont.)
start
6: remove reservation
1: look up
2: title data
4 : title returned
Catalog
5 : hold title
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 30
CRC Card
Responsibility
• Keep list of reserved titles
• Handle reservation
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 31
How to create CRC cards?
Find classes
Look for main classes first, then find relevant classes.
Find responsibilities
Know what a class does; what information you wish to maintain about
it.
Define collaborators
A class often needs to collaborate with other classes to get the job
done. Collaboration diagram is an example to show class relationship.
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 32
State Diagrams
(Billing Example)
Start End
Unpaid Paid
Invoice created payin Invoice destroying
g
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 33
Basic rules for State Diagrams
Draw only one object's chart at a time.
Yellow
Green
Event
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 35
Component Diagram
Components
a large rectangle with two smaller rectangles on the side.
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 36
Component Diagram (cont.)
Interface
An interface describes a group of operations used or
created by components. It represents a declaration of
a set of coherent public features and obligations,
similar to a contract.
Dependencies
dashed arrows.
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 37
Component Diagram (cont.)
order
customer
account
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 39
Microsoft Visio
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 40
UML studio 7.1
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 41
Poor Design, need more heuristics!
(Radu Marinescu[5])
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 42
A cleaner design
(Radu Marinescu[5])
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 43
Reference
5. http://labs.cs.utt.ro/labs/acs/html/lectures/4/lecture4.pdf
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 44
Introduction to UML[1]
Component Logical
View View
Use
Case
View
Concurrenc
Deployment
y
View
View
Model elements
Class
Object
State
Use case
Interface
Association
Link
Package ….
Stratford University | School of Computer Science & Information Technology | Dr. Engr. Sami ur Rahman 55
Introduction to UML[1]
Component Logical
View View
Use
Case
View
Concurrenc
Deployment
y
View
View
Model elements
Class
Object
State
Use case
Interface
Association
Link
Package ….
C ustom er
Actors:
Cashier
Customer
Supervisor
Choosing actors:
Identify system boundary
Identify entities, human or otherwise, that will interact
with the system, from outside the boundary.
Example: A temperature sensing device is an actor for
a temperature monitoring application.
Cashier
Log In
Cash out
Customer
Buy items
Return items
Common error -
representing individual
steps as use cases
Example: printing a receipt
(Why?)
Process sale
Payment
Authorization
Cashier Handle returns
service
Manage
System administrator <<actor>>
security
Accounting
Manage users
system