Courses / Machine Coding and Low-Level Design in TypeScript / Chapter 19
Module 8 · Design problems V: shopping, Q&A and restaurants · Chapter 19 of 28
Online Shopping Store: Catalogue, Cart, Orders and Shipments
Builds on Solving a Design Problem: Requirements to Tested Code in Six Steps, Design Patterns in TypeScript: Creational, Structural and Behavioural and Parking Lot: Floors, Spots, Tickets and Fees. Next up: Question and Answer Site: Posts, Votes, Reputation and Moderation.
Part 1 · Requirements
What the store must do
A shopping site looks like a list of products and a button, until two customers want the last unit and a card is declined halfway through. This chapter builds a small online store for kitchenware, from catalogue to delivery, as classes you can run and test.
A requirement is a sentence about the system that someone can check. Functional requirements say what the system does, and we write them before any class exists. For the store, they are these.
- The catalogue lists products. Each has a SKU (stock keeping unit, the store's own code for one product), a name and a price. A customer searches by words from the name.
- A customer keeps a cart: products and quantities. Checking out turns the cart into an order.
- Each product has a count of units on the shelf. Checkout holds the units that the order needs, so nobody else can buy them.
- A coupon takes something off the order: a flat amount above a minimum, or a percentage up to a cap.