Design the Data and the Features Together
In the last essay I argued that every to-do app is the same list, and that the interface is mostly a reformatting of the data underneath. The obvious conclusion is to design the data first, get it right, and build the app on top. I tried that. It doesn’t work either, and working out why changed what I mean by designing the data.
What designing the data means
Designing the data is deciding what the system knows. Which facts it keeps, what they’re called, how they connect. A task has a mark for started, a mark for whether it matters, and a date, and it sits under an area.
But you can’t decide that on its own, because the app can only do what the data can say. “Show me what’s started” is a feature. The started mark is the data that makes it possible. With no dates in the data there’s no calendar, however good the screen looks. So designing the data is really designing what the app can do, written down in a form that outlives any screen.
Three layers, not two
I used to split a system into data and application. It’s cleaner to see three layers:
- Data is what it knows. It lasts for years.
- Features are what it can do. They move with the data.
- The interface is how it looks. It changes whenever I get bored.
The interface is the surface from the last essay: a reformatting that sits on top and can be replaced without touching anything underneath. Data and features are the pair that has to be designed together.
Two ways to get it wrong
Data first. You design the perfect schema before you know what the app will do. Then the first feature needs something the data can’t say, like whether a task is started, or which of two dates is the real one. So you bolt it on in the app, a flag here and a special case there, where you can’t see it from the data. The schema you were proud of is now wrapped in exceptions.
Screens first. You design the interface, and the data becomes whatever the screens happened to need. It works until the next redesign. Then you find the data is shaped like last year’s screens, and changing the surface means migrating everything under it. That’s the trap the last essay was about.
What Lisp knew
Paul Graham describes the alternative in Programming Bottom-Up: “In Lisp, you don’t just write your program down toward the language, you also build the language up toward your program.” You write some of the program, notice what the language is missing, add it, and the next part of the program gets shorter. “Language and program evolve together.”
His image for it is the one I keep coming back to: “Like the border between two warring states, the boundary between language and program is drawn and redrawn,” until it settles along the natural frontiers of the problem.
Swap the words and it describes data and features. The data is the language. The features are the program written in it. Design the data, design the features, together, and let the border between them move until it stops moving. The interface stays out of that fight. It gets built on whatever the border settles into.
What that looks like
The format in the last essay was built this way. I didn’t sit down and design it. I started with one feature, a list of what to do today, and the smallest data that could support it. Today needed to know what was already started, so the data got a mark for started. The calendar needed dates, so lines got a date. When the data got awkward to read by hand, I changed the feature instead. Each side pushed on the other until neither needed anything new.
A few rules came out of it:
- Start with one feature and the least data that supports it.
- When a feature needs something the data can’t say, change the data. Don’t hide the fix in the app.
- When the data gets hard to read on its own, change the feature. Don’t add fields to make one feature easier.
- The data has to make sense without the app. If you can’t read it in a text editor, the app has leaked into it.
- Keep the interface out of both. If a screen needs something, it asks through a feature.
- Stop when the border stops moving.
Hackathons teach this whether you want it or not. There’s no time to finish the schema before the demo, or the demo before the schema. The teams that do well decide what the thing does and what it needs to know in the same first hour, and keep both rough until the end.
Graham says bottom-up design “yields programs which are smaller and more agile,” and that it “makes programs easier to read.” I’d say the same about data designed next to its features. It stays small because nothing goes in that a feature didn’t ask for. It stays readable because the screen isn’t allowed to carry the meaning. And when I get bored and build a new surface, the data and features are still the right shape, because they were never shaped by one surface.
Most of designing them together turned out to be cutting. That deserves its own essay: Removing Bullshit.