Scenario To Calculate Due Date Fine of A Library System
Scenario To Calculate Due Date Fine of A Library System
• The problems
– Are we building the right system?
– How to manage a large team of people?
– How to guarantee the quality of the software?
– How to prepare for changes in future?
– How to make the software easy to maintain?
– How to document the software?
– What happen if people in the team quit?
• Examples of methodologies
– Waterfall process
• Traditional approach
– Rational Unified Process (RUP)
• Proprietary product by Rational
– Agile Process
• Extreme Programming (XP)
• Advantages
– Users understand the spec, so that they can
participate in the process more effectively
• In comparison
– Traditional methods write the spec from the
developer’s viewpoint, using developer’s language
– Too technical, users can’t understand it
Requirement
definition
System and
software design
Implementation
and unit testing
Integration and
system testing
Operation and
maintenance
• Main problem
– A complete cycle can take a year to complete, slow
to respond to changes
– Modern approaches favor shorter cycle (from a day
to a few weeks) that build the work incrementally,
so that
• Risks can be discovered earlier
• Changes can be made more rapidly
• Short iteration provides continuous feedback to
the users
Analysis Model
Design Model
Implementation Model
Test Model
Project Manager
• actors
– users of the system (borrower, administrator)
• use cases
– how the system will be used by the actors
Department of Information Engineering 15
Preliminary system requirements
• Who is a user?
– An instance of the actor – the actual person who
uses the system
– e.g John is an instance of the actor Borrower
• Actors
– Borrower
– Librarian
– System administrator
• Iterative process
– Deal with the primary use cases first
Borrow copy of a book
User
Return copy of a book
• Prototyping
– Produce a rough user manual
– Discover all the basic courses of action
– Ignoring alternative courses (exceptions)
• The source use case makes use of the target use case
Extend loan <<use>>
Check for
Borrower reservation
Borrow copy
<<use>>
of a book
Refuse loan
Borrowing books <<extend>>
Borrower
Data base
• Local knowledge
– Object has limited knowledge, the knowledge is
encapsulated
class name
subclasses:
superclasses:
responsibilities collaborators
• Ref
– OOPSLA`89 in http://c2.com/doc/index.html
• A Laboratory for Teaching Object-Oriented
Thinking by Beck and Cunningham
• Facilitator (Nancy)
– object oriented expert
To discover classes in the application,
form a glossary,
use the glossary to produce scenarios
• Filtering classes
– eliminate redundancies
– identify missing abstraction
– recognize related classes
• e.g
– Betty: Librarian
– Dewey: Lendable
– Cecilia: Borrower, User,
– Jim: Book, Video, Journal, Date
• User:
– The human being that comes to use the library
• Borrower
– The set of objects that represent Users who borrow
items from the library
• Date
– The set of objects that represent dates in the system
Librarian: The object in the system that
fulfills User requests to check out, check in,
and search for library material
Librarian (class name)
subclasses:
superclasses:
responsibilities collaborators
• Scenario walkthrough
– Scenarios are concrete instances of use cases
– Use case
• A Borrower presents a book. The system checks . . .
– Scenario
• Ricky presents the C# Primer to the system, . . .
Department of Information Engineering 53
Ask the “What happens when . . .” question
• What happens when
– Ricky returns a video, C# Primer, to the Library
• The Book ?
– Ask the Book to change its status to ‘OUT’
• The Borrower !
– Ricky should know how many books he has
borrowed
• Borrower
– I am adding CanBorrow on my card as the
responsibility. I can use KnowFine responsibility to
see that my fine is less than $100. I will use
KnowSetOfBooks responsibility to see if I am over my
lendable limit. Knowing that I have only one book out,
I need to find out whether this book is overdue. Will
you know that, Book?
Department of Information Engineering 59
Check-out scenario
• Book
– I’ll add KnowDueDate as a responsibility. I will also
add KnowIfOverdue. To do this, I need to collaborate
with Date to compare today’s date and due date
• Date
– I’ll add CompareDates responsibility to my list. To
compare, I need to collaborate with another instance
of Date (today’s date), so I’ll add Date as my
collaborator. In this case, today’s date is less than due
date, Book.
• Book
– Great. Borrower, I can tell you that I am not overdue
• Borrower
– OK. Librarian, the Borrower can borrow.
Department of Information Engineering 60
Check-out scenario
• Librarian
– OK. I now need to change the Book’s state to indicate
that it is OUT
– I’ll ask Book to
• set due date
• set out status
• record name of borrower
• Wait a minute . . .
– Need to collaborate with Book three times
• Librarian
– Book, if I tell you who the Borrower is, can you please
check yourself out?
• Book
– Sure. I’ll add CheckOut as my responsibility. I must
know how to CalculateMyDueDate, and I need to
KnowMyBorrower, KnowDueDate, and KnowInOrOut.
I will add these as responsibilities. Done. Back
Librarian .
• Librarian
– Borrower, please add this book to your list
• Borrower
– I will add a responsibility to AddBook
Date
compare dates Date
Borrow
can borrow Book
know set of books
Book
know if overdue Date
check out
calculate due date
know due date
know borrower
know in or out
Department of Information Engineering 65
What we have achieved
• Identify objects (classes) in the system
• Identify their responsibilities
– the behavior of the objects later becomes the
functions of the objects
• Identify their collaboration
• Related scenarios
– repeat the check-out scenario with different
variations
– e.g. what happens if Frank has a non-overdue book
at home and what to check out a video
“Casablanca”?
UI
DB
Collection
Library
Lendable
Borrower Date
checkout
checkin
search
UI Library Borrower
collection
Lendable Date
check out Lendable Lendable, Borrower
check in Lendable Lendable, Borrower
search for Lendable Collection
get info from user UI Subsystem
display message UI Subsystem
Collection
know set of Lendables DB Subsystem, Lendables
Borrower
can borrow Lendable
know set of Lendables
know fine amount
Department of Information Engineering 75
CRC cards after analysis session
Date
compare dates Date
add days to date
Lendable
subclasses: Book, Video, Journal
calculate due date Date
calculate fine
check out Date
check in
know due date
know borrower
know in or out
know if overdue Date
Book
superclass: Lendable
calculate due date Date
calculate fine
Video
superclass: Lendable
calculate due date Date
calculate fine
Journal
superclass: Lendable
calculate due date Date
calculate fine
Department of Information Engineering 77
• Borrower can be a staff or a student
– Staff can borrow more books, has more privilege,
and pays heavier overdue fine
• UI
– Keep the GUI subsystem as separate as possible
– Add new class UI to serve as a layer that separate
the application and the GUI
• DB
– like UI, to separate the application from DBMS-
specific calls
Department of Information Engineering 81
Design model
• Object creation scenarios
– Who is responsible in creating/destroying the object?
– What is the lifetime of the object?
• UI
– Add GetBorrowerId as a responsibility
void main()
{
Librarian betty = new Librarian();
betty.WaitForUser(); //pass control to UI, wait
}
• UI
– Collaborate with the C# Form classes to capture
user input
<<file>>
<<file>>
interface
Department of Information Engineering 93
Artifacts from each stage
Refined
interaction
sequence diagram
diagram
Glossary class diagram refined class
diagram
source code
• Reverse engineering
– Turn C++/Java/C# code into UML class diagrams
• Round-trip engineering
– Generate C# code from UML class diagrams
– Edit the C# source code, compile and run
– Update the UML class diagrams by reverse
engineering
– Repeat the iterations
Department of Information Engineering 95
Reading list
• A Laboratory for Teaching Object-Oriented Thinking by Beck and
Cunningham (on CRC cards)
– c2.com/doc/index.html
• UML resources (contains references to tutorials on UML)
– www.omg.org
• Using the IBM RUP for small project – Gary Pollice
– www3.software.ibm.com/ibmdl/pub/software/rational/web/whitepapers/2
003/tp183.pdf
• A simplified approach to RUP – Gary Evans
– www-106.ibm.com/developerworks/rational/library/354.html
• dX: A minimal RUP process – Martin, Booch, Newkirk
– www.objectmentor.com/publications/RUPvsXP.pdf
• Extreme Programming (XP)
– www.serverworldmagazine.com/webpapers/2002/01_kanbay.shtml
• A good introduction to XP
– www.extremeprogramming.org
• A Comparison of the IBM RUP and XP – John Smith
– www3.software.ibm.com/ibmdl/pub/software/rational/web/whitepapers/2
003/TP167.pdf
Department of Information Engineering 96