Week 7
Week 7
Week 7
Rajib Mall
CSE Department
IIT KHARAGPUR
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
• “UML is a large and growing beast, but you don’t need all
of it in every problem you solve…”
– Martin Fowler
• “…when learning the UML, you need to be aware that
certain constructs and notations are only helpful in
detailed design while others are useful in requirements
analysis …” Brian Henderson-Sellers
Are All Views Required for Developing A
NO Typical System?
For a simple system:
− Use case diagram, class diagram and one of the interaction diagrams
only.
State chart diagram:
− when class has significant states.
− When states are only one or two, state chart model becomes trivial
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”
Start use case Use Case
Scenarios
Alternative flow 3 Alternative flow 1
Alternative flow 2
Alternative flow 4
end use case
end use case
• Do not have both system and actor Actor gives the amount
– Bad: “Get the amount from the user and give him the receipt.”
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".
Too many use cases
at any level should
be avoided!
Use Case Packaging
Accounts
Print
Query balance
Balance sheet
Receive Make
grant payments
Ordering
Query balance
More accetable!
Customer
Maintenance
Query balance
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
More
Generalization
Feline Lizard
Examples…
Wrong
Generalization Chassis Engine Door
--- attributes attributes attributes
or “is a kind
of” heuristic
69
Inheritance Example Library
Book
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.