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.
Simple Search — twelve stages
I know I need search. I have no idea how to implement search — is it a search engine?
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?
Simple Search = Given some words a person typed, find the products whose names those words describe.
- Does a search have identity? No. A search is a question asked of the catalog, and the answer is computed each time. Two identical queries are the same question. The *products* have identity; the search does not, which is why V0 is a function and not a thing that is stored.
- Who owns it? Nobody owns a search; the catalog owns the products it runs over. When saved searches or search history arrive, *those* have an owner — a different concept.
- How long does it exist? For the duration of one call. Nothing persists — until V4, when an index is built ahead of time, and then the index has a lifetime and can go stale.
- Should it survive reload? The query in the URL should, so a result page can be shared; the results are recomputed. That is a frontend decision, not part of the concept.
- Is it a search engine? Not yet, and probably never. A search engine is a V6 answer to problems — fuzzy matching, ranking across fields, millions of documents — that a catalog of a thousand products does not have. Start with the loop.
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.