Performance is the enemy of clean code

Renan Schmitt
Java Performance
Published in
4 min readMar 10, 2024

--

We, developers and architects, are always (or most of the time) willing to create the best software ever, the truly state-of-the-art, and follow some of the well-known concepts, like Design Patterns, SOLID, DDD, TDD, etc. However, we have some enemies, and one of the most formidable enemies is Performance.

Performance is cruel to our architecture; it hurts our concepts, destroys components, breaks architectures, and keeps us awake at night.

The reason for this is that in some of the good architectures, we create abstractions by introducing layers. Introducing a new layer is definitely a good thing because it clearly separates concepts, hides implementation details from consumers, and simplifies the usage of lower-level components. But, in some cases, it comes with an expensive cost: Performance.

Generally, the performance issue arises because you have to move data from one layer to another, and it requires data mapping between the data structures of those layers. As mapping may be a slow operation in some frameworks, it worsens when you have a lot of data to process.

One might think that in most cases we usually implement, the amount of data that needs to be transferred between layers is so small that the performance degradation is not significant, and it is really worth it to invest in a beautiful…

--

--

Renan Schmitt
Java Performance

20+ years as a Dev & Architect, mastering Java & ABAP. Passionate about clean code, system architecture, and delivering impactful training.