clean-architecture

Gateway in Interface Adapter Layer of Clean Architect


As I can see, in the humble object section of Uncle Bob, he mentioned that Database Gateway is an interface, and its implementation is a humble object.

context about db gateway written by Uncle Bob

As I understand, the Database Gateway will reside in Application Business Layer (the same layer as the usecase), and the implementation will reside in Framework Layer (outmost layer).

Is my understanding correct and if so, what does the term "Gateway" in Interface Adapter layer present

clean architecture structure

Thank you very much

###########


Solution

  • As I understand, the Database Gateway will reside in Application Business Layer (the same layer as the usecase), and the implementation will reside in Framework Layer (outmost layer).

    Yes, the interface will reside in the application layer and the implementation in the interface adapters layer.

    Is my understanding correct and if so, what does the term "Gateway" in Interface Adapter layer present

    The term refers to the gateway implementations. You might be a bit confused that the term appears in the name of the interface in the application layer and in the diagram it appears in the adapters layer where the implementations reside. I usually prefer the term Repository in the application layer, because to me it is closer to a domain language then database gateway.

    In general a gataway is an object that encapsulates access to an external system or resource. See Gateway.