Sie sind auf Seite 1von 4

Evaluation of MVVM

Let’s take a look at MVVM from higher level and take a step by step approach to
understand it. Here our discussion is based on complexity of the architecture from simple
to complex, not from historical order.

Probably the simplest design principle to separate the data from its presentation is
Observer design pattern. In observer design pattern, we have two different classes for
data (subject/model) or its presentation (observer/view). Subject class contain the
instance of all of the observers and send notification to all of observers when there is any
change in the data. Here is a simple block diagram of observer design pattern.

The next step is to introduce middle layer in between data and its presentation. The main
purpose of this layer is to communicate between these two component. This is a main
concept of Model View Controller (MVC). It is shown by this block diagram.
This approach has some advantages and disadvantages. The main disadvantage is that our
view is not totally independent of our model. Model View Presenter (MVP) handle
exactly the same problem. In MVP model there is no relation between View and Model.

MVVM is very similar to MVP pattern. Or it is some sort of specialized form of MVP
pattern. In MVVM Presentator known as ViewModel. Model communicate with
ViewModel with notifcation and ModelView communicate with View with data binding
and command binding as shown by this block diagram.

Now let’s take a look at MVVM little bit more detail. What is the biggest advantage of
this. Its first advantage is that our presentation is totally unaware of our model. We don’t
write any user interface specific code in ViewModel and all the communication is based
on data binding and command binding. It means we can easily write a unit tests for it. We
can easily change any user interface or even change the data model easily. Here is a detail
block diagram of MVVM.

This diagram explain how can we take advantage of MVVM. The most important thing
in this pattern is to property design the ViewModel. WPF has very orthogonal design. It
means we can customized or enhanced different parts of the library without effecting
others. Most of the WPF reusability is based on composition rather than inheritance.
Therefore we can take its maximum advantage even at run time. Because we can change
the composition behavior at run time easily but not inherited components. In this block
diagram we see the major components of WPF class library which we developed,
enhanced or customized in most of the WPF application.

Das könnte Ihnen auch gefallen