bxcodec / go-clean-arch

Go (Golang) Clean Architecture based on Reading Uncle Bob's Clean Architecture
MIT License
9.03k stars 1.19k forks source link

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

Open akmalhazim opened 3 years ago

akmalhazim commented 3 years ago

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.

frederikhors commented 3 years ago

I think the second one.

bxcodec commented 2 years ago

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.