File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Cart vs Order Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Cart vs Order" Watch "Cart vs Order" New topic

Cart vs Order

fahd helwani
Ranch Hand

Joined: Jul 18, 2006
Posts: 63

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?

SCJP 5 (80%), SCWCD 5 (85%), SCBCD 5 (80%), CAPM, SCEA/OCMJEA
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33134

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.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Yegor Bugayenko
Ranch Hand

Joined: Feb 11, 2011
Posts: 80
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.

SCEA, PMP, read my blog:
fahd helwani
Ranch Hand

Joined: Jul 18, 2006
Posts: 63

thank you guys for your feedback,

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

I agree. Here's the link:
subject: Cart vs Order
It's not a secret anymore!