System Design Academy

Saving…

Lesson 1 of 7 in Module 50 of 45 lessons complete

The Machine-Coding Framework

Module 5, lesson 1Concept15 min

Definition

Machine-coding framework

In plain English
A machine-coding framework is a fixed sequence of steps for turning a problem statement into working, well-structured code under time pressure.
Think of it like
It is like a pilot's pre-flight checklist that keeps you calm and thorough.

Why it exists

You have 90 minutes. You spend 60 drawing types, then discover that nothing runs.

Or you write a 400-line main function. One new requirement forces changes across the whole program.

How it works

Core flow

In plain English
A core flow is the one or two most important user journeys the design must support, such as placing an order.
Think of it like
It is like the main road through a town.

Extension question

In plain English
An extension question is a new requirement an interviewer adds near the end to test whether your design bends without breaking.
Think of it like
It is like being asked to add a room to a house you built.
  1. 1. Clarify scope — 10 minutes

    Write accepted inputs, expected outputs and excluded features.

  2. 2. Find entities — 10 minutes

    List nouns, responsibilities and ownership.

  3. 3. Draw two views — 10 minutes

    Draw types and one core interaction.

  4. 4. Choose patterns — 5 minutes

    Find variation before choosing an interface.

  5. 5. Write skeletons — 10 minutes

    Compile the types, then run a tiny end-to-end path by minute 45.

  6. 6. Complete the core flow — 25 minutes

    Replace the tiny path with the required behaviour.

  7. 7. Protect shared work — 10 minutes

    Identify locks, ownership and shutdown.

  8. 8. Demo and extend — 10 minutes

    Run examples, then handle one changed requirement.

Clarify leads through entities, diagrams, patterns, skeleton, core flow and safety to a demo.

Eight steps keep a 90-minute round moving.

Clarify leads through entities, diagrams, patterns, skeleton, core flow and safety to a demo.

MistakeFix
Drawing until time runs outStop each stage at its timebox.
Adding every known patternName the specific variation first.
Delaying integrationRun a tiny path by minute 45.
Locking everythingProtect shared state and keep callbacks outside locks.

Examples

Start with nouns and verbs

Members reserve tools. Reservations expire after 24 hours.

Member, Tool and Reservation are the nouns. Reserve and expire are the verbs; an injected Clock makes expiry testable.

reservation.go — A compiling skeleton isolates the clock.
Go
package library

import "time"

type Clock interface{ Now() time.Time }
type Member struct{ ID string }
type Tool struct{ ID string }
type Reservation struct {
	Member    Member
	Tool      Tool
	ExpiresAt time.Time
}
type Service struct{ Clock Clock }

The insight

Nouns, verbs and one injected dependency get you most of the way.

Trade-offs

Pros

  • A calm, repeatable process.
  • A running core flow shows design thinking.

Cons

  • Timeboxes can feel rigid.
  • Small problems need fewer steps.

Use when

  • Interviews.
  • A new component with several responsibilities.

Avoid when

  • Trivial scripts.
  • A one-line data transformation.

Quick check

In a 90-minute round, by roughly when should something be running?
When should you introduce a design pattern?

Takeaways

  • Follow the same steps every time.
  • Get the core flow running by halfway.
  • Put interfaces where change is likely, then handle the extension question.

Try the quick check above whenever you feel ready.

Previous: Thread-Safe Design Checklist