In a pricing system, a customer can apply a 10% discount coupon and a $5 fixed discount coupon. Which order of applying these discounts results in the lowest final price?
Think about how percentage discounts affect the price after fixed discounts.
Applying the 10% discount first reduces the base price, then subtracting $5 results in a lower final price than the reverse order.
Which component design best supports validating multiple coupon types (percentage, fixed amount, buy-one-get-one) in a scalable pricing system?
Consider maintainability and adding new coupon types in the future.
Using separate validator classes with a common interface allows easy extension and testing of each coupon type independently.
Your e-commerce platform expects a sudden surge of 1 million coupon redemptions in one hour during a sale. Which approach best ensures system reliability and prevents coupon overuse?
Think about balancing consistency and performance under high load.
Distributed counters with eventual consistency and retries allow high throughput while minimizing contention, preventing overuse without blocking requests.
Should coupon expiry be checked at coupon issuance or at order checkout? What is the main tradeoff?
Consider user experience and system performance impacts.
Checking expiry at checkout ensures coupons are valid when used but may add latency; checking only at issuance risks expired coupons being accepted later.
Your system logs every coupon redemption with user ID, coupon ID, timestamp, and order ID. Estimate the storage needed per day if you expect 500,000 redemptions daily. Assume each log entry is 200 bytes.
Multiply number of entries by size per entry and convert bytes to GB.
500,000 entries * 200 bytes = 100,000,000 bytes ≈ 100 MB per day.