For the survey conducted, we see that more and more in applications development, is followed by the MVVM, what are the advantages of this in relation to MVC, since we aremore familiar with MVC (Model-View-Controller)?
I appreciate your opinion,
Todas as Respostas
Advantages of MVVM over MVC -
1. Increases the "Blendability" of your views (ability to use Expression Blend to design views) – This enables a separation of responsibilities on teams that are lucky enough to have a designer and a programmer... each can work independent of the other.
2. "Lookless" view logic – Views are agnostic from the code that runs behind them, enabling the same view logic to be reused across multiple views or have a view easily retooled or replaced. Seperates concerns between "behavior" and "style".
3. No duplicated code to update views – In code-behind you will see a lot of calls to update view controls. With MVVM you can be assured the view is updated appropriately just by setting the underlying property and all view side-effects thereof.
4. Testability – Since your logic is completely agnostic of your view, unit testing is made easy. You can test the behavior of a ViewModel without involving its view. This also enabled test-driven development of view behavior, which is almost impossible using code-behind.
5. Designer-Developer Workflow – MVVM facilitates a separation of UI and presentation logic concerns from the business layer that makes it easy to streamline the development process by allowing design cycles to happen in parallel with development.
Both are passive view patterns.
Mvc is used with asp.net.
Mvvm is used with wpf/silverlight and whatever xaml on win8 will be called.
Both offer similar advantages over code behind which are related to separation of concerns.
So the question is a bit strange.
The MVVM pattern was introduced by Microsoft Architect John Gossman as a WPF and Silverlight specialization of Martin Fowler’s platform-independent Presentation Model (PM) pattern (a variation of MVC).
The key difference is the existence of binding to decouple the 'View Model' from the 'Model'.
In PM the 'Presenter' is referencing the 'View'.
It comes down to what "application" you are building. MVVM web applications frameworks like KnockoutJS have peculiar advantages including a closer UI centric viewmodel abstracted from HTML and faster page loads when used with MVC4 WebAPI. I suggest reading Addy Osmani's blog on KnockoutJS
These are the patterns targeted to specific platforms,
MVVM Introduced standard way of leveraging core features of WPF, we can say it is more generalized form of Presentation Model introduced by MartinFowler and tailer-made for WPF or Silverlight.
Hops this helps you...
If this post answers your question, please click "Mark As Answer". If this post is helpful please click "Mark as Helpful".
If you what to know why MVVM then
- it helps separate UI from Application logic
- UI is considered job of UX (User Experience) Designers and Application Logic is considered job of Developers do helps in isolating their work
- increases testability of Application logic and that too via automated tests
- XAML is very powerful in Data Binding and related stuff that is built in core of it and is basis of MVVM
Happy Coding!! If my post answers your question please 'Mark as Answer' and 'Vote as Helpful' if it helps you.
- Sugerido como Resposta Coder R quarta-feira, 12 de junho de 2013 10:28
As already mentioned, these are patterns NOT technologies. In theory you can use MVVM or MVC on a ZX Spectrum (ask your parents). Whilst it's true that MVVM has become popular with XAML based technologies it's also true that it's been implemented elsewhere as Vinod as already mentioned. They are both patterns that promote separation between what is showing some data, what is holding the data and what is orchestrating the whole. I like MVVM for the reasons already provided (although some mentioned above are not MVVC over MVC, the share a great deal), but it does depend on what you are writing, and unfortunately, what tools/technologies you are using as practically that will impact your ROI.