Skip to content

ports/Interface defined but not used in entire project #6

Answered by cycloss
jolosastro asked this question in Q&A
Discussion options

You must be logged in to vote

I think they ought to be being used. For example in internal/adapters/handler/user_handler.go, the UserHandler is referencing the concrete implementation of UserService in the services package, but I think it should instead reference the UserService in the ports package.

The advantage of this will be increased decoupling, and will allow the UserService to be switched out for a different implementation. For example, this might be useful for writing tests for testing the decoding and validating http requests where a mock service can be injected. There is also a niche use case which I encountered recently where there are two types of user who's type dictates which of one or two third party s…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jolosastro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants