Public UseCase(Repository repository, Presenter presenter) The presenter interface: // Use Case Output Portįinally, the interactor itself: class UseCase UseCase useCase = new UseCase(presenter, repository) Repository repository = new Repository() To make a code example, this could be the controller code: Presenter presenter = new Presenter() Following the communication flow, I expect the "Use Case Input Port" to be a primary port (thus, just a method), and the "Use Case Output Port" an interface to be implemented, perhaps a constructor argument taking the actual adapter, so that the interactor can use it. Is the second solution leaking application responsibilities out of the application layer, in addition to not clearly defining input and output ports to the interactor? Input and output portsĬonsidering the Clean Architecture definition, and especially the little flow diagram describing relationships between a controller, a use case interactor, and a presenter, I'm not sure if I correctly understand what the "Use Case Output Port" should be.Ĭlean architecture, like hexagonal architecture, distinguishes between primary ports (methods) and secondary ports (interfaces to be implemented by adapters). However, I see people implementing this architecture, returning the output data from the interactor, and then let the controller (in the adapter layer) decide how to handle it. The Clean Architecture suggests to let a use case interactor call the actual implementation of the presenter (which is injected, following the DIP) to handle the response/display.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |