4

If you could explain mvvm to me in what sentence. How would you explain it?

Comments
  • 8
    The more I read about MVC, MVP, MVVM, etc., the more I think that no-one really knows what any of these patterns are.

    I think I use MVCVM.
  • 0
    📌
  • 0
    It's like eating a sandwich but you walk in on your mom showering
  • 0
    '\'s pretty much what vue or angular does' is probably the shortest I could do
  • 1
    You have a place for data and a place for displaying the data.
  • 2
    Model is the data, View is the UI displaying the model, and the ViewModel is the brains of business logic that facilitates between the two just like a controller but with a different name.
  • 2
    @duckWit Actually it's quite different than a controller. A viewmodel dictates how the view behaves which can be done through, amongs other things, binding data and displaying that and doing shit with methods that can be called with buttons, and stuff. Take this additionator for a MVVM (without the model) example https://jsfiddle.net/aug7k9rw/. Here the viewmodel binds a, b, and c in order to do something with them (the calculate method).

    A controller on the other hand makes sure that data gets send to the view so that the view can display it according to its rules. Here you would supply the controller with a and b which it would then use to calculate c and then send a model containing a, b, and c to the view for it to render.

    Or put simpler, in MVVM the view is already rendered but you change the data whereas in MVC you render the view with the new data.
  • 1
    @platypus In second semester (like a year ago) we were taught about PCMEF. PCMEF is something that, when you google the first result is the Czech wikipedia page
  • 0
    @inaba I understand your point. To a degree I feel we might be splitting hairs. I should have said "similar to" a controller. They do share some of the same responsibilities. In old AngularJS as an example, their definition and purpose of a controller is almost identical to that of a ViewModel. Even if we're talking about an API controller, I still say a lot of the responsibilities are similar.
  • 0
    @inaba that needed all those sentences... so is vue mvvm?
  • 0
    @duckWit I had no idea what a controller was in old angular so I just looked it up and it looks like it's just what they call their viewmodel. It's definitely not a controller in the MVC sense

    @rant1ng It is because you use a viemodel (the class returned in <script>) in order to give functionality to the view (the <template>)
  • 0
    The view is king
Add Comment