• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

LineItem class in Cade's class diagram

 
Peter Bergoff
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In regards to the LineItem class in Cade's SCEA Study Guide in the case study (pg. 169):

Can someone help explain the logic of the LineItem class? Without any explanation in the use cases when a user is searching for a product and selects to add it to the shopping cart the product is referenced as an "item" - hence I assume the new class "LineItem". It seems confusing to reference the same thing using 2 different words - product vs. item.

Why wasn't a direct link between product and order done instead?

Thanks.
 
Peter Bergoff
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looking at "Applying UML and Patterns ..." by Craig Larman I see a similar example which I think explains lineitem - i.e. a class to show the quantity of an item purchased. However, still wondering about the switch from product to item. A customer buys products which are then referenced as items once bought - or so it appears although never stated.
 
C Chavan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lineitem is closely related to order (or invoice) (order contains lineitem) whereas product has its own seperate identity.

lineitem is comprised of product, quantity, price etc.
 
Peter Bergoff
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So if you only have one item instead of multiple items in lineitem would you still need it? Here's where I'm going with this:

It appears that when a product is assoicated to an order it's called an item. When it's not part of an order it's called a product.

Thoughts?
 
Ramon Gill
Ranch Hand
Posts: 344
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter,
Products and LineItems are two completely different entities. LineItems have an association with Products to get relevant information (e.g. product description, price) rather than having to store it itself. Product could be used by other entities in the same way (e.g. a Catalogue entity).
You need to have a way of capturing the qty of a product for an Order. LineItem does this.

Hope this helps.

Ray
SCJP, SCWCD, SCBCD, SCEA (part-1), IBM-484, IBM-486
 
Peter Bergoff
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What if the maximum quantity an order could have of any unique product was one? Would LineItem still be necessary or could a direct association between Order and Product then be made?
 
Ramon Gill
Ranch Hand
Posts: 344
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would still have LineItem. LineItem is part of a Sale, Product is not. If 2 people each bought 1 apple, I would want each order to have a line item of 1 apple (i.e. 2 apples sold in total). Product has a separate purpose to LineItem. It gives details such as description, price, etc. It is not part of a sale. It can be used for many other purposes. A LineItem will acess Product to get information rather than store it itself.

Ray
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic