0
0
LLDsystem_design~20 mins

Product, Cart, Order classes in LLD - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Master of Product, Cart, Order Classes
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Identify the primary responsibility of the Order class

In a simple e-commerce system, what is the main responsibility of the Order class?

AStore details about a completed purchase including products, quantities, and payment status
BCalculate discounts and promotions for products in the cart
CHandle adding and removing products before checkout
DManage the list of products a user wants to buy and their quantities
Attempts:
2 left
💡 Hint

Think about what happens after a user completes their purchase.

Architecture
intermediate
1:30remaining
Choose the best class to calculate total price

Which class should be responsible for calculating the total price of all products including quantities and discounts?

AProduct class, because it knows the price of each item
BOrder class, because it represents the finalized purchase
CCart class, because it holds all products and their quantities before purchase
DA separate PricingService class, to keep pricing logic outside data classes
Attempts:
2 left
💡 Hint

Consider where the products and quantities are managed before checkout.

scaling
advanced
2:00remaining
Scaling the Cart for many users simultaneously

When many users add products to their carts at the same time, which design approach best ensures performance and data consistency?

AStore carts only in the database and query on every user action
BUse a global lock to allow only one cart update at a time
CStore all carts in a single shared database table with row-level locking
DKeep each user's cart in a separate in-memory cache instance with periodic database sync
Attempts:
2 left
💡 Hint

Think about fast access and avoiding bottlenecks for many users.

tradeoff
advanced
2:00remaining
Tradeoff between storing product details in Cart vs referencing Product IDs

What is a key tradeoff when the Cart stores full product details versus only product IDs with quantities?

AStoring full details increases data duplication but allows faster access without extra queries
BStoring only IDs causes data duplication but reduces database queries
CStoring full details reduces memory usage but requires more network calls
DStoring only IDs increases data duplication and slows down price calculations
Attempts:
2 left
💡 Hint

Consider data duplication and access speed.

component
expert
2:30remaining
Estimate capacity for Order processing system

Your e-commerce system expects 10,000 orders per minute at peak. Each order has on average 5 products. Estimate the minimum number of database writes per second needed to store orders and order items.

AApproximately 50,000 writes per second
BApproximately 3,000 writes per second
CApproximately 833 writes per second
DApproximately 10,000 writes per second
Attempts:
2 left
💡 Hint

Calculate total writes considering one write per order and one per product item.