Courses / Machine Coding and Low-Level Design in TypeScript / Chapter 6
Module 4 · Design problems I: parking, elevators and libraries · Chapter 6 of 28
Solving a Design Problem: Requirements to Tested Code in Six Steps
Builds on The Machine Coding and LLD Round: Format, Scoring and a Method, Object-Oriented Design and UML: Use Case, Class, Sequence, Activity and State Diagrams, Design Principles: SOLID, DRY, KISS, YAGNI and the Law of Demeter and Design Patterns in TypeScript: Creational, Structural and Behavioural. Next up: Parking Lot: Floors, Spots, Tickets and Fees.
Part 1 · Clarify and scope
Why the prompt is short on purpose
A design problem arrives as one or two sentences, and most of the work is deciding what those sentences mean. This chapter takes one problem, a desk booking system for a co-working space, through six steps from questions to tested code.
The six steps are the method from the first chapter, with writing tests folded into building each layer, since each layer is tested as soon as it exists.
The statement is short because the person who wrote it wants to see which questions you ask. "Design a desk booking system" can mean a ten-line script or a platform with payments, floor plans and mobile apps. If you start coding before choosing, you will build the wrong thing quickly, or the right thing too slowly to finish.
Scoping is the act of fixing what is in the problem and what is not. It has three outputs. A short list of what the system must do. A list of what it should do if time allows. And a list of what you are deliberately leaving out. Writing all three where the reviewer can see them also protects you: a rule you did not build is acceptable if you said you left it out, and a surprise otherwise.