Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cart vs Order

 
fahd helwani
Ranch Hand
Posts: 67
Android Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

as I'm finalizing my assignment solution I got this doubt that I need some help clearing it.

I've got a SFSB that represents a shopping cart, and I've added an entity bean that represents an order. each of these two classes has its own relations to other objects, what I'm thinking about is if I can remove the shopping cart class and consider a shopping cart an instance of Order class that is not yet paid for (or persisted), and do the needed changes to the type of this class so it can be persisted, would you consider this as good condensed design approach?

I feel that keeping two classes for shopping cart and order is redundant to some extent: they both share similar qualities and functionalities, although also keeping them separate is a practice of separation of concerns.

what do you think guys?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34178
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What makes them the same? The fact that they share data? I can think of methods that would be different between the two. For example, you can't remove an item from an order or ship a shopping cart.
 
Yegor Bugayenko
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fahd, I did exactly as you are saying. Class Order is JPA persistent, and is managed by stateless session bean. This mechanism is more scalable since SFSB are not as scalable as HTTPSession.
 
fahd helwani
Ranch Hand
Posts: 67
Android Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you guys for your feedback,

I kept these two classes separate, that's cleaner than having these two as one class.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic