2

I can't decide what the Model part (that is passed and handled by presenters/controllers and passed to views) used in a MVx application should really be.

So is Model

  1. a single business entity? E.g. a Customer class mapped to database table or service object, possibly with own helper methods like ComputeAge?
  2. a composed business entity for every different form/page/screen of the app? E.g. a CustomerMasterDetail class mapped to a database view or service object, containing a Customers list, data for the Customer selected in the list, and also relevant data like Customer's current Car or Company?
  3. the whole business entity "database"? Would a presenter receive the whole data repository and extract the relevant data itself?

The examples i could find were mostly dumbed down and reduced the Model layer to a single Person entity. I am looking for a proper, uniform way instead.

If i need to specify i want to use MVP Passive view as it seems more "clean", but i think the principles might be the same in MVC or even MVVM.

EDIT I am not asking about the whole MVP pattern, there are many explanations. But they don't explain the Model in practice.

They either say view can databind to it, which excludes variant 3. But they don't talk about multiple models for a single view, which seems to exclude variant 1. And their example model is always a simple entity, which excludes 2 or makes the example unhelpful.

Jakub Fojtik
  • 681
  • 5
  • 22
  • 1
    http://stackoverflow.com/questions/2056/what-are-mvp-and-mvc-and-what-is-the-difference – Allan S. Hansen Feb 17 '16 at 19:12
  • I am not looking for a MVx comparison. None of the answers to that question explain the Model, except one which dumbs it down to a Car object. Accepted answer explains Presentation Model, but only by comparing it to normal Model which is unexplained. – Jakub Fojtik Feb 17 '16 at 19:39
  • Definitely neither 1 nor 2. M is closest to your 3rd case, but I would say that M is _an interface how your P can get/put data_ from/to the application business logic layer from the perspective of a particular P. Letting M be just a simple entity (why?) does not make such models have much sense. I think that the biggest confusion about Ms comes from thinking of them as a bunch of properties: http://stackoverflow.com/questions/32146099/mvp-pattern-in-gwt-how-to-initialize-model-view-and-handle-server-requests-in-t/32147921#comment52187312_32147921 – Lyubomyr Shaydariv Feb 17 '16 at 21:10
  • Regarding the examples that use simple objects as M: they do not violate MVP principles per se, but they bring some in-example simplicity, however causing confusions on how a particular M might look like. – Lyubomyr Shaydariv Feb 17 '16 at 21:14

0 Answers0