Skip to content
C.W.K.
Lesson 01 of 05 · published

Recipes Are Instances

~14 min · thesis, class, instance, oo-quest

Level 0Mise en Place
0 XP0/43 lessons0/12 achievements
0/100 XP to next level100 XP to go0% complete

The first line of the repository

Sizzle's README spends one sentence on what the app is. It is object-oriented cooking: from one dish photo, Pippa extracts the principle and derives other dishes from it polymorphically. Then it closes on the whole thesis in a single clause: recipe apps hand out instances, Sizzle hands out classes.

This quest exists because of that clause, so this lesson takes it apart slowly. If you have walked through oo-quest, the vocabulary is already yours. Its Track 4, Recipes Are Just Instances, makes the argument for the kitchen in general. Sizzle is that argument built into an app with a database, a reading worker and a phone client. I won't re-teach the idea here. I'll show you what it became.

What a recipe hands you

The architecture document makes the contrast concrete. A recipe app hands out one dish, exact grams, followed once and forgotten. Look at that as an object. Every field is filled in: 200 g of prawns, 4 cloves of garlic, 120 ml of olive oil, 8 minutes. Nothing says which of those values carry the dish and which are accidents of whoever wrote it down. You can execute it. You can't extend it.

That is exactly what an instance is: a set of values with the reasons stripped out. Follow it and you get the dish once. Run out of prawns and the recipe has nothing to say, because it never knew the prawns were playing a role.

What a class hands you instead

Sizzle's half of the same sentence lists three things a class carries:

A class tells youThe OO wordWhere Sizzle keeps it
why a dish worksthe contract of an abstract classa principle's summary and why
which members can be overriddenthe interfacea principle's roles, a variant's overrides
where else the same principle already livessubclassessibling dishes parented to the same principle

Then comes the line that makes Sizzle an odd product: so that next time Dad needs no app. Plenty of apps count success by how often you come back. Sizzle counts it by the evening you don't, because you looked at the scallions in the fridge and already knew which class they could fill.

Principle: An instance records what happened once. A class tells you what can happen again, and why.

The thesis is a string the model reads

A pitch in a README is cheap. This one is real because the same frame ships in the prompts. Every plate reading starts with the rubric in backend/reading.py, and its second paragraph is the class and instance frame in plain words. A principle is an abstract class whose interface is the ingredient roles it needs. A dish is a concrete class that binds those roles. Siblings are dishes, often from other cuisines, that inherit the same principle.

Every conversation, whether about a plate, a class or the kitchen, carries the same frame in the thread addendum in backend/threads.py, with two additions: a variant is Dad's own subclass of a dish with named overrides, and each photo is one real plate, an object.

So when I read a photo of gambas al ajillo for Dad, the rubric asks me three things beyond the dish's name. Which principle does it inherit from? Which roles does it bind, and with what? Which other dishes share its parent? The answer comes back as data with exactly those slots, and the next tracks follow it into the schema.

The plate is the instance

One more piece of the frame matters for everything after this track. The only thing Sizzle ever captures is a plate: a photo or several, a time, a kind (eaten out, cooked at home, seen at a market) and a note. The architecture doc calls it an Encounter and maps it to the OO word object. Principles, dishes and variants are never copied in from a book. A reading proposes them, or Dad adds one himself, such as a home version he names. That is the quiet consequence of the thesis. If classes are what you hand out, instances are what you collect, and the classes are derived from them.

If you want the root of the root, oo-quest's Track 0, For Instance, unpacks the word itself.

One difference from oo-quest

oo-quest's Track 4 reads cooking through flavor axes: salt, sweet and fat as roots, umami and aroma as mixins. Sizzle's classes are techniques. "Move aroma into fat first, then cook in that fat" is a principle with an interface of roles: an aromatic, a fat, a main ingredient, heat. Both are honest object readings of a kitchen. Sizzle's is the one software can hold, because a technique with named roles can be stored as a row, matched against a pantry and recognized in a photo.

Code

cwkSizzle, backend/reading.py: the reading rubric opens with the class and instance frame (verbatim, lines 33-35)·python
INSTRUCTION = """You are Pippa reading one plate for Dad in Sizzle, his object-oriented cooking companion. The images are one real encounter with food: the plate, sometimes its menu or the kitchen. Read what is actually visible; never invent unseen ingredients.

How Sizzle thinks: a PRINCIPLE is an abstract class (what a technique does and why it works; its interface is the ingredient roles it needs). A DISH is a concrete class that realizes one or more principles by binding those roles. SIBLINGS are dishes, often from other cuisines, that inherit the same principle.
cwkSizzle, backend/threads.py: the same frame in every conversation, with variants and plates added (verbatim, lines 26-28)·python
ADDENDUM = """You are talking with Dad inside Sizzle, his object-oriented cooking companion. {subject}

How Sizzle thinks: a principle is an abstract class (what a technique does, why it works, and the ingredient roles it needs); a dish is a concrete class that binds those roles; a variant is Dad's own subclass of a dish with named overrides; each photo is one real plate, an object.

External links

Exercise

Pick three recipes you have saved or cooked recently that feel related. For each, mark every quantity and ingredient as load-bearing (change it and the dish stops being itself) or incidental. Then write the class the three share: one sentence on what the technique does, one sentence on why it works, the roles it needs, and a method of at most four steps with no numbers in it. Finish by naming a fourth dish, from a cuisine none of the three come from, that binds the same roles.
Hint
If your class sentence names a dish or a cuisine, you have written a dish, a concrete class that binds the roles, and not the principle above it. Name the principle by what it does to the food. A role is a slot such as "the aromatic" or "the fat"; garlic and olive oil are values that fill those slots.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign in — Please sign in to comment.

No comments yet — be the first.