MVVM

MVVM

The well-ordered and perhaps the most reusable way to organize your code is to use the 'MVVM' pattern. The Model, View, ViewModel (MVVM pattern) is all about guiding you in how to organize and structure your code to write maintainable, testable and extensible applications.

Model − It simply holds the data and has nothing to do with any of the business logic.

ViewModel − It acts as the link/connection between the Model and View and makes stuff look pretty.

View − It simply holds the formatted data and essentially delegates everything to the Model.

MVVM pattern is ultimately the modern structure of the MVC pattern, so the main goal is still the same to provide a clear separation between domain logic and presentation layer. Here are some of the advantages and disadvantages of MVVM pattern.

The key benefit is allowing true separation between the View and Model beyond achieving separation and the efficiency that you gain from having that. What that means in real terms is that when your model needs to change, it can be changed easily without the view needing to and vice-versa.

There are three important key things that flow out of applying MVVM which are as follows.

Maintainability

  • A clean separation of different kinds of code should make it easier to go into one or several of those more granular and focused parts and make changes without worrying.
  • That means you can remain agile and keep moving out to new releases quickly.

Testability

  • With MVVM each piece of code is more granular and if it is implemented right your external and internal dependences are in separate pieces of code from the parts with the core logic that you would like to test.
  • That makes it a lot easier to write unit tests against a core logic.
  • Make sure it works right when written and keeps working even when things change in maintenance.

Extensibility

  • It sometimes overlaps with maintainability, because of the clean separation boundaries and more granular pieces of code.
  • You have a better chance of making any of those parts more reusable.
  • It has also the ability to replace or add new pieces of code that do similar things into the right places in the architecture.

The obvious purpose of MVVM pattern is abstraction of the View which reduces the amount of business logic in code-behind. However, following are some other solid advantages −

  • The ViewModel is easier to unit test than code-behind or event-driven code.
  • You can test it without awkward UI automation and interaction.
  • The presentation layer and the logic is loosely coupled.

Disadvantages

  • Some people think that for simple UIs, MVVM can be overkill.
  • Similarly in bigger cases, it can be hard to design the ViewModel.
  • Debugging would be bit difficult when we have complex data bindings.


To view or add a comment, sign in

More articles by Kishan Kumar

  • Sales Manager

    What is a Sales Manager? A sales manager is responsible for overseeing and leading a team of sales representatives to…

  • Data Modelers

    Data modelers are systems analysts who work with data architects and database administrators to design computer…

  • Deepfake Technology

    What is Deepfake? Deepfake is a term that refers to synthetic media that have been digitally manipulated to replace one…

  • Analytics

    Analytics is a field of computer science that uses math, statistics, and machine learning to find meaningful patterns…

  • What is Apache Airflow?

    The Apache Airflow platform allows you to create, schedule and monitor workflows through computer programming. It is a…

  • LSTM Networks

    LSTM networks are an extension of recurrent neural networks (RNNs) mainly introduced to handle situations where RNNs…

  • Free Space Laser Communication

    FSO is a line-of-sight technology that uses lasers to provide optical bandwidth connections or FSO is an optical…

  • Neo4j

    A Neo4j graph database stores nodes and relationships instead of tables or documents. Data is stored just like you…

  • Customer Communications Management

    What is customer communications management? Customer communications management is a strategic framework designed to…

  • Bid Rigging

    Bid rigging is a common practice in almost every industry. It hampers the buyers’ efforts to get goods and services at…

Others also viewed

Explore content categories