In Model-Driven Design, what does it mean to treat the model as the 'primary artifact' instead of treating diagrams as throwaway documentation?
answer
- model = blueprint not poster
- translation gap
- ubiquitous language enforcement
- generated vs disciplined sync
- round-trip engineering
basics
~20 sThe model isn't a picture you draw once and forget — it's the actual blueprint that the code, database, and APIs are built from and kept in sync with, so it stays accurate and useful as the system evolves.
solid answer
~40 sTreating the model as the primary artifact means the model — the set of concepts, relationships, and rules describing the domain or system — is the authoritative description everyone, including the code, must agree with, not a one-off diagram made for a kickoff meeting and never touched again. Documentation-only models drift from reality within weeks because nothing enforces alignment; a primary-artifact model instead drives implementation, either literally (code generation, executable models) or disciplinarily (the team refuses to let code diverge from the model's vocabulary and structure, as in Domain-Driven Design's ubiquitous language). The practical test: if you change the model, does something concrete have to change too, and if the code changes, does someone update the model? If the answer is no on either side, it's decoration, not a primary artifact.
go deeper
Should be able to state that the model isn't a throwaway diagram and give one concrete example of code reflecting model vocabulary; doesn't need to know MDA or generation tooling.
Should distinguish the generative (tool-driven) approach from the disciplinary (code-review-enforced) approach and know at least one has to be actively maintained.
Should be able to name the translation-gap problem this solves, describe how their own team keeps code and model aligned in practice, and identify where it has slipped before.
Should be able to weigh model-primacy discipline against delivery speed at an org level and design the process or tooling — review gates, codegen, or lightweight linting — that keeps a whole organization's models honest over years, not just one team's sprint.
## The artifact of record In most software projects, 'the model' shows up as a UML diagram in a wiki page, drawn during initial design and never opened again. **Model-Driven Design rejects that pattern.** It insists the model — a structured representation of the important concepts, their relationships, invariants, and behavior — is the artifact of record: the thing developers, testers, and business stakeholders treat as authoritative when they disagree about what the system does. Code, database schemas, and API contracts are expected to be derived from or kept faithful to the model, not the other way around. ## Two flavors Mechanically this plays out in two flavors. 1. **The heavyweight version is generative.** Tooling (in the OMG's Model Driven Architecture tradition, using UML plus the Meta Object Facility) reads a formal model and produces skeleton code, database DDL, or even a fully executable system, so the model is quite literally compiled. 2. **The lighter, more common version** — closer to Eric Evans' Domain-Driven Design usage of the term 'model-driven design' — **is disciplinary rather than mechanical.** There is no generator, but the team enforces that every class, method, and table name traces back to a concept in the model, and every model change forces a corresponding code change in the same commit. | Flavor | What keeps the code faithful | |---|---| | Generative, heavyweight | Tooling reads the formal model and produces the code | | Disciplinary, lighter | The team enforces that every name traces back to a concept in the model | Both flavors share the same goal: **eliminate the gap between what was designed and what was built.** ## The translation gap The problem this solves is an old one — the **translation gap**. A business analyst writes a spec, an architect draws a diagram interpreting the spec, and a developer writes code interpreting the diagram; at each hop, information is lost or silently reinterpreted, and six months later nobody can say with confidence what the system is actually supposed to do, because the diagram — if anyone still has it — no longer matches the code. Making the model the primary artifact collapses those hops: there's one representation that must stay true, and everything else answers to it. ## The trade-off: discipline versus speed The trade-off is discipline versus speed. Keeping a model authoritative costs continuous maintenance effort — every schema tweak, every new business rule, has to be reflected in the model as well as the code, and code reviews have to check for drift, not just correctness. Teams under deadline pressure routinely let this slip: - a developer patches the generated code directly to hit a deadline, or - adds a field to a table without updating the corresponding model element. In generative setups this is sharper still, because hand-edited generated code gets silently overwritten the next time someone regenerates from the model — the classic **round-trip engineering** failure mode; teams work around it with generator 'protected regions' or by abandoning generation for hand-written code that merely mirrors the model's vocabulary. ## What it cashes out to day-to-day A concrete real-world instance: shops using Domain-Driven Design tactically keep an aggregate concept — say, an `Order` with its `OrderLine` children — as the model, and insist that - the `Order` class in code, - the `orders` and `order_lines` tables, and - the API's `Order` DTO all use exactly that vocabulary and exactly that consistency boundary, with no helper classes carrying logic the model doesn't describe and no direct SQL updates to `order_lines` that bypass the `Order` aggregate's invariants. That discipline is what 'model as primary artifact' cashes out to day-to-day: not a diagram, but a standing rule that code must justify itself against the model, and the model must justify itself against the domain. ## How it fails Failure shows up gradually rather than as an outage: - new hires read the stale model and build features that contradict how the code actually behaves; - two teams implement the 'same' concept differently because each trusted a different stale copy of the model; - and eventually the model is quietly deleted from onboarding material because 'it's wrong anyway' — at which point the team has reverted to code-only design with all the translation-gap risk that model-driven design was meant to remove.
- If a team has no code-generation tooling at all, can they still practice 'model as primary artifact'?Yes — this is the Domain-Driven Design flavor of model-driven design: there's no generator, but the team enforces by convention and code review that class names, method names, and structure trace directly back to the model's ubiquitous language. The discipline is social and process-based rather than tool-enforced, which is more fragile but far cheaper to adopt than a full generative toolchain.
- What's the first sign a team has stopped treating the model as primary and started treating it as documentation?Code review comments stop referencing the model, and a change to business rules gets implemented in code without anyone updating the model artifact in the same change. Once that happens once without pushback, the model starts drifting and rarely recovers without a deliberate re-sync effort.
It's the difference between an architect's blueprint that the construction crew is legally required to follow, and that gets updated the moment a wall moves, versus a lobby poster showing an 'artist's impression' of the building that nobody checks against the actual construction.
saying these in an interview costs you the question
- calls the model 'just a diagram we made at the start'
- can't explain what forces the model and code to stay in sync
- conflates having a UML diagram with practicing model-driven design
- no answer for what happens when code and model disagree