• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

simple question for u! - Urgent

 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A object model for a eCommerce site would likely to have a Order class.
would u implement something like order.getPrice() to get the total price for the order.
or would u have a OrderHandler object to calculate the price for the Order???
thx
 
Marshal
Posts: 17009
298
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The main thing to remember is that there really is no "right" or "wrong" although I doubt that getPrice() is an appropriate name for any of the responsibilities you normally assign to an Order class. It should probably be getTotalAmount() or simply getTotal(). getPrice() sounds like a responsibility you'd give to an Item class.
What you really should ask yourself is whether it make sense to assign a responsibility to a certain object. Use Craig Larman's GRASP patterns discussed in his book "Applying Patterns and UML", the Law of Demeter and other OO design principles to guide you on what you should.
Junilu
[ June 02, 2002: Message edited by: Junilu Lacar ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic