For everyone — A place for everything
In a badly organized house, the kitchen, the office and the workshop share the same room: it's impossible to prepare a meal without disturbing whoever is working, and you end up looking for your keys at the bottom of the oven. In a well-designed house, each activity has its room, and everyone breathes. "Separation of concerns" is that common sense applied to software: each responsibility gets its own clearly delimited place, so you can change one thing without breaking the others.
It's a principle useful far beyond computing: any organization that grows — a company, a non-profit, an administration — benefits from splitting its tasks into clear roles rather than entrusting everything to a single entity. You gain in stability, in understanding, and in freedom to evolve. No miracles though: separating well requires finding the right boundaries, and that is the whole point of this article.
This is precisely the spirit of Yokul: modeling a virtual world means superimposing independent planes — weather, geology, biotopes, physics, the behaviors of beings — that must be able to evolve separately, like assembled bricks.
The full text
The principle
The expression goes back to Edsger W. Dijkstra ("On the role of scientific thought", 1974): preventing several concerns — different motivations for change — from becoming entangled in the same part of a system. If price computation and invoice display live in the same code, changing the pricing rules forces you to touch the display, and vice versa. If each concern has its own, every change stays local. Naming a system's concerns well is therefore already anticipating where it will want to change tomorrow.
It is a thread running through the whole history of software engineering, under various names:
- modularity and encapsulation, which hide the detail of a module behind a stable interface;
- layers (network, databases, interfaces), stacked from the closest to the hardware to the closest to the user;
- separation design patterns (facade, decorator, visitor), which detach one concern from another without duplicating code;
- dependency injection, which separates what a component requests from how it is provided (see Inversion of Control);
- external configuration, which detaches what changes often (settings, environments) from code that changes rarely.
In every case, separation goes hand in hand with an accepted trade-off: cutting things apart means giving up an immediate global optimization to gain the freedom to change each module independently. Cutting too much, or cutting in the wrong place, costs as much as not cutting at all — the right boundary is the one between changes that arrive at different rhythms.
The Yokul example
In a simulator like Yokul, the temptation of "everything in the same bag" is at its strongest: a simulation of individuals who perceive, decide, learn and transmit touches everything — perception, memory, decision, transmission, the physical environment. To last over time, we therefore applied the separation of concerns at the scale of the world itself:
- weather, geology and biotopes evolve according to their own rules and their own time steps, independently of one another;
- the behaviors of beings are described separately from their execution, in behavior graphs (see Behavior Model);
- long-running processes — chains of steps with persistent state and error recovery — are entrusted to a dedicated engine (see Workflow Engine);
- rendering, finally, is merely an observer of the world: the 3D scenes display the current state without contributing to computing it — that is the role of jMonkeyEngine.
Each plane can thus be corrected, replaced or enriched without touching the others: a new biotope model doesn't require rewriting the weather, and a behavior added mid-simulation affects neither the rendering nor the environment.
This discipline pays off precisely where it is most debatable: when everything changes all the time. Adding an individual, changing its motivations or introducing a new species is done by composing existing bricks — not by deep surgery on a monolith. Separation of concerns is what makes the project's ambition plausible: building a world that can be modified continuously, where nothing that has been built is thrown away.
For Yokul, this is not one architectural detail among others, but the project's survival condition: each isolated concern is a brick that can evolve, be replaced or be reused — and it is the sum of these bricks that holds up an entire world.
Takeaways
- Separation of concerns (Dijkstra, 1974) means isolating motivations for change, so that each evolution stays local.
- It takes many forms: modularity, layers, design patterns, dependency injection.
- The right boundary runs between things that change at different rhythms; separating too much costs almost as much as not separating at all.
- At Yokul, it applies to the whole world: weather, geology, biotopes, behaviors, processes and rendering live in independent planes.