Quantcast
Channel: Active questions tagged use-case - Stack Overflow
Viewing all articles
Browse latest Browse all 80

Prevent duplication of validation logic in use-cases (Clean Architecture)

$
0
0

Suppose I have multiple use-cases that takes in user-id as parameter and therefore has to verify that there indeed exists a user with that user-id in the db before the execution start. This works fine, but what if it now came up that these use-cases will use each-other, for example CreateUserUseCase might call CreateCalendarForUserUseCase, where both want to validate that the user exists. There will essentially be duplication of the check. I understand if this is the price I have to pay to follow this design, but is there any other way to think of this to prevent this duplication to take place.

I thought about maybe not using use-cases for reuse, rather having a service createCalendarForUserService that can assume that the user-id indeed points to a user in the db, but this means that I completely throw away the concept of reusable use-cases, and I feel like then it is not clean architecture anymore.


Viewing all articles
Browse latest Browse all 80

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>