my API is divided to some layers:
- Presentation layer (PL) - API
- Bussiness Logic layer (BLL)
- Data access layer (DAL)
- database (DB)
PL is the controllers, that have some methods and every method accept XRequest (some request model) and returns XResult (some response model). These models are just DTO (Data Transfer Object) models.
DTO are a part of BLL, because Request model is passed to BLL, when it is being processed and it returns Response model to be returned by controller.
Only DAL has access to DB, of course, so if BLL needs something it communicates through DAL.
I think it is understandable, as it is some kind of N-Tier architecture and it is very similar to architecture described here (diagram 2): Typical layered architecture - project structure
My DAL does not exposes Entities, so it returns to BLL some kind of DTO object. I have no idea where should be these object classes stored (objects that are used to communicate between BLL and DAL).
Should it be in bussiness layer or in data access layer?
If first option is correct, then my diagram will look like this: PL→BLL⟷DAL.
Isn't it wrong that DAL uses classes from BLL?
If second option is correct, then it will look like this: PL→BLL→DAL.
But in this case the bussiness layer depends on data access layer, and I think it is not correct also, because in my opinion bussiness layer should define which data load from database.
If it is wrong, please tell me, but I think the best option is something like this: PL→BLL←DAL.
So here the bussiness layer exposes the interface and objects that should be implemented in DAL. It doesn't look like N-Tier architecture anymore, isn't it? Also, I don't know how to achieve it, because in first and second case it is simle that DAL object are injected in BLL service constructor, and services are injected to controllers. It is easy to achive with ASP.NET dependency injection, but what if I would like to BLL be the core?
Maybe I should just use first approach and doesn't care about that?
Aucun commentaire:
Enregistrer un commentaire