go-clean-arch icon indicating copy to clipboard operation
go-clean-arch copied to clipboard

Creating different insert operation method vs creating single insert method and reuse in usecase?

Open akmalhazim opened this issue 5 years ago • 2 comments

Hello, Sorry for too many questions. I've been studying this architecture lately and came up across this question?

Is it better to create a single Create() method in repository layer and have many usecase methods that creates the entity or having different method for Create() operation in repository layer for so every usecase that requires a Create() method could have it's own dedicated method for creating the entity?

Appreciate your feedback. Thank you and have a nice day ahead.

akmalhazim avatar Oct 27 '20 11:10 akmalhazim

I think the second one.

frederikhors avatar Oct 30 '20 21:10 frederikhors

Agree with @frederikhors The repository is meant to be re-used by the usecase/service layer as the orchestrator. The service layer knows which repos they want, and orchestrates the repos as needed.

bxcodec avatar Aug 04 '22 01:08 bxcodec