Appearance
Lesson 5 Practice — Shopping Cart Collaboration
Create:
text
ZCL_CART_ITEM_###
ZCL_SHOPPING_CART_###
ZCL_ABAP_L05_PRACTICE_###Cart Item
Private state:
text
product_code
name
unit_price
quantityMethods:
text
constructor
increase_quantity
get_quantity
get_line_total
get_product_codeRules:
text
price >= 0
quantity >= 1Shopping Cart
Store a table of references to ZCL_CART_ITEM_###.
Methods:
text
add_item
get_item_count
get_totalget_total must ask each item for get_line_total.
Questions
- Why is line total derived rather than stored?
- Why does Cart store references?
- Which class owns quantity validation?
- What is a private helper method useful for?
- Why is a generic public setter for every field often a weak API?