Courses / Machine Coding and Low-Level Design in TypeScript / Chapter 20
Module 8 · Design problems V: shopping, Q&A and restaurants · Chapter 20 of 28
Question and Answer Site: Posts, Votes, Reputation and Moderation
Builds on Solving a Design Problem: Requirements to Tested Code in Six Steps, Design Patterns in TypeScript: Creational, Structural and Behavioural, Parking Lot: Floors, Spots, Tickets and Fees and Online Shopping Store: Catalogue, Cart, Orders and Shipments. Next up: Restaurant Management: Tables, Orders, Kitchen Tickets and Bills.
Part 1 · Requirements
What the site must do
A question and answer site is a pile of posts held together by a few rules: one vote per member, a reputation that means something, and a way to stop bad posts. This chapter builds a small one 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. Every rule about points is "in our model": real sites choose their own numbers, and none of this describes a particular site.
- A member asks a question with a title, a body and one to five tags, which are short labels such as
arrays. Other members post answers. Anyone may comment on a post. - A member votes a question or an answer up or down. Each member has one vote per post, cannot vote on their own post, and can change or take back a vote.