Post

In Parts We Think

On building complex systems when you no longer write the code.

In Parts We Think

We don’t write code anymore. The model does. It is fast, it writes a lot, and for a while it feels like the job got easier.

Then my project got big. It was a backend service, and at some point the model lost sight of the whole thing. So did I. I could not picture the system and its components. I did not know where the bottlenecks were, or how to fix what was blocking us. Whether the problem was performance, the data model, a library it picked, or the design itself, the model would confidently say it was blocked with no way around it, and I had nothing to answer with.

There were features in my own project that I did not know existed, because the model created them: extra endpoints, caching and retry layers, fallbacks that hid errors, config nobody asked for. My vision and the model’s vision were at odds, and the model’s was the one in the code.

Is working code a working result?

Should I trust that what the model chose is the best result? Maybe there was a better one with a simpler architecture, and I had no way to tell. And now that it is built, how do I move it from here to somewhere else and account for every part? I could not tell that either.

The tests did not help much, because the tests were the model’s beliefs. It wrote the code, wrote what it believed the code should do, and checked one against the other. I did not even know what it meant for a test to pass or fail. A test checks for working code, or for code that used to work. But is working code the same as a working result?

A more powerful model does not solve this. It can build more, and I still cannot hold more in my head.

In parts

So we changed how we work. We think in parts.

We divide the system into smaller parts, each one small enough that one person can reason about it through and through. Why is it needed? What goes in, what comes out, what does it promise? The test is simple: can you swap it for another one without touching the rest? If you can, it is a real part. If you cannot, it is still tangled with its neighbours, and we cut again.

Then we reason about a collection of parts, and the inside of each one is opaque. I only need the contract. The model can write the inside, rewrite it, and pick whatever algorithm it wants. As long as the contract holds, the details can stay with the model.

How the parts are found

You find the parts as you go. The model produces, a person reasons about it and suggests changes, and after a few rounds the boundaries are clear. The important thing is how that ends: a person owns the output and understands how it works.

You need more than one person for an extensive project, and even one person has to focus on one aspect of it. So each of us holds a few parts completely, and we share the contracts between them. It is like construction, where labour and decisions are well defined: the architect lays no bricks and still answers for the building. Here the model is the labour, and the decisions are ours.

Where the thinking went

The thinking we used to do in code, we now do in parts and the contracts between them. If you take one thing from this: understand the contracts and interfaces of your system. You may never read what is behind them, and that is fine, because the interface is where you can tell what a change will break.

The model will build what you ask, and more than you ask. Keep your own picture of the system, part by part. That is how you notice when its picture is no longer yours.

This post is licensed under CC BY 4.0 by the author.