MVP: Should the View implement a Presenter's interface or vice versa?

前端 未结 3 853
离开以前
离开以前 2020-12-14 03:25

I am doing my first steps with GWT. I have a question after reading:

  • Large scale application development and MVP
  • Large scale application
相关标签:
3条回答
  • 2020-12-14 04:18

    In the second tutorial the code was changed to using a Presenter interface (defined in the view) to accommodate using UiBinders and Java generics. I think the Presenter interface was moved to the View interface as they both share the same generic T.

    0 讨论(0)
  • 2020-12-14 04:21

    I think you should have used the word 'defines' in your question instead of 'implements' and if thats the case then it does not matter which class defines the interface.

    You could do something different by defining the interfaces in its own files. At the end of the day all that matters is the Presenter implementing the Presenter interface and the View implementing the View interface.

    0 讨论(0)
  • 2020-12-14 04:21

    @deepak these are valid concerns . Word is infect implementation not definition .

    Let me explain . In first example presenters hold the contract to what view must implement in other words drives what should be implemented by views a classical MVP approach .

    Things get confusing in second example. Where Presenter has no control over what view must implement . This is not MVP and google is calling it as MVP . There is no way you can test the views with JRE /unit tests using this approach . That does not make it bad though just not MVP and google should not call this MVP or they must explain as to why is it an MVP ?

    @Saket Bansal separating out interface is not correct approach . It will result in hard to maintain code as application grows .

    In my opinion you can take either approach , I remember google saying some where first one worked for them for adwords and second for wave .

    Any how you should also look at framworks like GWTP or ERRAI from jboss

    0 讨论(0)
提交回复
热议问题