difference between MVP MVC and MVVM

后端 未结 2 1048
别跟我提以往
别跟我提以往 2021-02-05 12:11

Folks I have gone through many links/blogs. I see most of them not able to clearly communicate in layman language and as well technical difference between MVP, MVVM and MVC. I k

相关标签:
2条回答
  • 2021-02-05 12:53

    I can't give you a complete answer, however I did struggle to learn some of these patterns and might be able to give you an idea about some of the main differences.

    I learned MVVM first, and then MVC. I am aware of MVP and how it works in theory, however I have never actually built an application with it.

    The biggest difference between the design patterns seems to be who controls the application flow and logic.

    In MVVM, your code classes (ViewModels) are your application, while your Views are just a pretty user-friendly interface that sits on top of the application code and allows users to interact with it. This means the ViewModels have a huge job, because they are your application, and are responsible for everything from application flow to business logic.

    With MVC, your Views are your application, while your Controller handles application flow. Application logic is typically found in ViewModels, which are considered part of the M in MVC (sidenote: the M in MVC cannot be considered the same as the M in MVVM because MVC's M layer contains more functionality than MVVM's M layer). A user is given a screen (View), they interact with it then submit something to the Controller, and the Controller decides who does what with the data and returns a new View to the user.

    I have not used MVP, however my understanding of it was very similar to MVC, but optimized for a desktop application instead of a client/server application. The Views are the actual application, while the Presenter handles application events and business logic.

    0 讨论(0)
  • 2021-02-05 12:54

    In MVC you have Model View Controller linked as a triangle In MVP you have Model View Presenter linked lineary Basically MVC and MVP are very much similar, however it's simplier to work with MVC, even because you already have built in MS plugin to create and separate your M-V-C providing its advantages With MVP your app would look like like a general ASP.NET app , means: no Razor, no .cshtml for the views, etc. and you have to deal with the structure on your own. MVVM is generally used in Silverlight/WPF and for those techs it's the best choice. The idea of MVVM and MVC are pretty much similar. You can also apply MVVM on a client side of your web app if you use knockout.

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