I have a use case where i need to register a user,
The registration process includes 2 steps
2. Status check
Status check is done on the basis of an id which is generated in repository
Should I send the response of upload to Usecase and then let use case take decision to call status Api ?.
Or directly call the status api from repository as i already have the id ?
03/28/2022, 1:36 PM
is there any reason you wouldn't call it?
Is calling it a business decision? or is it an impl detail of how the API works?
I'd say if it's a business decision / something with that decision needs to be tested, kick it back up to the use case / domain, if it's just, thats how the API works, and from a business / decision perspective, it either all works, or it all doesn't, then do it in the repo and keep it out of the way
03/28/2022, 2:45 PM
Basically status is something which is required to complete the registration post upload api, Just the results for upload api should be 200 then i can directly call status api
but the question arises, Should i sent the success of upload back to usecase and then call status - though there is no processing on success of upload response
03/28/2022, 3:33 PM
In my opinion there's no right or wrong answer. It depends on how you define the responsibilities of your repositories and those of your UseCases.
In some architectures that I worked on, the Repositories have only "leaf" operations. So coordination between them is done by a UseCase. By that definition, you would your scenario is the job of a UseCase.
Another factor to consider is - is this really "domain" logic? What happens if the ID is invalid? Then it would also go in a UseCase.
Next, consider testing. Do you want to write unit tests for the registration process? What would be more suitable from a testing point of view?
Just to round off the discussion, there are situations where I would do logic in the repository: for example JSON parsing. So even though there is logic - I would not move that to a UseCase.
03/28/2022, 5:28 PM
The repository itself creates ID so for now i don't have any validation on it, Just I use that ID to call Status API
Still I was thinking If I directly call status api after getting 200 from upload api, Will it break anything basically responsibility of repository