May 24, 2021

Best practice to reuse UseCases

Best practice to reuse UseCases

Wish you to clarify something, dear fellows.

Imagine that you have two UseCases.

One of them is CreateCustomerHandler, other is SignUpCustomerByGoogleAuthHandler. So, the SignUpCustomerByGoogleAuthHandler has to reuse the CreateCustomerHandler to eventually create a Customer.

Is it legit to inject CreateCustomerHandler to SignUpCustomerByGoogleAuthHandler as a dependency? Are there any pitfalls?

Read that it's not recommended to reuse your UseCases, but what to do in that simple case? Extract the whole CreateCustomerHandler as Application Service and inject it both to the CreateCustomerHandler and SignUpCustomerByGoogleAuthHandler UseCases?

UPDATE
CreateCustomerHandler: https://pastebin.com/TnYcuFgN
SignInCustomerByGoogleAuthHandler: https://pastebin.com/ajj2xWMw

submitted by /u/hapanda
[link] [comments]