2

I started using MVP for the first time on my last project and I'm absolutely confused with it now.

What I was taught regarding MVP is that: The Model in MVP really exists just to provide exactly what the view needs and only what it needs.

So the models that my view would be getting, are unlikely to be representing classes/objects with actual logic on them.

They are in fact, a lot more likely to be just data transfer objects with everything set-up perfectly so that the view has to do nothing but display the data however it sees fit.

BUT from what I gathered online, the model layer is where most of my business logic should reside in.

Why is what I'm finding online about models so different from what I've been taught?

I'm pretty sure I'm confusing concepts here and I really need help in untangling this mess.

Darkalfx
  • 259
  • 3
  • 12
  • MVC is still a UI pattern. Put your business logic in your business layer. Also remember that its a pattern to be followed, not a law. – crthompson Mar 16 '14 at 02:48
  • 1
    Note that MVC and [MVP](http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93presenter) and [MVVP](http://en.wikipedia.org/wiki/Model_View_ViewModel) are different patterns and "model" mean very different thing in each (second part of the post is likely about original [MVC](http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller)). – Alexei Levenkov Mar 16 '14 at 03:18
  • A straight model doesn't contain business logic. What you're reading may be talking about View Models in the MVVM pattern, which perform basically the same task as the Presenter in MVP. – jmcilhinney Mar 16 '14 at 03:38
  • @Alexei Levenkov , is the the definition that I put in bold about the model MVP correct? If so, do you mind explaining a little bit the differences between the model in MVC and MVP? – Darkalfx Mar 16 '14 at 14:57
  • @Darkalfx - Note that I'm not an expert for that... My understanding is your bolded definition is for "view model" in MV **V** P (i.e. as used in WPF and ASP.Net MVC), while second part is "business/domain model" with is what "M" stands for in MVC/MVP/MVVP. – Alexei Levenkov Mar 16 '14 at 17:17
  • @Alexei Levenkov - So you're saying that there's in fact not three, but four parts to MVP? The View/Model/Presenter AND a ViewModel? – Darkalfx Mar 16 '14 at 17:33
  • @Darkalfx - no, I just think that your definition of model is from "MVVP", not "MVP" - 2 different patterns. Check links on Wikipedia (and links from each of 3 articles) and make you own judgment. – Alexei Levenkov Mar 16 '14 at 17:37
  • https://stackoverflow.com/questions/2056/what-are-mvp-and-mvc-and-what-is-the-difference/42757368#42757368 explains what MVC/MVP/MVVM mean in a big picture – Xiaoguo Ge Aug 22 '17 at 07:26

1 Answers1

0

I think you're on the right track, the Presenter layer should handle most business logic and the Model layer should represent your data or domain model. This is what the text I am working through suggests anyway, and it seems to provide a nice foundation for SOLID in Web Forms.

JTW
  • 3,546
  • 8
  • 35
  • 49