A Student Guide to Object-Oriented Development - PowerPoint PPT Presentation

About This Presentation
Title:

A Student Guide to Object-Oriented Development

Description:

A Student Guide to Object-Oriented Development Chapter 6 Identifying Functionality * * * Size 10cm X 15cm. To encourage small cohesive classes with limited but well ... – PowerPoint PPT presentation

Number of Views:181
Avg rating:3.0/5.0
Slides: 28
Provided by: Jacqui96
Category:

less

Transcript and Presenter's Notes

Title: A Student Guide to Object-Oriented Development


1
A Student Guide to Object-Oriented Development
  • Chapter 6 Identifying Functionality

2
Class-Responsibility-Collaboration (CRC) cards
Identifying operations using the CRC card
technique
  • useful for identifying operations
  • not officially part of the UML
  • views classes in terms of their responsibilities
  • responsibilities evolve into sets of operations

3
Responsibilities
  • Overall system functionality divided up between
    classes
  • Each class has certain responsibilities
  • to provide a service to a user (e.g.maintain a
    customer record) or to another class (e.g. to
    supply data)

4
CRC cards
  • Responsibilities are allocated to the most
    appropriate class
  • Sometimes a class needs to collaborate with
    another class to fulfil its responsibilities

5
CRC card for the Customer class
6
Identifying responsibilities from scenarios
  • Stephanie arrives at the shop at 9.00am one
    Saturday and chooses a mountain bike
  • Annie sees that its number is 468
  • Annie enters this number into the system
  • The system confirms that this is a womans
    mountain bike and displays the daily rate (2)
    and the deposit (60) (Bike)
  • Stephanie says she wants to hire the bike for a
    week
  • Annie enters this and the system displays the
    total cost 14 60 74 (Bike)
  • Stephanie agrees this
  • Annie enters Stephanies name, address and
    telephone number into the system (Customer)
  • Stephanie pays the 74
  • Annie records this on the system and the system
    prints out a receipt (Payment collaborating with
    Customer)
  • Stephanie agrees to bring the bike back by 5.00pm
    on the following Saturday

7
Collaboration of objects
  • A collaboration is the group of objects that
    interact to execute a use case

8
.Sample Collaboration Diagram
  • .

2 validate id
3 enter current semester
1 enter id
registration form
4 create new schedule
5 display
John Student
schedule form
available classes
6 get courses
9
Sample Sequence Diagram
10
CRC card for the Hire class
11
CRC card for the Bike class
12
CRC card for the Payment class
13
Deriving operations from responsibilities
  • We need to specify responsibilities in terms of
    individual operations and attributes.
  • Ensure that each class has data and operations to
    fulfil responsibility
  • Walk through use case description

14
Use case description Issue bike
15
Operations required for issue bike use case
16
Class diagram for Wheels with attributes and
operations
17
Interaction Diagrams
  • Describe messaging between objects to achieve use
    case goal
  • Revisit sequence of events in each scenario
  • View in terms of messages spawned by each event.
  • Two types of interaction diagram sequence and
    collaboration

18
Sequence diagrams
19
Sequence diagrams
20
Sequence diagrams
21
Sequence diagrams
22
Sequence diagrams - without returns
23
Sequence Diagrams
  • Sequence diagrams present the flow of messages
    between instances in time.
  • One can immediately see in what order messages
    are sent because time is an explicit, vertical
    dimension on the sequence diagram
  • each instance is represented as a verticalline

24
Collaboration Diagrams
  • Collaboration diagrams show how objects work with
    each other by sending messages and exchanging
    data.
  • Sequence diagrams and collaboration diagrams are
    two different views of object interactions

25
Collaboration Diagrams
26
Data dictionary - operations
  • findBike(bike)
  • This operation finds the Bike object whose
    number corresponds to the bike number input
    (bike) and returns details about the bike (bike
    available type make model size
    dailyHireRate deposit)

27
Another example - calcDaysOverdue()
  • calcDaysOverdue()
  • This operation uses today's date from the system
    clock and the attributes startDate and numberDays
    to calculate whether the bike has been returned
    late and if so by how many days. It calculates
    the overdue amount (Bike.dailyHireRate multipled
    by the number of days late) and records it by
    executing SetLatenessDeduction(amt).

28
specification by contract - describes operations
in terms of the services they deliver
the signature of the operation (its name, any arguments, and the type of values it returns) calcDaysOverdue ( )
the purpose of the operation this operation works out whether a bike has been returned late and if so by how many days
what the client object must provide in order to obtain the required service the bike must have been returned by the customer, the hire details must have been found,
a description of the internal logic of the operation the number of days hired is added to the start date and then compared with todays date to calculate if the bike is late and by how many days. The daily hire rate is multiplied by the number of days late to give the charge for late return, this is performed by the Bike.getCharges operation
any other operations that are called by this operation this operation calls Bike.getCharges(noDaysLate)
any attributes of objects whose values are changed by the operation this operation sets the Hire attributes dateReturned and latenessDeduction
Write a Comment
User Comments (0)
About PowerShow.com