Manato Kuroda
1 min readMar 10, 2020

--

Hi, thank you for your question. The reason why we have interface/repository/user_repository.go and usecase/repository/user_repository.go is to make dependencies only point inner circle.

If usecase/repository/user_repository.go has a specific implementation, like getting users from the database or creating a user, which violates the dependency rules because the database is in the outer layer of usecase, you should not access from the inner to the outer layer.

So, to solve the issue, we have interface/repository/user_respository.go to implement a specific logic.

And more importantly, we want to separate the details and abstracts.

usecase/interactor/user_interactor.go depends on only usecase/repository/user_repository.go which means that it depends on the only interface, not specific knowledge of the detail. So, even though you edit the code in interface/repository/user_respository.go, usecase/interactor/user_interactor.go won’t care about the changes.

You can check the detail about Dependency Injection in some pieces.

--

--

No responses yet