
Diagrams are not code. They cannot be a code smell. They are just Diagram Smells.
TL;DR: Don't use diagrams. They are obsolete and dead.
Problems
Maintainability
Trash code
Code Duplication
Diagrams focus only on structure (accidental) and not behavior (essential).
Solutions
Use diagrams only to communicate ideas with other humans.
Program on your favorite IDE.
Thrash all diagrams. Even the ones generated from the source code.
Trust your tests. They are alive and well maintained.
Use Domain Driven Design technique.
Sample Code
Wrong

Right
Detection
We can remove all code annotations and forbid them by policy.
Examples
Conclusion
Designing is a contact sport. We need to prototype and learn from our running models.
Papers and JPGs don't run. They live in the utopic world where everything works smoothly.
CASE was a very hot trend back in the 90s. No good system was developed with these tools.
Relations
More info
Credits
Photo by Nick Seagrave on Unsplash
The Diagram is Not the Model. The model is not the diagram. It is an abstraction, a set of concepts and relationships between them.
Eric Evans
This article is part of the CodeSmell Series.
About the author
I’m a senior software engineer loving clean code, and declarative designs. S.O.L.I.D. and agile methodologies fan.
Comments
Join the discussionI tend to disagree, we still use diagrams and functional designs to help understand the semi/non-technical client what we are building.
It's a decent way to validate if what we are going to build is what they envisioned.
We rather spend the hour making the diagram and functional designs than building something only to realize it's not what they wanted.
Sure !
But you use diagrams to talk to other humans. That's a very valid scenario.
I prefer to validate what user wants using TDD.
The main problem with diagrams is that you discuss DATA with users. And data is accidental. You need to discuss behavior with them. And, IMHO, functional tests and acceptance tests are better for it.
We can validate rapid prototyping and validations with diagrams or Acceptance tests. I prefer the latter.
Code Smells
In this series, we will see several symptoms and situations that make us doubt the quality of our developments. We will present possible solutions. Most are just clues. They are no hard rules.





