I have a layered application where the UI -> Service -> Logic -> DA. I'm using Inversion of Control and Unity as my IoC container.
A common issue I have, and am looking to find out of this is acceptable or how to work around it, is the case below.
In the normal flow of things (red arrows), witn an example of Login, the UI calls the UserService class, which calls the Userlogic class, which calls the UserDataAccess class which goes to the DB. Data comes back (maybe) back to the logic, where it's processed, and then a reply goes back up to the UI.
But the blue line - is that bad architecture? What's happening there is that I am registering a new user. UI calls the UserService (_userService.RegisterNewUser), which calls the Logic, which registers the user with the database, and replies with the new UserID to the Logic.
If all is good, at that point, I need to create a 'Finance' record for the new user (It's a business requirement). So then I make a call to my _FinanceLogic class (_FinanceLogic.CreateUserFinance), which then goes down to the database and responds back up all the way back to the UserLogic, which then finalises the Registration, if all was OK.
What I'm trying to find out is - is the cross layer call (_UserLogic calls _FinanceLogic) acceptable? I need to add a reference to my _UserLogic, for the _FinanceLogic class. Which means my constructor is getting larger and larger.
public UserLogic(ILog logger, IEmail email, IUserData user, IFinancialLogic financialLogic)
Or, should _UserLogic be calling _FinanceDataAccess direct? I suspect not, as there would be logic in the _FinanceLogic.CreateUserFinance which you would not want to bypass.
Aucun commentaire:
Enregistrer un commentaire