MVC vs MVVM

Ever heard of MVC?

Yes, its massive view controller 🙂 some call it and its true, because a lot of logic get placed in the view controller only. so today we are trying to convert it into MVVM, yes its Model-View-ViewModel.

first of all here is typical setup of MVC.

MVC.png

Model represent data, views represent user interface and view controller mediate the interaction between two of them.

So there thing about that view and view controller are typically distinct components and they almost go together – tightly coupled. but a view could be paired with different view controllers or vice-versa. so why not formalise their connection.

MVC1.png

There are few things that we only need in view controller like presentation logic.  so make it more clear lets add it into flow.

MVVM.png

i know its looking much better now. its an argumented version of MVC where we move presentation logic out of the controller into a new object – the view model. The motivation behind that is reduce the complexity of view controller.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s