Organizing a codebase by use cases

I’ll present my approach to avoiding code hotspots.

Luís Soares
CodeX

--

Photo by Aleks Dorohovich on Unsplash

The problem — code hotspots

Domain-centric architectures help separate technology from business rules, but some codebases are still complicated to change. The most common reason is that they contain huge files with web handlers and others full of business logic. These are called code hotspots. Most of them are “god objects” (overbusy objects), as they are filled with unrelated functionality, show low cohesion, and violate the single responsibility principle.

There are several reasons why code grows into hotspots. The most common reason is low cohesion, which means that the hotspot contains several unrelated parts and lacks modularity. Such hotspots attract many commits because they have too many responsibilities and those responsibilities tend to be central to your domain, which is why they change. Software Design X-Rays

Visualizing code hotspots (CodeScene)

Why is this bad?

  • Hindered developer experience. Can you quickly find the required feature in huge “hubs” and “services”? Code hotspots grow indefinitely. All you can do is use the editor’s find…

--

--

Luís Soares
CodeX
Writer for

I write about automated testing, Lean, TDD, CI/CD, trunk-based dev., user-centric dev, domain-centric arch, ...