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?

1 Answers1

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.

candied_orange
  • 119,268