Hi, can somebody please let me know why the functions and business logic for User (and Role) has been divided into 2 different places (UserManager and UserAppService)? I can see that the UserAppService sometimes using the functions within the UserManager. I am trying to understand the reason behind it so I could fallow the same principle with my own entities. In all demo and sample projects I have seen so far, all the business logic is supposed to be within the AppServices classes.
Thanks,
4 Answer(s)
-
0
From the documentation on NLayer Architecture:
Application Layer Application layer mainly includes Application Services that use domain layer and domain objects (Domain Services, Entities...) to perform requested application functionalities. It uses Data Transfer Objects to get data from and to return data to presentation or distributed service layer. It can also deal with Authorization, Caching, Audit Logging, Object Mapping, Session and so on...
Domain Layer This is the main layer that implements our domain logic. It includes Entities, Value Objects, Domain Services to perform business/domain logic. It can also include Specifications and trigger Domain Events. It defines Repository Interfaces to read and persist entities from data source (generally a DBMS).
-
0
Hi Aaron, Thanks for your comment. Well, the problem is I can't distinguish the business logic and the requested application functionalities. For instance in the UserAppService>CreateUserAsync, almost all the business logic of creating a user is located in the method body itself rather than the UserManager in the Domain layer.
thanks
-
0
Write all your logic to Application Service. Whenever you need to use the same logic in different places like in different application services you should you a domain service to share the code.
-
0
<cite>alper: </cite> Write all your logic to Application Service. Whenever you need to use the same logic in different places like in different application services you should you a domain service to share the code.
Hi Alper,
Write all your logic to Application Service. Whenever you need to use the same logic in different places like in different application services you should you a domain service to share the code.[/quote]
Would it be a good practice to write the logics as Private functions within the Application Service, while keeping the actual AppService functions focusing on DTOs operations. Later stage, the same logics to be shared with other AppService, then a these Private functions can be easily ported to Domain Service.
Personally, I prefer to have logics implemented at Domain layer; however, it is extra overhead if logics are only used by a single AppService.
Are my perspectives above correct?
Thanks. /Tommy