Reputation: 1275
I'm reading up on the Clean Architecture by Bob Martin (https://blog.8thlight.com/uncle-bob/2012/08/13/the-clean-architecture.html) - and I see what seems like a contradiction to me.
The visual representation of the architecture has "UI" listed in the outermost layer - meaning it's part of the "Frameworks & Drivers", it's external.
However, when he elaborates on the layer one step in from from that one - called Interface Adapters - he says "It is [the Interface Adapters] layer...that will wholly contain the MVC architecture of a GUI. The Presenters, Views, and Controllers all belong in here." Saying that the Interface Adapter layer contains the Views makes it seem to me like the UI belongs there.
So which layer is to house UI-specific code?
Upvotes: 5
Views: 898
Reputation: 1042
I don't think it's a contradiction as much as distinguishing a layer of indirection. The Interface Adapters are used to convert the internal representation to an external representation, but the external representation needs to interact with the Framework and Drivers layer. So while the application code that interacts with the MVC framework is in the Interface Adapters layer, the APIs it calls and the rendering happen in the Framework and Drivers layer.
As a consequence, the recommendation is that these concerns should not be commingled which make it easier to test and evolve independent of the framework.
Upvotes: 0
Reputation: 5243
The confusion happens because UI has two aspects:
One is the concrete, "physical" aspects of the UI, which is specific to a certain OS or delivery mechanism (such as the Web). This part of the UI is concerned with HOW things are displayed to the user, and HOW user actions are captured.
The other part of UI is concerned with WHAT to display to the user and WHAT user actions to listen to.
Uncle Bob effectively separates between the HOW and the WHAT.
The WHAT aspects of the UI belong to the "Interface Adapters" layer. The Views that you generate there determine WHAT information you display to the user.
The HOW aspects belong to the "Frameworks & Drivers" layer. The goal is that if you want to provide two user experiences to your users - a web app and a mobile app - you will only need to write two versions of the outer layer, but the inner layers don't need to change, or only need to change a little bit.
Upvotes: 7