UML Complete Week 7 and Week 8
UML Complete Week 7 and Week 8
1
Introduction
• Object-oriented design (OOD) techniques are now extremely
popular:
–Inception in early 1980’s and nearing maturity.
Standardization
UML 1.1
public
feedbac UML
UML 0.9
0.9 && 0.91
0.91
Unification
k
Unified method 0.8
Booch'93 OMT-2
− Behavioral view
− Implementation view
− Environmental view
Diagrams
Behavioural View
Structural View - Sequence Diagram
and views
in UML
- Class Diagram - Collaboration Diagram
- Object Diagram - State-chart Diagram
- Activity Diagram
User’s View
-Use Case
Diagram
Deployment diagram:
− In case several hardware components used to develop the system.
Use Case Modelling
9/6/2018
Use Case Model Behavioural View
Structural View - Sequence Diagram
Play Move
Tic-tac-toe game
Player
update
grades
faculty
Another Example Use Case Diagram
Rent
Videos
Clerk <<external system>>
Credit Authorization
. . . Service
Yet Another Use
Telephone Order System
Case Example
Check
Status Salesperson
Place
Order
Fill
Shipping
Orders
Customer Clerk
Establish
credit
Supervisor
Factoring Use Cases
• Two main reasons for factoring:
–Complex use cases need to be factored into simpler use cases
–Helps represent common behavior across different use cases
• Three ways of factoring:
–Generalization
–Include
–Extend
Generalization
• The child use case inherits the
parent
behavior of the parent use case.
–The child may add to or override some
child
of the behavior of its parent.
Registration
Generalization
Example 1
Under-graduate Graduate
registration registration
Factoring Use Cases Using Generalization
<<include>>
<<include>>
<<include>>
<<include>>
<<include>>
<<include>>
Example of Factoring
Use Cases Using
Check Reservation Include
Example Factoring A Use Case Using
Extend
<<extend>>
Perform Sale Product is a gift
Gift wrap
After checkout Product
Order
Supply Product
Customer Data Arrange
Payment
<<include>>
<<include>>
<<include>>
Place Order
Cash Credit
Payment Payment
Sales Person
<<extend>>
Salesperson asks for catalog
Rent/Return
Videos
«include»
Staff
Customer
Search for
Videos
Maintain
Customers
«include»
Maintain Example 1:
Videos
Solution
Generate
Manager Reports
Name
Actors Use Case
Trigger Description
Preconditions
Post conditions
Mainline Scenario
Alistair Cockburn
“Writing
Effective Use
Alternatives flows Cases”
ATM Money Withdraw Example
• Actors: Customer
• Pre Condition:
– ATM must be in a state ready to accept transactions
– ATM must have at least some cash it can dispense
– ATM must have enough paper to print a receipt
• Post Condition:
– The current amount of cash in the user account is the amount before withdraw
minus withdraw amount
– A receipt was printed on the withdraw amount
Actor Actions System Actions
1. Begins when a Customer arrives
at ATM
2. Customer inserts a Credit card 3. System verifies the customer ID
ATM Money
into ATM and status Withdraw
5. Customer chooses “Withdraw” 4. System asks for an operation
operation type Mainline
7. Customer enters the cash
amount
6. System asks for the withdraw
amount
Scenario
8. System checks if withdraw
amount is legal
9. System dispenses the cash
10. System deduces the withdraw
amount from account
2. Event-based
- Identify the external events that the system must respond to.
- Relate the events to actors and use cases.
Example 2: Use Case Model for Course Management Software
• At the beginning of each semester,
– Each professor shall register the courses that he is going to teach.
• A student can select up to four-course offerings.
– During registration a student can request a course catalogue showing course offerings for the
semester.
– Information about each course such as professor, department and prerequisites would be
displayed.
– The registration system sends information to the billing system, so that the students can be
billed for the semester.
• For each semester, there is a period of time during which dropping of courses is
permitted.
• Professors must be able to access the system to see which students signed up for each
of their course offerings.
Course Management Software
Register Example 2:
Course
offering
See
Model Solution
Course
Professor Show List
registration
<<Extend>>
<<External>>
Register
Billing System
course
Student
Drop
Course
Calendar
• Use case name should begin with a verb.
• While use cases do not explicitly imply timing:
– Order use cases from top to bottom to imply timing -- it improves readability.
• Use cases should start off simple and at as much high view as
possible.
Effective Use Case
– Can be refined and detailed further. Modelling
• Use case diagrams represent functionality:
– Should focus on the "what" and not the "how".
Class Diagram
• Classes:
– Entities with common features, i.e. attributes and operations.
– 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.
UML Class Representation
• A class represents a set of objects having similar attributes,
operations, relationships and behavior.
Class Name
Window
A class can
size: Size implicitly
Attributes have a few
visibility: boolean association
attributes
display()
Operations hide()
Different representations of the LibraryMember class
–Represents generalization-specialization
Dog Cat
Inheritance
• Lets a subclass LibraryMember Base Class
inherit attributes
and methods from
Derived
a base class. Faculty Students Staff
Classes
Inheritance
Derived
Faculty Students Staff Faculty Students Staff
Classes
Multiple
Inheritance
issuable reference
Issuable Reference
Issuable Reference
Single Volume Single Volume
BookSet BookSet
Book Book
V. Ramesh
691205-5678
Keshab Parhi
People Tax_files
1 1
People Associated Tax_files
with
motherOf
Multiple
Bhim
Association – motherOf
example Kunti Yudhistir
motherOf
Arjun
Woman Person
1 *
Woman Mother of Person
Association UML Syntax
role B
Class A role A Class B
Association Name
Association - More Examples
Library Member
1 borrowed by *..5 Book
* eats * Human
Lion
opens 0..5
Key * Door
Association – Multiplicity
• A teacher teaches 1 to 3 courses (subjects)
• Each course is taught by only one teacher.
• A student can take between 1 to 5 courses.
• A course can have 10 to 300 students.
1 teaches 1..3
Teacher Course
1..5
takes
Students
10..300
Quiz: Draw Class Diagram
• A Student can take up to five Courses.
Correct or
Wrong Student credits hasEnrolmentOf Course
10..300 Enrols in 1..5
opens 0..5
* Door
Key
Association and Link
• A link:
– An instance of an association
– Exists between two or more objects
– Dynamically created and destroyed as the run of a
system proceeds
• For example:
– An employee joins an organization.
– Leaves that organization and joins a new organization.
Association Relationship
• A class can be associated with itself (unary association).
–Give an example?
• An arrowhead used along with name: *
–Indicates direction of association. Person *
Friend of
Aggregation
Composition
Overdoing Associations
• Avoid unnecessary Associations
PersonInfo PersonInfo
Person 1 1 Address Name
Name E-Mail Address
Birthday E-Mail
Birthday
* Paragraph * Line
1
Document 1
* *
1 0..1
Company Person Club
employs memberOf
Aggregation cont…
*
1
Aggregation vs. Inheritance
Inheritance:
Cont…
Aggregation:
− Containment allows construction of complex objects.
Composition
• A stronger form of aggregation
– The whole is the sole owner of its part.
• A component can belong to only one whole
– The life time of the part is dependent upon the whole.
• The composite must manage the creation and destruction of its
parts. 1
Circle Point Circle
3..* Point
Polygon
Composition Relationship
• Life of item is same as that of order
1
Order * Item
Composition: Alternate Notation
Car
4 1
Wheel Engine
2 1
Door Chassis
1 1
Axle Steering
Composition
Window whole
• An object may be a part of ONLY
1
one composite at a time.
Whole is responsible for the
creation and disposition of its parts. *
Frame part
• Composition: Aggregation vs. Composition
– Composite and components have the same life line.
• Aggregation:
– Lifelines are different.
• Consider an order object:
– Aggregation: If order items can be
changed or deleted after placing order.
– Composition: Otherwise.
Composition versus Aggregation
*
1
Order Item Composition
*
1
Item Aggregation
Order
Class Dependency
Types Engine
• composition: is made of
Book
– Stronger version of aggregation composition
1
– The parts live and die with the whole *
Page
– Symbolized by a filled diamond
• dependency: Depends on dependency
Summary
Object Object
Aggregation Composition
Object Association Association Association
1..* 1
n n
0..* 0..*
Mritunjay LibraryMember
LibraryMember
B10028
C-108, Laksmikant Hall Mritunjay
1119 B10028
Mrituj@cse C-108, Laksmikant Hall
25-02-04 1119
25-03-06 Mrituj@cse
NIL 25-02-04
25-03-06
IssueBook( ); NIL
findPendingBooks( );
findOverdueBooks( ); Different representations of
returnBook( ); the LibraryMember object
findMembershipDetails( );
Interaction Diagram
• Can model the way a group of objects interact to realize some
behaviour.
35
Develop One Sequence
diagram for every use case
Return
Book member: :Book
book:Book
LibraryMember Copy
Use ok = canBorrow()
Case borrow(book)
Borrow
Book
Book [ok] borrow(member)
Search setTaken(member)
Book
36
Sequence Diagram
• Shows interaction among objects in a two-dimensional
chart member:
LibraryMember
book:Book
:Book
Copy
–iteration (*)
member: :Book
book:Book
LibraryMember Copy
• iteration marker *[for all objects]
ok = canBorrow()
• [condition] borrow(book)
[ok] borrow(member)
– message is sent only if the condition is true setTaken(member)
• self-delegation
– a message that an object sends to itself Gist of Syntax
• Loops and conditionals:
– UML2 uses a new notation called interaction frames to support
these
Control logic in Interaction Diagrams
• Conditional Message
– [ variable = value ] message()
– Message is sent only if clause evaluates to true
• Iteration (Looping)
– * [ i := 1..N ] message()
– “*” is required; [ ... ] clause is optional
– The message is sent many times to possibly multiple receiver
objects.
Elements of A Sequence Diagram
X-Axis (objects)
member: :Book
book:Book
LibraryMember Copy
Y-Axis (time)
condition
How do you show Mutually exclusive conditional messages?
41
Sequence Diagrams
How to represent Mutually exclusive conditional invocations?
confirm
updateMemberBorrowing
State Machine
Diagrams
9/13/2018
State Chart Diagram Cont…
– State table
e1 Light_off none
Light_off
e2 Light_on set red LED flashing
e1 Light_on none
Light_on
e2 Light_off reset red LED flashing
OOAD Process
Iterative and Incremental
OOA OOD/OOP
Domain
Specification Definition Model Construction
of of Program
Use
the problem case the solution
model
OOA versus OOD?
• Analysis:
– An elaboration of requirements.
– Independent of any specific implementation
• Design:
– A refinement of the analysis model.
– Takes implementation constraints into account
Design Process
OOA OOD
User interface
Use case Interaction
Issues or GUI
prototype diagram diagram
Start
Glossary
Domain Model Conceptual Class Diagram
Relationships Domain Model
Define terms
Domain
Use Case Model objects Glossary
Functional Requirements
Interaction Diagrams
Dynamic Behavior