Search code examples
javamvpclean-architecturegwt-mvp

I can not understand clean architecture's part (MVP) from uncle Bob book


I read "Clean Architecture book" by uncle Bob. And I tried to implement simple examples. I have this diagram:

enter image description here

I can not understand how can I implement part in the red line. For example, I have a simple web page:

enter image description here

I have 2 buttons, one edited text, and one label. If I press to send to server button - text from edit text will send to the server. And If I press get from server button - I load message and sow in the label.

What happens if I click to first button(send to the server)? My view call presenter or controller?

If I will belive to diagram - my Web view doesn't know about the presenter. It knows only about the Screen View interface(it implements this interface). The presenter knows about the Screen View interface too. But the presenter hasn't link to the controller. How can I pass my text from edit text box to controller or interaction?


Solution

  • Maybe this is not the best picture to explain view, presenter and controller. There are other pictures in his book which more clearly show that

    • the view send a request object to the controller
    • the controller interacts with the business logic
    • the business logic passes response model to presenter
    • the presenter updates the view model which is observed by the view

    All this collaboration happens by respecting the dependency rule often using inversion of control.

    For a more detailed description of view, controller and presenter interaction pls see to my blog: http://www.plainionist.net/Implementing-Clean-Architecture-Controller-Presenter/