Skip to main content

DON'T PUT a service layer

One best practice in software design is to avoid putting a service layer between your controllers and your data access layer. While a service layer can be useful for handling business logic and providing a separation of concerns, it can also introduce unnecessary complexity and make your code harder to understand and maintain.

By not using a service layer, you can simplify your code and make it more straightforward. Instead of having to go through multiple layers of abstraction to perform a simple CRUD operation, your controllers can directly access the data access layer and perform the operation.

This approach can also improve performance, as it reduces the amount of code that needs to be executed for each request. It can also make it easier to test your code, as you can write unit tests that directly access the data access layer without needing to mock or stub out a service layer.

Of course, this doesn't mean that you should ignore separation of concerns altogether. It's still important to keep your code organized and maintainable, but you can achieve this by using other techniques such as SOLID principles, dependency injection, and proper naming conventions.