1

I have checked many articles and discussions around the web.

So we have the main diagram:

Uncle Bob's Clean Architecture Diagram

So we have Controller pointing directly to RequestModel.

So straight to the point, should I:

  1. Create a RequestModel class on "delivery" (is how uncle bob calls this layer) layer that implements a RequestModel interface, create the instance of RequestModel concrete class in controller and "throw it in the flow"
  2. Create a RequestModel class on use-case layer, create the instance of RequestModel class in controller and "throw it in the flow''

From my initial understanding, option 2 violates some SOLID principles, correct?

2
  • 1
    A request model is not an interface, it's just a data structure that one (or more) of the methods on the InputBoundary interface accept as a parameter. It's declared in the same layer as the use-case, but is created by clients in order to invoke the Interactor (so, as candied_orange said, the controller might create it; it certainly has to pass it along). Note that the request model is a conceptual thing, a representation of an architectural element; it might be an actual class, but it might just be a parameter list. Feb 17 at 8:28
  • Thank you @FilipMilovanović for this Feb 18 at 17:34
2

Controller creates a RequestModel instance or implements RequestModel?

Let's read a bit from Uncle Bobs book:

Open arrowheads are using relationships. Closed arrowheads are implements or inheritance relationships

Clean Architecture by Robert Martin - page 84

There is no closed arrow head between Controller and RequestModel so no implementing relationship. There is an open arrow head. So a Controller may use a RequestModel.

Does that mean Controller creates a RequestModel? Well it can. Or you can inject it. The diagram simply doesn't tell you which. But for sure there's no implementing happening between them. Not and end up with this diagram.

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.