Answer the question
In order to leave comments, you need to log in
Do I need a business logic layer?
I develop API in C# (ASP.NET Core). The data access layer is divided into many modules (eg authorization module: contains models and repositories associated with authorization, the library module contains models and repositories associated with books, etc., etc.).
It was planned to use all these modules in a project with an API, and write all the logic in controllers. Is this a good idea? Or is it better to create a separate project in which all business logic will be described, and use it in a project with an API? If you create a separate project for the BL, then what about the models? It turns out that there will be database models, business logic models and models that I will give / receive from the user in the API.
Answer the question
In order to leave comments, you need to log in
I completely agree with Tolstoy Lorry and Arkadiy Parinov , on my own I would like to add
This is a bad idea and goes against MVC. The controller should not contain business logic, it should only contain the logic for processing the user's request and that's it.
Whether business logic needs to be moved to separate projects or not depends on whether it will be necessary to use it in other projects or not. But it’s definitely worth isolating the business logic layer from the UI layer and the data access layer
Read about splitting the application into layers, DDD and these questions will disappear on their own.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question