Kamil Szerszeń’s Post

Hey everyone 👋 Layers or Domains — Where’s the Sweet Spot? 🤔 Lately, I keep seeing discussions about how to structure a Java project the right way. The classic setup looks like this: controller/ service/ repository/ model/ And it makes sense — everything’s organized, clean, easy to follow. It works great for smaller projects or when you’re just getting things off the ground. But more and more people say: “Don’t separate technically, separate by domain.” So instead of splitting the code by technical layers, you group everything by feature: user/ ┣━ UserController ┣━ UserService ┗━ UserRepository order/ ┣━ OrderController ┣━ OrderService ┗━ OrderRepository This domain-based structure starts to shine in bigger projects. Each module becomes more independent, easier to understand, test, and develop without touching the whole codebase. ⚖️ The Sweet Spot? As always — it depends. Layered architecture is great for clarity and smaller apps. Domain-based makes more sense once things get bigger and you want your code to reflect real business logic. 💬 How about you? Do you stick to layers, domains, or something in between? #Java #SpringBoot #CleanCode #Architecture #DDD #SoftwareDevelopment #Programming

  • diagram

To view or add a comment, sign in

Explore content categories