I have been implementing a proof of concept application using Uncle Bob's Clean Architecture and I have run into a bit of a problem.
Uncle Bob's architecture calls for the explicit separation of request and responses using interfaces. This is not a problem in most cases (e.g. when implementing a UI using the MVP pattern) but I don't know how to apply this to create a REST API using Spring MVC.
Controller has a method with the following signature:
Response<String> greet(String name)
/greeting that takes a name and outputs a different greeting depending on the value of the name.
Injected into the
Controller is the
UseCase that receives the name and creates the greeting, sending the output through the
OutputPort injected into it.
The problem is that I cannot separate the inputs and outputs in this way because the
Controller needs to interact with both the inputs and outputs to create a response.
The only way to "implement" this, that I can come up with, is returning the value using the
InputPort, which sounds pretty bad and not at all what a Clean Architecture calls for.
I've been thinking about this and I cannot find any way that my
Controller can act both as a
Controller and as a
Presenter at the same time. Am I missing something here? Is there a better desing that would allow the separation of the inputs and outputs of the REST API without massively overcomplicating things?