ports/Interface defined but not used in entire project #6
-
There are ports for services (example ports.UserService, ports.MessengerService), but I don't see it used in the project. Why are they defined but not used? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I think they ought to be being used. For example in The advantage of this will be increased decoupling, and will allow the |
Beta Was this translation helpful? Give feedback.
I think they ought to be being used. For example in
internal/adapters/handler/user_handler.go
, theUserHandler
is referencing the concrete implementation ofUserService
in theservices
package, but I think it should instead reference theUserService
in theports
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…