The Machine-Coding Framework
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. Clarify scope — 10 minutes
Write accepted inputs, expected outputs and excluded features.
- 2. Find entities — 10 minutes
List nouns, responsibilities and ownership.
- 3. Draw two views — 10 minutes
Draw types and one core interaction.
- 4. Choose patterns — 5 minutes
Find variation before choosing an interface.
- 5. Write skeletons — 10 minutes
Compile the types, then run a tiny end-to-end path by minute 45.
- 6. Complete the core flow — 25 minutes
Replace the tiny path with the required behaviour.
- 7. Protect shared work — 10 minutes
Identify locks, ownership and shutdown.
- 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.
| Mistake | Fix |
|---|---|
| Drawing until time runs out | Stop each stage at its timebox. |
| Adding every known pattern | Name the specific variation first. |
| Delaying integration | Run a tiny path by minute 45. |
| Locking everything | Protect 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.
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.
Keep a visible timebox
A candidate spends 50 minutes on a perfect hierarchy. The printer queue never runs.
Five minute markers move from scope at zero to a runnable queue at 45 and a demo at 90.
Use the skeleton stage to connect one producer to one worker. Complete the queue behaviour during the next stage.
The insight
Working code beats a perfect diagram.
Add home visits
The clinic already chooses a visit location through an interface. Now you need home visits.
package clinic
type Location interface{ Address() string }
type Clinic struct{ Street string }
func (c Clinic) Address() string { return c.Street }
// Added for the extension; callers still accept Location.
type Home struct{ Street string }
func (h Home) Address() string { return h.Street }
Add a booking rule that chooses Home for home visits. The appointment flow still accepts Location.
The insight
Interfaces at points of variation keep extensions small.
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
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.