The architectural cost of a design decision
An undo button takes ten seconds in Figma. What it costs in architecture, and why design and engineering are deciding the same things.
One of my favourite things to think about in software engineering is the undo button.
Not because there’s anything particularly fascinating about an arrow pointing anticlockwise, but because of the sheer disparity between the effort it takes to design one and the effort it sometimes takes to engineer one.
Open Figma. Grab an icon. Position it somewhere in the toolbar.
Ten seconds, perhaps fifteen if you’re particularly indecisive about the icon.
Now go and implement it in an application with collaborative editing, asynchronous operations, persistent storage and hundreds of potentially reversible actions.
Good luck.
I’ve always found this disparity quite interesting because it exposes something fundamentally odd about how we organise the production of software.
We tend to treat design as the discipline responsible for deciding how software should look and behave, and engineering as the discipline responsible for making those decisions work.
On paper, it sounds perfectly reasonable.
In practice, some of the most consequential architectural decisions in an application begin their lives as incredibly innocent design decisions.
A button that changes everything
Imagine we’re building a simple image editor.
We have a canvas, a collection of objects, and the ability to manipulate their properties.
Our initial document model might look something like this:
type CanvasObject = {
id: string;
x: number;
y: number;
width: number;
height: number;
rotation: number;
};
type Document = {
objects: Record<string, CanvasObject>;
};
To move an object, we update its coordinates.
function moveObject(
id: string,
x: number,
y: number
) {
document.objects[id].x = x;
document.objects[id].y = y;
}
Nothing particularly interesting here. We mutate some state and the interface reflects that state.
Then somebody says:
“Wouldn’t it be nice if users could undo their last action?”
And what an innocent thing to say.
Suddenly, the current state of the application is insufficient. We also need knowledge of its previous states, or enough information to reconstruct them.
We’ve gone from modelling what exists to modelling what happened.
That distinction has considerable architectural implications.
One approach is to retain snapshots of the document.
type History<T> = {
past: T[];
present: T;
future: T[];
};
Each meaningful modification produces a new immutable state. Undo moves the current state into the future and restores the most recent previous state.
function undo<T>(history: History<T>): History<T> {
if (!history.past.length) return history;
const previous =
history.past[history.past.length - 1];
return {
past: history.past.slice(0, -1),
present: previous,
future: [
history.present,
...history.future
]
};
}
For a sufficiently small application, this is perfectly reasonable. With structural sharing, immutable snapshots can also be considerably more memory-efficient than repeatedly cloning an entire document.
But what happens when the document contains thousands of objects? What happens when those objects reference large image buffers? How frequently should we capture a snapshot?
And perhaps the most interesting question: what constitutes an action?
If I drag an object from one side of the canvas to another, I’ve potentially generated hundreds of pointer events.
Should pressing undo reverse a single pointer movement?
Of course not.
As a human, I performed one action. I moved an object.
As a machine, we processed hundreds of state changes.
There’s a fundamental disconnect between the granularity of computation and the granularity of human intention.
And I think bridging that disconnect is one of the more fascinating responsibilities of interface engineering.
Engineering human intention
An alternative approach is to model changes as operations or commands.
Rather than exclusively preserving the resulting state, we preserve a description of the action that produced it.
type Position = {
x: number;
y: number;
};
type MoveCommand = {
type: "move";
objectId: string;
before: Position;
after: Position;
};
Now we can execute and reverse a movement.
function applyMove(
document: Document,
command: MoveCommand,
direction: "forward" | "backward"
) {
const position =
direction === "forward"
? command.after
: command.before;
const object =
document.objects[command.objectId];
if (!object) return;
Object.assign(object, position);
}
But more importantly, we can separate transient interaction state from meaningful document mutations.
While a user drags an object, we render a temporary position. When they release it, we commit one operation representing the entire movement.
let drag: {
objectId: string;
origin: Position;
current: Position;
} | null = null;
function onDragStart(
objectId: string,
position: Position
) {
drag = {
objectId,
origin: { ...position },
current: { ...position }
};
}
function onDragMove(position: Position) {
if (!drag) return;
drag.current = position;
renderPreview(drag.objectId, position);
}
function onDragEnd() {
if (!drag) return;
commit({
type: "move",
objectId: drag.objectId,
before: drag.origin,
after: drag.current
});
drag = null;
clearPreview();
}
Now an undo action reverses something meaningful to the human using the application.
Notice that this isn’t merely a performance optimisation or an exercise in better state management.
We’ve made an architectural decision based on our understanding of human cognition.
We understood that a person perceives dragging an object as one continuous action rather than a collection of individual events, so we engineered a system that respects that perception.
This is where I find the distinction between UX and engineering particularly difficult to justify.
Who owns that decision?
Is it the designer because it concerns human behaviour?
Or the engineer because it concerns the architecture of state?
Surely it’s both.
What happens when there’s another human?
Now imagine we introduce collaboration.
Two people are manipulating the same document. One moves an object from coordinate 10 to coordinate 20. Another subsequently moves it from coordinate 20 to coordinate 50.
The first person presses undo.
Where should the object go?
Back to coordinate 10? That would effectively erase the other person’s contribution.
Back to coordinate 40? That would reverse the first person’s relative movement while preserving the subsequent displacement.
Should the operation be rejected because the object has changed since the original action?
Should undo be scoped to the user’s own operations? Should the experience communicate when an action can no longer be meaningfully reversed?
There isn’t a universally correct answer.
Different collaborative systems implement different semantics for undo, and different types of operations require different approaches. A relative translation might be reasonably reversible, whereas deleting an object somebody else has since modified introduces a considerably more complicated conflict.
Operational transformation and conflict-free replicated data types can help distributed clients converge on shared state. But convergence alone doesn’t tell us what undo ought to mean to a human being.
That’s a product decision.
And that product decision informs the choice of architecture.
This is why I get somewhat uncomfortable when we talk about software architecture as though it’s an exclusively technical discipline.
Good architecture cannot be determined independently of what the application is supposed to feel like.
You could build a remarkably elegant distributed system that converges perfectly and still delivers a collaboration experience that makes absolutely no sense to the people using it.
The data is correct.
The experience is wrong.
Not every operation deserves the same architecture
During my time as a founding engineer at NEX, I worked on the frontend architecture of an AI-powered creative platform, including an interactive canvas editor, generative tooling and image manipulation experiences.
Creative software is a particularly interesting category of software because it exposes the limitations of treating every interaction as a conventional application state update.
Consider an image editing application that allows a user to paint over an area to create a mask for an image generation operation.
Conceptually, we’re asking the application to do several different things.
We want the brush movement to feel immediate. We want the resulting mask to be accurate. We want to preserve the user’s editing history. We want to submit the operation to a remote generation service. We might also want to cancel it, retry it or compare the generated result against the original.
Those concerns operate at completely different frequencies.
Pointer movements can occur many times within a single second. Persistent document changes happen considerably less often. Remote image generation could take several seconds or longer.
If we funnel all of these concerns through the exact same state update mechanism, we risk coupling the responsiveness of the interaction to unrelated parts of the application.
A more considered architecture might separate them like this:
The high-frequency interaction remains responsive without requiring every pointer movement to become a durable document mutation or trigger a full interface update.
The remote generation process has its own lifecycle and failure semantics.
This architecture isn’t inherently superior in every application. But in an interactive editor, these distinctions are often necessary consequences of the experience we’re trying to deliver.
The user should be able to continue painting while unrelated interface components remain stable.
The user shouldn’t have to understand the rendering architecture to interact with a brush.
They should just paint.
The cost of making something cancellable
Another interesting example is cancellation.
Let’s imagine somebody designs a file upload interface with a cancel button.
Again, an incredibly innocent design decision.
From an engineering perspective, what exactly are we cancelling?
Are we aborting the client’s network request?
Are we stopping the server from processing the upload?
Are we deleting partially uploaded data?
Are we releasing resources allocated by an asynchronous worker?
What if the operation has already completed by the time we click cancel?
We might initially implement something like this:
const controller = new AbortController();
async function upload(file: File) {
await fetch("/api/uploads", {
method: "POST",
body: file,
signal: controller.signal
});
}
function cancel() {
controller.abort();
}
And yes, we’ve introduced the ability to abort the client’s fetch operation.
But we haven’t necessarily cancelled the underlying operation on the server.
If the server has already received the request and queued work, that work might continue independently of the browser.
The human thinks they’ve cancelled an operation.
The engineer has cancelled a network request.
These are not necessarily the same thing.
If cancellation is a genuine product requirement, we may need a server-side job identifier, explicit cancellation semantics, cleanup mechanisms and a lifecycle that accounts for races between completion and cancellation.
type JobState =
| "queued"
| "running"
| "cancelling"
| "cancelled"
| "completed"
| "failed";
The interface needs to distinguish between requesting cancellation and receiving confirmation that the operation has been cancelled.
Otherwise, we’re effectively lying to the user.
And all of this began because somebody put an X next to a progress bar.
The false economy of the handoff
This is where I think traditional design-to-engineering handoffs can become particularly expensive.
Imagine a product has been designed for several months before the engineers responsible for building it have meaningfully interrogated the interaction model.
We’re now discovering that the seemingly straightforward experience requires substantially different infrastructure from the infrastructure we had anticipated.
There are two common outcomes.
We simplify the experience to accommodate the existing architecture.
Or we introduce considerable architectural complexity to accommodate the proposed experience.
Neither outcome is inherently wrong. Software involves compromises, and sometimes those compromises are entirely appropriate.
But I wonder how many of them could have been avoided if the design and engineering considerations had evolved together.
I don’t think every designer needs to understand distributed systems. Equally, I don’t think every engineer needs to become exceptionally talented at visual design.
Specialisation is valuable.
What I do think is that we need more people who can understand the relationship between the two.
People who can look at an interaction and understand its architectural consequences.
People who can look at an architectural constraint and imagine a better interaction around it.
Because sometimes the best engineering solution is a slightly different design decision.
And sometimes the best design solution is a considerably different engineering decision.
APIs as interaction contracts
One of the more interesting consequences of all this is how we think about APIs.
We often design APIs around the structure of our databases or the relationships between our entities.
And that’s understandable.
But a well-considered API should also reflect the operations that matter to the people interacting with the application.
Consider an endpoint that updates a document:
PATCH /documents/123
It’s flexible. We can send any supported modification to that document.
But imagine the product requires granular history, collaborative editing, retries and conflict detection.
An operation-oriented interface might become considerably more useful.
POST /documents/123/operations
{
"operationId": "op_84a1",
"baseRevision": 42,
"type": "object.move",
"objectId": "obj_17",
"delta": {
"x": 24,
"y": 12
}
}
The server can now reason about operation identity, revisions and intent. With appropriate implementation, it can deduplicate retries or detect conflicts.
This doesn’t automatically make the API collaborative or fault-tolerant. Those guarantees still need to be engineered.
But we’ve introduced a contract that gives us the vocabulary to express them.
The API architecture now reflects something about the experience we want to deliver.
That’s quite a different starting point from simply exposing the database to the frontend.
Design is not the decoration of engineering
I think one of the more unfortunate consequences of our industry separating design from engineering is the tendency to perceive design as something that happens to software rather than something that fundamentally defines it.
Design isn’t the rounded corner we introduce after engineering the button.
It’s the decision that the button exists. The decision that clicking it represents a particular intention. The decision about whether that intention is reversible, interruptible, optimistic, destructive or collaborative.
Engineering establishes the conditions under which those decisions can become reality.
They’re both concerned with the same thing.
Making software behave in a way that makes sense to a human being.
And the next time somebody adds an undo button to a Figma file, perhaps spend a little more time interrogating what it actually means.
Because somewhere inside that beautifully insignificant little arrow might be an entirely different software architecture.
— Adenekan
