I Know What I Need, But I Don't Know How To Build It
Pick the thing you need. Then derive it: meaning, state, operations, rules, examples, representation, pseudocode — and only then the code, one rung at a time.
“I know I need a shopping cart. I have no idea how to implement a shopping cart.” The gap is not a missing tutorial; it is a missing method. Every stage below asks you to write before it shows you anything, because the code is the last step of a derivation, not the first thing to search for.
Which concept?
Grouped by exercise level; the level is how far the derivation goes, not how hard the code is.
How much help?
Every stage's content is shown right after your attempt box.
Job Queue — twelve stages
I know I need a job queue — send the email later, resize the image in the background, retry the webhook. I have no idea how to implement a job queue.
Define the concept
In one sentence, without any code: what is it? Then answer for yourself — does it have identity, who owns it, how long does it exist, should it survive a reload or a login?
Job Queue = A holding place for units of work that will be performed later by a worker, each unit tracked from waiting to finished so that none is done twice at once and none is forgotten.
- Does a job have identity? Yes. Two "send welcome email to alice" jobs are two jobs — or should be one, which is a deduplication rule the queue does not have by default. A job needs an id from the first version because ack and fail have to name one.
- Who owns it? The queue owns the job's state; the producer that enqueued it owns its meaning; a worker owns it only while it is running, and that ownership is what "at most one worker at a time" protects.
- How long does it exist? From enqueue until it is done or has failed for the last time. Whether a done job is kept for inspection is a retention decision; V0 keeps everything, V2 keeps rows with a status, V4 moves the permanently failed ones to a dead-letter list.
- Should it survive reload? Yes — that is most of the point. A job lost when the process restarts is a welcome email nobody gets. The queue is persistent from V2, and "never lost" is only a rule from then on.
- Who may run it? Any worker, but only one at a time. Which worker is not part of the job's identity; that a worker holds it is part of its state.
The catalog is one derivation, not the only one (impl §60). A different set of examples yields different rules; a different first requirement yields a different V1; a map instead of an array is not wrong, only an answer to a different question. Compare your derivation with the reference for the differences, then decide which ones were rules and which were style.
Take it further
The flagship exercise: the cart typed by you, with the reference hidden until you ask.
Make It Smaller Until You Know How to Build It →The principle behind the ladder, and the primitive chain it produces.
The Implementation Loop →The loop the twelve stages follow, and why the code is last.