0

There is a number of posts about MVVM generally and also in relationship with MVC pattern, like this.

But they mostly describe just general concept of what should MVVM do (like, "remove most of the logic from ViewModel to Controller" etc).

I would like though to know more specifically which tasks in the app logic would rather be better to move to ViewModel than to have them in Controller?

(As even though that's great to have all the business logic in Controller, there are still some tasks which are more "client side" (or, at least, "presentation-") related, but still must be done on server side (with C#, for instance), like Data Formatting, Localization etc.)

(The talk is only about ASP.NET MVC (i.e., Web) extending with ViewModels using).

What's else?

Thank you.

Community
  • 1
  • 1
Agat
  • 4,577
  • 2
  • 34
  • 62
  • What else other that Data Formatting and Localization are you concerned about? I doubt there's an exhaustive list. – D Stanley Nov 11 '13 at 22:09
  • Well, this is what I am trying to clarify, which are also possible... The thing is I am thinking of creating some sort of framework for MVVM, so trying to understand what are tasks, which might be involved into its (MVVM) work. Plus, "data formatting" is also wide enough term... – Agat Nov 11 '13 at 22:13
  • Why did you move the block into the quote? That's (still) only my thoughts. :) – Agat Nov 11 '13 at 22:14
  • My apologies - I misinterpreted and rolled back to the original version. – D Stanley Nov 11 '13 at 22:17

1 Answers1

2

I am not a MVC developer(but MVVM developer) but I think I may know what you asking.

1. The main benefit of MVVM is Binding.(i.e. you want to change label simultaneously when you entering text in TextBox then you can easily do it using Binding)

2. To perform client side operations use MVVM. MVC is used to perform server side operations.

3. MVVM is used to update UI whiout sending request to server which is quite useful in many scenarios.

So keep these points in mind and move your code accordingly.

May be I missed out some points but as a MVVM developer I inform you as much as I can.

Pranav
  • 146
  • 1
  • 5
  • Thank you for your answer, but those are still pretty general things. I am familiar with MVVM pretty close and know how it generally works, but would rather be interested in life time examples of which tasks would be better to be moved to MVVM part from Controller. – Agat Nov 12 '13 at 11:08
  • "MVVM is used to update UI without sending request to server" - are you talking about javascript? But my question was only about server part... – Agat Nov 12 '13 at 11:08
  • Yes I am talking about javascript, I think knokoutJS is used to achive MVVM in MVC, I don't know other ways. For server part MVC is more useful and powerful compare to MVVM. I will let you know if I get more detail about it – Pranav Nov 12 '13 at 13:48
  • Thank you for the answer. And I do know about knockout. But this is javascript part -- if you need something to do on client part (meaning, in browser) -- you just have no choice. So, that's why I am asking about server part (the stuff to move from Controller to ViewModel). – Agat Nov 12 '13 at 13:50
  • I researched some and found that at server side there is no use of MVVM for that use only MVC. And in this line: "remove most of the logic from ViewModel to Controller" Model is not equal to ViewModel? because some developers use ViewModel word for Model(I found it little bit strange) – Pranav Nov 12 '13 at 14:06
  • Well, you should continue researching on MVVM for web, then. :) That's obviously, that MVVM in that case is not exactly the same replacement for MVC (as it is in WPF, for instance). But using ViewModel-s is wide in ASP.NET MVC, when ViewModel just extends the functionality which Model is not allowed to do. – Agat Nov 12 '13 at 14:13