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?

asked Feb 16, 2021 at 18:17
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. Commented Feb 17, 2021 at 8:28
  • Thank you @FilipMilovanović for this Commented Feb 18, 2021 at 17:34

1 Answer 1

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.

answered Feb 16, 2021 at 23:47
3

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.