locked
MVVM pattern RRS feed

  • Question

  • It is important to learn learn Model View ViewModel(MVVM) pattern?

    And what is the advantage's of mvvm?

    Friday, July 31, 2015 7:24 AM

Answers

  • MVVM is an easier way to work than event based code behind.

    It's a version of the passive view.

    The benefits are

    Seperation of concerns:

    Easier development, maintenance. Greater flexibility. You can have a graphics designer non-coder develop the view independent of the developer working on the viewmodel. Well. Somewhat independent anyhow.

    Makes fast tests possible

    Enabling automated testing approaches such as TDD and BDD. You just can't run 2000 tests every 5 or 10 minutes if you have to instantiate a view for each test. .

    I'm not really convinced on some of the advantages listed but the PRISM documentation

    https://msdn.microsoft.com/en-us/library/gg405484%28v=pandp.40%29.aspx?f=255&MSPPError=-2147217396

    says

    "

    The Model-View-ViewModel (MVVM) pattern helps you to cleanly separate the business and presentation logic of your application from its user interface (UI). Maintaining a clean separation between application logic and UI helps to address numerous development and design issues and can make your application much easier to test, maintain, and evolve. It can also greatly improve code re-use opportunities and allows developers and UI designers to more easily collaborate when developing their respective parts of the application.

    Using the MVVM pattern, the UI of the application and the underlying presentation and business logic is separated into three separate classes: the view, which encapsulates the UI and UI logic; the view model, which encapsulates presentation logic and state; and the model, which encapsulates the application's business logic and data.

    ...

    These features embody the most common practices for implementing the MVVM pattern and are designed to support testability and to work well with Expression Blend and Visual Studio.

    This topic provides an overview of the MVVM pattern and describes how to implement its fundamental characteristics. The topic Advanced MVVM Scenarios describes how to implement more advanced MVVM scenarios using the Prism Library.

    "


    • Marked as answer by Vencee Friday, July 31, 2015 8:26 AM
    Friday, July 31, 2015 7:50 AM
  • Yes, it is! :)

    The advantage of MVVM is the separation of concerns in a software architecture. This leads to several other advantages. Separating the model from the view model and from the view leads to 3 layers that are more or less independent of each other. You can write unit tests against each layer. So you can test your logic independent of the UI (means independent of any controls). You can reuse the view models for different views, e.g. for desktop applications, for mobile applications and so on. And the separation of the model and the view model leads to smaller models that can be used in a GUI. Depending on the UI, you won't need all elements from a model. Instead you can use a smaller view model.

    But that's only for the overview. Please find here some links with further information. Read through them to get a good overview:

    Microsoft Best Practices (MVVM)

    Wikipedia (MVVM)

    MVVM Made Simple (CodeProject)


    Robin Sedlaczek (https://twitter.com/RobinSedlaczek, http://robinsedlaczek.wordpress.com) @ Microsoft Forums (Wave Developments / The Berlin Microsoft Connection - https://www.facebook.com/TheBerlinMicrosoftConnection)

    • Marked as answer by Vencee Friday, July 31, 2015 10:34 AM
    Friday, July 31, 2015 7:57 AM

All replies

  • MVVM is an easier way to work than event based code behind.

    It's a version of the passive view.

    The benefits are

    Seperation of concerns:

    Easier development, maintenance. Greater flexibility. You can have a graphics designer non-coder develop the view independent of the developer working on the viewmodel. Well. Somewhat independent anyhow.

    Makes fast tests possible

    Enabling automated testing approaches such as TDD and BDD. You just can't run 2000 tests every 5 or 10 minutes if you have to instantiate a view for each test. .

    I'm not really convinced on some of the advantages listed but the PRISM documentation

    https://msdn.microsoft.com/en-us/library/gg405484%28v=pandp.40%29.aspx?f=255&MSPPError=-2147217396

    says

    "

    The Model-View-ViewModel (MVVM) pattern helps you to cleanly separate the business and presentation logic of your application from its user interface (UI). Maintaining a clean separation between application logic and UI helps to address numerous development and design issues and can make your application much easier to test, maintain, and evolve. It can also greatly improve code re-use opportunities and allows developers and UI designers to more easily collaborate when developing their respective parts of the application.

    Using the MVVM pattern, the UI of the application and the underlying presentation and business logic is separated into three separate classes: the view, which encapsulates the UI and UI logic; the view model, which encapsulates presentation logic and state; and the model, which encapsulates the application's business logic and data.

    ...

    These features embody the most common practices for implementing the MVVM pattern and are designed to support testability and to work well with Expression Blend and Visual Studio.

    This topic provides an overview of the MVVM pattern and describes how to implement its fundamental characteristics. The topic Advanced MVVM Scenarios describes how to implement more advanced MVVM scenarios using the Prism Library.

    "


    • Marked as answer by Vencee Friday, July 31, 2015 8:26 AM
    Friday, July 31, 2015 7:50 AM
  • Yes, it is! :)

    The advantage of MVVM is the separation of concerns in a software architecture. This leads to several other advantages. Separating the model from the view model and from the view leads to 3 layers that are more or less independent of each other. You can write unit tests against each layer. So you can test your logic independent of the UI (means independent of any controls). You can reuse the view models for different views, e.g. for desktop applications, for mobile applications and so on. And the separation of the model and the view model leads to smaller models that can be used in a GUI. Depending on the UI, you won't need all elements from a model. Instead you can use a smaller view model.

    But that's only for the overview. Please find here some links with further information. Read through them to get a good overview:

    Microsoft Best Practices (MVVM)

    Wikipedia (MVVM)

    MVVM Made Simple (CodeProject)


    Robin Sedlaczek (https://twitter.com/RobinSedlaczek, http://robinsedlaczek.wordpress.com) @ Microsoft Forums (Wave Developments / The Berlin Microsoft Connection - https://www.facebook.com/TheBerlinMicrosoftConnection)

    • Marked as answer by Vencee Friday, July 31, 2015 10:34 AM
    Friday, July 31, 2015 7:57 AM
  • thank you for your answer.

    I'm gonna try to learn this :D

    Friday, July 31, 2015 8:17 AM