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.
Realtime Chat — twelve stages
I know I need chat between users. I have no idea how to implement messages that arrive in order, reach everyone, and remember what each person has read.
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?
Realtime Chat = A conversation is a shared, ordered sequence of messages between a fixed set of participants, where each participant separately knows how far they have read.
- Does a conversation have identity? Yes, strongly. Two conversations with the same participants are still two conversations — a group chat and a re-created one after leaving are different threads. It needs an id from the start, because every message points at it.
- Does a message have identity? Yes. Two messages with the same text from the same sender one second apart are two messages. The identity is (conversation, sequence number), and that pair is also its position — identity and order are the same fact.
- Who owns it? The participants jointly own the conversation; each sender owns their messages; each participant owns their own read state. Nothing here has a single owner, which is why the server, not any one client, is the authority on order.
- How long does it exist? Until it is deleted, which V1 does not do. Messages are the history; a chat without history is a phone call.
- Should it survive reload? Always. A chat that forgets its messages on reload has no history, and history is the product. In-memory V1 exists only to get the ordering right before persistence is added.
- Should it survive login? The conversation does; the subscription does not. Being connected is a property of a session, not of a participant — a participant who is offline is still a participant, and every message still counts as undelivered to them until they fetch it.
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.