See all posts

Mon Jul 29 2024

Comparison - C4 model vs UML

A breakdown of the key differences between the C4 model and UML for documenting your software architecture

Tim

⚡️ TL;DR

  • Unified Modelling Language (UML) has been the standard for modelling software systems for nearly 20 years. It’s comprised of 14 diagram types across 2 categories.
  • The C4 model has a lower learning curve and can be paired with a model-based tool for consistent diagramming.
  • UML popularity has been on a steady decline in the last decade, while interest in the C4 model has increased due to the need for a lightweight methodology to document software systems.

💨 A quick recap on the C4 model

If you haven’t already, check out our first article, What is the C4 model?

To keep things brief, the C4 model is a lightweight method for documenting software architecture. It organizes diagrams in 4 levels of hierarchy with a limited set of abstractions at each level.

🆚 C4 model vs UML

Before comparing the C4 model with UML, let’s talk a bit about UML (Unified Modeling Language). UML has been the standard for documenting software systems for decades (since 1996, to be exact). It has deep ties to object-oriented programming, which was developed around the same time with its own object-modelling technique (OMT). Today, UML is managed by the Object Management Group (OMG) and is an official ISO/IEC 19501 standard.

💡 Learning curve

UML has many diagram types—14 diagram types divided into 2 categories. Behavioural diagrams focus on a system’s more dynamic aspects, whereas structural diagrams highlight the architecture’s underlying static composition. Each diagram type is used for different use cases, from showing low-level class details to high-level data flows.

Understanding all these diagrams and when to use them requires a steep learning curve. Not only is the learning curve high for creators, but it’s arguably even higher for consumers who need to juggle different types and notation. Many people who start learning UML are easily overwhelmed by the sheer amount of documentation needed to document their systems. Most people end up relying on a few diagram types in specific scenarios in combination with more freeform diagrams.

UML diagram types
UML diagram types

In contrast, the C4 model has 4 diagram types: Context, container, component, and code. These are organized in a hierarchy, allowing you to navigate from the high-level to the low-level details of a system. It’s much easier to learn, which allows teams to focus on the more important abstract thinking of their architecture.

C4 model diagrams with abstractions
C4 model diagrams with abstractions

⚙️ Tools available

There are plenty of options for UML tools. Popular diagram-as-text UML tools include Mermaid JS and PlantUML. These options typically require some learning of syntax to create diagrams (yes, another thing you have to learn in addition to the 14 diagram types). If you’re looking for more user-friendly drag-and-drop tools, there are popular options like Draw.io, Miro, LucidChart, and Visio. These are all pretty similar since they’re based on the same notation and standard UML diagram types.

With the C4 model being newer, there are fewer options for tooling. The good news is that many tools have started to support the C4 model as it’s becoming more widely adopted in the architecture community. Mermaid and PlantUML support the C4 model, as do visual diagramming tools like LucidChart and Miro. There’s, of course, IcePanel, a visual C4 model tool that combines the best of both worlds — a user-friendly interface combined with a model-based system.

🏢 Consistency

Having consistent diagrams and being able to easily maintain them is a key consideration when choosing a solution. When exploring options, it’s essential to look for a model-based tool. There are many UML and C4 model tools that aren’t model-based (yes, it’s confusing because they both contain ‘model’ in their names). Let’s clarify this a bit.

A model-based tool gives you a single-source of truth of objects and relationships to create different views from. This makes your diagramming much more efficient, since any changes to objects are synced across all the different views. If you change an object property that exists in 10 diagrams, you just need to do it once. By combining the C4 model with a model-based tool, you get the best of both worlds — simplicity and consistency.

What does a model-based tool help with?
What does a model-based tool help with?

If you opt for a UML solution, make sure to look for a model-based tool. Otherwise, you’ll be creating one-off diagrams to communicate something with your team and then discarding them into the ether. This is great if you want to jot down some quick visuals and don’t care about longevity or tracking changes over time. It’s not so great if you’re looking to maintain and reuse these diagrams over time as your system evolves.

📈 Popularity

UML is about 10 years older than the C4 model and is the standard modelling language across the software industry. In the last 20 years it’s been on a steady decline as software documentation has taken a back seat to the ‘moving fast and breaking things’ ethos. It’s still default alive, though, as teams need some form of documentation for their systems.

Interest in UML over time — Google Trends
Interest in UML over time — Google Trends

In the last 5 years, interest in the C4 model has steadily increased. We’re not quite sure about the root cause, but Simon Brown has continued to evangelize the practice to software teams around the world with much success. Our hunch is that the increased complexity of software systems coupled with outdated, dense methodologies has pushed people towards simpler methods. Documentation is still important, but the tools available haven’t adapted to the needs of modern software teams. Our increasing dependence on AI and third-party tools will continue to encourage teams to understand their architecture from top to bottom.

Interest in the C4 model over time — Google Trends
Interest in the C4 model over time — Google Trends

📋 C4 model vs UML cheatsheet

C4 model vs UML cheatsheet

🏁 Next up

In the next article, we walk you through how to get started with the C4 model if you want to make the leap with your team. Stay chill! 🤙