Organizing a codebase by use cases
I’ll present my approach to avoiding code hotspots.
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
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…