14

The question is self explanatory, just to add my thoughts :
As far as I have read, The presentation layer in Clean arch has the same responsibility as in MV in MVP.

How one decides to choose one pattern instead of the other?

Mehrdad Shokri
  • 251
  • 1
  • 2
  • 6

1 Answers1

16

What Bob Martin called "Clean Architecture" is more a "meta architecture", a high level guideline for creating layered architectures. It does not say anything like

"There must be a Model layer, a View layer and a Presentation layer, and they must be implemented using MVP",

it contains only more general rules for the layers like "dependencies must go from the outer circles to the inner circles, not vice versa". And since in MVP, the View (=UI) might know the Presenter, but the Presenter is decoupled from the View by an interface, MVP is just one of many possible solutions which fulfills this rule.

Of course, one can use MVP inside a "Clean Architecture" system, but this is not the only one correct approach. Any UI design where the "inner layers" do not know anything special about the UI, and where the UI follows also the other "Clean Architecture" rules described in Bob Martin's article will be fine.

Doc Brown
  • 199,015
  • 33
  • 367
  • 565
  • if I follow MVP pattern, is it guaranteed that I haven't violated Clean architecture rules? – Mehrdad Shokri Nov 24 '16 at 11:44
  • 1
    @Mehrdad: no. MVP just helps you to get the "Dependency Rule" right, and only between the layers View & Presenter, as well as between Presenter and Model, no less, no more. You still have to care for all the other things described in Bob Martin's article. For example, MVP alone does not stop anyone from passing complex data structures between layers (as opposed to the simple data structures mentioned in that article which should be used for crossing boundaries). – Doc Brown Nov 24 '16 at 14:11
  • Could you give a bit more info @DocBrown? I am slightly confused right now as have for a long time been using an MVCS pattern in spring (java) which I had always been told\assumed was a layered architecture based on the concepts in clean architecture. Layers such as the controller only know about the next layer to them, services encapsulate business logic and DTO's and models are used as the data structures, and DAO's are used to access the database with everything interface driven and using IoC and DI. Is this aligned with clean architecture, the diagram for it that is way more complicated. – berimbolo Nov 18 '22 at 08:17
  • @berimbolo: I am not an expert for MVCS in Spring. But if you like, ask a new question on this site, if that architecture fits into "clean architecture". But when you do, make sure you explain precisely the points where you think the two don't match, and give the references. – Doc Brown Nov 18 '22 at 11:48