dev-mastery / comments-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question about the controllers

ChristianSchneeweiss opened this issue · comments

Why do you inject the add-comment in the controller post-comment. Should inner layers not be imported into outer layers usually? I can not wrap my head around this. On all other layers you imported the inner ones and injected the outer layers.

You're right. Good catch. add-comment can be imported and does not need to be injected.

Strictly speaking, Uncle Bob's Clean Architecture diagram shows that the Use Case Interactor implements a Use Case Input Port interface, and the Controller references the Input Port interface. While importing the Use Case Interactor directly in the Controller does not violate the dependency rule, injecting an Input Port implementation does make testing the Controller easier.