Example

Worked example / Comparing designs

Choose between two designs by seeing both.

Before you build a feature, you often have to choose between designs with different trade-offs: store a total or work it out when asked, one shared row or many small ones. The choice decides what the app can do later and how it behaves when it is busy.

Usually you choose from a description. An agent, or a colleague, writes a paragraph of pros and cons, and you take it on trust because nobody builds both.

With an agent writing the code, building both is cheap. For programs written in the typed functional language Bosatsu, Yichus draws each design from its compiled source with the same marks, so the differences show up in the pictures. Use it to choose between designs your agent proposes, and to check that its account of the trade-offs matches the code it wrote.

01 / The app

Friends on a trip, splitting the bills.

A group adds what each person paid, and the app says who owes whom. Both designs split an expense with the same rule. They differ in when that rule runs.

Design 1: running balancesEach member’s balance is stored on the group’s row. Adding an expense updates the balances.Source
Design 2: expense logEvery expense is stored as its own row. The balances are worked out each time someone asks for them.Source

Everything inside a Yichus output frame is drawn from the code. The notes beside each pair are by the AI that wrote both designs, and Yichus did not check them.

02 / The whole service

One table, or a group and its expenses.

Loading design 1’s system map.

Loading design 2’s system map.

03 / Adding an expense

Rewrite one row, or add a new one.

Loading design 1’s tree.

Loading design 2’s tree.

04 / Reading the balances

Read the answer, or work it out.

Loading design 1’s tree.

Loading design 2’s tree.

To try this on your own designs, ask your agent to write both and draw them. Work with your agent →

Where this fits

What this is about: Lenses and diagrams