download

Rational Rose
Introduction to Computer-aided
Software Engineering (CASE):
Rational Rose
and ATM example
• What is it?
– Rose (Rational Objected-orientated Software Engineering) is a
CASE (Computer-Aided Software Engineering) tool
– it supports the modelling of software systems → captures user
requirements, analysis of the requirements and the design of
the solution in one model (with different views)
– it is meant to be used by all members of a software team to
coordinate development of the software system
– it can map the architecture of the system to code in various
languages (Java, C++, Ada, Visual Basic, …)
Developer(s)
– it can “reverse engineer” code to a model
Developer
Requirements
SE104. Originally prepared by Gary
Bundell modified by R Thomas
2nd sem 2003 1
Code
Requirements
Model
Code
2nd sem 2003 2
SE104. Originally prepared by Gary
Bundell modified by R Thomas
ATM example:
Use Case Diagrams
Use Cases
• ATM Example - Requirements:
– Identify the required functionality:
•
•
•
•
•
•
deposit funds
transfer funds
withdraw money
change a PIN
check the balance
make a payment
– Identify the externals to the ATM machine (the actors):
• customer
• bank officer
• bank system
SE104. Originally prepared by Gary
Bundell modified by R Thomas
Actors
2nd sem 2003 3
SE104. Originally prepared by Gary
Bundell modified by R Thomas
2nd sem 2003 4
Use-case Scenarios
• Scenarios are usually described by interaction diagrams
→ sequence or collaboration diagrams
• Several interaction diagrams may be needed to define a
use case, e.g. ATM example: Withdraw Money use case
ObjectName:ClassName
– what happens when OK
– what happens when wrong PIN entered
– what happens when insufficient funds available, etc
•
Need to find the objects or classes:
Lifelines
– e.g. via class identification (get nouns from requirements)
• Customer, Card Reader, ATM Screen, Customer’s Account, Cash Dispenser
• Need to describe the interactions:
• Insert card, Card Reader reads card, Initialises the ATM screen, Prompts for
PIN, Customer enters PIN, Open the Account, Verifies PIN, ...
SE104. Originally prepared by Gary
Bundell modified by R Thomas
2nd sem 2003 5
Messages
Sequence Diagram:
Focus is on object
interaction
sequences
2nd sem 2003 6
SE104. Originally prepared by Gary
Bundell modified by R Thomas
ATM example:
Class Diagrams
• A class encapsulates information and behaviour:
Attributes
– e.g. an Employee class would have:
• employeeID, name, address, phone number, etc (i.e. have attributes)
• know how to be hired and fired, pay changed, etc (i.e. have operations)
• Classes can be found from:
– requirements documentation
– event flow in use cases
• From the ATM example:
Operations
– Card Reader, ATM Screen, Cash Dispenser, Account
Association
Relationships
• Develop the class operations and attributes:
– operations from messaging from interaction diagrams
– attributes from the information the class needs to maintain
SE104. Originally prepared by Gary
Bundell modified by R Thomas
2nd sem 2003 7
SE104. Originally prepared by Gary
Bundell modified by R Thomas
2nd sem 2003 8
ATM example:
Mapping Messages → Operations
Messages -> Operations
• Messages between objects become operations on
classes:
anObject1: Object1Class
anObject2: Object2Class
Actor messages remain
as messages
1: message to anObject2
1: operationOnObject2Class
– Messages to actors are not converted to operations
– All objects on the sequence diagram must be mapped to a class
so that the operations of the class can be used
– Can check for completeness of mapping (e.g. in Rose use
Report -> Unresolved messages)
2nd sem 2003 9
SE104. Originally prepared by Gary
Bundell modified by R Thomas
2nd sem 2003 10
SE104. Originally prepared by Gary
Bundell modified by R Thomas
ATM example:
Class Behaviour
• Consider the Account class in the ATM example:
– Need to be able to open and close an account
– Need to be make deposits and withdrawals
– Need to deny withdrawals if the balance is less than zero and
inform the customer
Start State
• State Transition Diagrams (StateCharts) can capture this
behaviour:
– states
– transitions
Event / Action [Guard]
stateName
/^Target.SendEvent(arguments)
Transition
Entry: activity/action
Do: activity/action
– event/action
Exit: activity/action
– guards
– send events or messages
SE104. Originally prepared by Gary
Bundell modified by R Thomas
Stop State
2nd sem 2003 11
SE104. Originally prepared by Gary
Bundell modified by R Thomas
State
2nd sem 2003 12
Code Generation - ATM example
SE104. Originally prepared by Gary
Bundell modified by R Thomas
2nd sem 2003 13
Lecture Summary
• Rational Rose is a CASE tool that supports Visual
Modelling with the UML
• Have looked at Rose implementation of:
–
–
–
–
–
–
Use case diagrams
Use case scenarios: interaction diagrams
Class diagrams
Sequence diagrams: messages → operations
State Diagrams
Code generation: components
• Next → Rose: Class relationships & behaviour
SE104. Originally prepared by Gary
Bundell modified by R Thomas
2nd sem 2003 15
Code Generation - ATM example(2)
SE104. Originally prepared by Gary
Bundell modified by R Thomas
2nd sem 2003 14