Perspectives23 November 202610 min read
Should you start over to build on solid foundations?
Sometimes a project starts without anyone really knowing what it will become.
You have an idea, an initial need, a few features to develop. You choose a suitable architecture, you start building and, gradually, the project takes shape.
Then come the new requests.
An extra feature, an integration with an external system, a new type of user, data to share between several modules…
Each change seems reasonable taken on its own.
But after a few months, sometimes a few years, you end up with a solution that still works, yet where the slightest modification becomes an adventure.
One added feature disrupts another. Components that were initially independent become interdependent. Some parts of the code are duplicated, others are so heavily used that no one dares touch them anymore.
And inevitably this question arrives:
Wouldn’t we be better off starting again from scratch?
An architecture can become unsuitable without ever having been bad #
We often talk about technical debt to explain the difficulties encountered in projects that have evolved a great deal.
But I find that expression sometimes reductive.
It can suggest that the current problems necessarily stem from poor past choices, shortcuts or a lack of rigour.
Yet that isn’t always the case.
An architecture may have been perfectly appropriate at the time it was designed.
The project simply changed.
What was meant to be an internal tool has become a platform used by several organisations. An application that was initially standalone must now communicate with other systems. A prototype meant to validate a concept gradually turns into a product.
The assumptions on which the initial architecture rested are no longer necessarily valid.
And it’s hard to blame a team for not having anticipated needs that didn’t yet exist.
We could of course try to foresee everything from the start, by designing an extremely generic and extensible architecture.
But that would introduce immediate complexity to answer hypothetical needs.
So the problem isn’t always having designed the system badly.
It’s sometimes simply having kept evolving an architecture without re-examining the assumptions that had led to its design.
Stack up or rebuild? #
Faced with this situation, two approaches come fairly naturally to mind.
The first is to keep evolving what already exists.
You add an abstraction, create an extra interface, introduce a special condition to preserve an old behaviour.
This keeps the project running and meets immediate needs.
But if every change adds new dependencies, you risk making the following ones even harder.
The second approach is more radical: start from scratch.
This time, you understand the project, its features and its constraints far better. So you could design an architecture consistent with what it has become.
On paper, it’s appealing.
But a complete rewrite carries a risk that’s often underestimated.
The existing system contains far more knowledge than its architecture reveals.
Specific behaviours were introduced to handle real situations. Exceptions were dealt with over time. Some business rules are sometimes documented nowhere other than in the code.
Rebuilding everything means finding and reproducing those behaviours, including the ones whose existence has been forgotten.
Not to mention that you often have to maintain the old solution while developing the new one.
And nothing guarantees that the needs will remain stable during that reconstruction.
So, rather than immediately choosing between stacking up and starting over, I wonder whether it wouldn’t be more interesting to begin with another question:
Do we really understand what our system has become?
Before changing the architecture, map the system #
When you examine a complex application, you often start by looking at its technical organisation.
The modules, the classes, the services, the databases, the APIs…
That’s essential, but it only tells part of the story.
Because a software architecture isn’t limited to the organisation of its code.
It must also make it possible to understand how features collaborate to produce the expected behaviours.
So I find it interesting to start with a qualitative audit of the features, then to represent their relationships as a graph.
Each feature becomes an identifiable element, connected to the others according to the nature of their interactions.
Some share data. Others use the same services. Some depend directly on the result produced by another. Others still take part in the same user journey.
Gradually, a representation of the system appears.
And I rather like to imagine it as a tree.
You can make out a trunk, main branches, secondary ramifications and sometimes tangles whose existence you didn’t suspect.
Some branches are relatively autonomous.
Others are so intertwined that it becomes hard to understand where one responsibility begins and another ends.
And a few elements seem to support a large part of the whole.
This representation doesn’t yet tell us what to modify.
But it lets us start asking the right questions.
What the graph can teach us #
Once the system is mapped, several situations can appear.
First, features that reproduce similar mechanisms.
You may discover that several branches have each developed their own user management, their own notification system or their own way of accessing data.
There may be an opportunity to pool them.
Conversely, some components have become responsible for too many different behaviours.
They concentrate dependencies that don’t necessarily have a functional reason to be brought together.
Separating them could make future changes simpler.
You can also identify central components on which many features depend.
These are often the trickiest elements to modify, because their changes can ripple through a large part of the system.
But be careful not to draw conclusions too quickly.
A highly connected graph isn’t necessarily the sign of a bad architecture.
Some dependencies are perfectly legitimate. A cross-cutting service can be used by many modules without causing any particular difficulty.
In the same way, systematically pooling similar features can create artificial coupling between domains that should remain independent.
So the graph isn’t a tool that decides for us.
It’s an analysis support.
It lets us compare the system’s current organisation against its real functional responsibilities.
And above all, it helps distinguish the areas that deserve a transformation from those that can perfectly well stay as they are.
Turning mapping into a transformation tool #
From this representation, you can start building a strategy for a gradual overhaul.
Rather than modifying the whole system at once, you identify coherent perimeters.
A relatively autonomous feature can be isolated behind a clearly defined interface.
Several genuinely common mechanisms can be grouped into a shared service.
A component that has become too complex can be gradually broken down into distinct responsibilities.
And when part of the system needs to be deeply rethought, a new implementation can temporarily coexist with the old one, while its migration is organised.
These techniques already exist in refactoring and software modernisation practices.
The value of mapping is that it lets you choose where and how to apply them.
Because not all transformations carry the same level of risk.
Modifying an isolated feature doesn’t have the same consequences as touching a central component used by a large part of the application.
The graph can help identify these differences and prioritise the interventions.
You’re no longer simply trying to obtain a cleaner architecture.
You organise its transformation while taking into account the relationships that make the current system work.
What if the graph also helped organise the tests? #
This is probably one of the most interesting aspects of this approach.
When you modify an existing architecture, the main difficulty isn’t always developing the new solution.
It’s making sure that this transformation doesn’t disrupt what used to work.
Unit tests and integration tests are obviously essential, but they aren’t always enough to reveal the consequences of a change on the system as a whole.
Suppose we want to replace a component used by several features.
If we have a map of their dependencies, we can identify the journeys likely to be affected.
We can then build a suitable validation strategy.
Unit tests check the behaviours of the modified component.
Integration tests monitor its exchanges with the other elements.
And system tests make it possible to verify that the functional journeys concerned continue to produce the expected results.
Mapping thus becomes an aid to impact analysis.
It lets us connect an architectural change to the behaviours that will need particular attention.
Of course, this assumes the graph is representative enough of reality.
Some dependencies may be indirect, dynamic or simply absent from the map. An impact analysis therefore doesn’t replace a broader test campaign when the risks justify it.
But it lets us organise the checks with more method.
And above all, it offers an interesting possibility: to evolve the architecture gradually while keeping a view of the features that each transformation might affect.
An architecture you can watch evolve #
I would even take this approach a little further.
Why consider this map as a one-off document, produced only before an overhaul?
If the graph is kept up to date, it can become a tool for tracking architectural evolution.
After each transformation, you can compare the relationships between features and components.
Have some dependencies disappeared?
Have responsibilities been better isolated?
Have dependency cycles been removed?
Has complexity really decreased, or has it simply moved elsewhere?
These observations aren’t enough, on their own, to measure the quality of an architecture.
A reduction in the number of dependencies, for example, isn’t automatically an improvement.
But combined with functional criteria, maintainability measures and test results, they can help assess the real effects of a transformation.
The overhaul then stops being a vast undertaking whose benefits you hope to discover at the end.
It becomes a succession of modifications whose consequences you can observe and verify.
Accepting that an architecture is never final #
In the end, I think the difficulty also comes from the way we consider a project’s architecture.
We would like it to be well thought out enough to support all future changes over the long term.
But when a project starts without a perfectly defined purpose, that ambition can become illusory.
You can’t design precisely for needs you don’t know.
On the other hand, you can seek to make the system understandable, its responsibilities identifiable and its dependencies explicit enough to allow it to evolve.
This doesn’t mean we should give up on anticipating.
It’s simply that anticipation perhaps shouldn’t be about future features alone.
It could also be about our ability to transform what we’re building today.
So, when a project becomes hard to evolve, I’m not sure the first question to ask is whether everything should be rebuilt.
I would rather begin by trying to understand what actually exists, how the features interact and which transformations would be possible without needlessly calling the whole thing into question.
And if, in the end, a complete rewrite does turn out to be necessary, this knowledge will be just as valuable in preparing it.
Because an architecture isn’t only a way of organising a system.
It’s also what should allow us to keep evolving it as we discover what it’s really meant to become.