# Code Smell 47 - Diagrams

*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

1. Use diagrams only to communicate ideas with other humans.
    
2. Program on your favorite IDE.
    
3. Thrash all diagrams. Even the ones generated from the source code.
    
4. Trust your tests. They are alive and well maintained.
    
5. Use [Domain Driven Design](https://en.wikipedia.org/wiki/Domain-driven_design) technique.
    

# Sample Code

## Wrong

![class-example-library-domain.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1607469295593/BHMBjTokB.png align="left")

## Right

%[https://gist.github.com/mcsee/36f0af6785ea36a05c3ec394fa71e4e8] 

# Detection

We can remove all code annotations and forbid them by policy.

# Examples

* [Automatic Code Generators](https://maximilianocontieri.com/lazyness-ii-code-wizards)
    

# 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](https://en.wikipedia.org/wiki/Computer-aided_software_engineering) was a very hot trend back in the 90s. No good system was developed with these tools.

# Relations

%[https://maximilianocontieri.com/code-smell-01-anemic-models] 

%[https://maximilianocontieri.com/code-smell-25-pattern-abusers] 

# More info

%[https://maximilianocontieri.com/lazyness-ii-code-wizards] 

%[https://en.wikipedia.org/wiki/Computer-aided_software_engineering] 

%[https://en.wikipedia.org/wiki/Domain-driven_design] 

# Credits

Photo by [Nick Seagrave](https://unsplash.com/@seagrave) on [Unsplash](https://unsplash.com/s/photos/map)

---

> 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*

---

%[https://mcsee.hashnode.dev/software-engineering-great-quotes] 

---

This article is part of the CodeSmell Series.

%[https://mcsee.hashnode.dev/how-to-find-the-stinky-parts-of-your-code]
