Object Oriented Design Heuristics - PowerPoint PPT Presentation

About This Presentation
Title:

Object Oriented Design Heuristics

Description:

Title: Object Oriented Design Heuristics Author: Fakhar Lodhi Last modified by: mona Created Date: 5/18/2003 8:12:07 PM Document presentation format – PowerPoint PPT presentation

Number of Views:88
Avg rating:3.0/5.0
Slides: 4
Provided by: Fakh4
Category:

less

Transcript and Presenter's Notes

Title: Object Oriented Design Heuristics


1
private double amountFor(Rental aRental) return
aRental.getCharge()
  • initially replace the body with the call
  • remove this method later on and call directly

while (rentals.hasMoreElements()) double
thisAmount 0 Rental each (Rental)
rentals.nextElement() thisAmount
each.getCharge() the rest continues as
before
2
frequent renter points
  • Lets do the same thing with the logic to
    calculate frequent renter points
  • extract method
  • each can be parameter
  • frequentRenterPoints has a value before the
    method is invoked, but the new method does not
    read it we simply need to use appending
    assignment outside the method.
  • move method
  • Again, we are only using information from Rental,
    not Customer, so lets move getFrequentRenterPoint
    s to the Rental class.
  • Be sure to run your test cases after each step

3
// add frequent renter points frequentRenterPoint
s // add bonus for two day new release
rental if ((each.getMovie().getPriceCode()
Movie.NEW_RELEASE)
each.getDaysRented() gt 1) frequentRenterPoint
s // show figures for this rental result
\t each.getMovie().getTitle() \t
String.valueOf(thisAmount)
\n totalAmount thisAmount // end while
Write a Comment
User Comments (0)
About PowerShow.com