Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. MVVM As Explained by an Idiot (Yours, Truly)

MVVM As Explained by an Idiot (Yours, Truly)

Scheduled Pinned Locked Moved The Lounge
wpfdesignwcfcom
29 Posts 11 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    honey the codewitch
    wrote on last edited by
    #1

    I've never used MVVM. Today I realized I had to. So I started reading. It's a bunch of 10 dollar words to explain a 5 dollar concept. Microsoft, honest edition: "We originally intended you bind your business data directly to controls but when that didn't work in the real world, we noticed people would create an intermediary binding object to transform the data, and then bind to that. We formalized what y'all have been doing since VB6, and gave it a confusing name to make it our own, because you are lowly plebes."

    Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

    J A J Sander RosselS O 6 Replies Last reply
    0
    • H honey the codewitch

      I've never used MVVM. Today I realized I had to. So I started reading. It's a bunch of 10 dollar words to explain a 5 dollar concept. Microsoft, honest edition: "We originally intended you bind your business data directly to controls but when that didn't work in the real world, we noticed people would create an intermediary binding object to transform the data, and then bind to that. We formalized what y'all have been doing since VB6, and gave it a confusing name to make it our own, because you are lowly plebes."

      Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

      J Offline
      J Offline
      Jon McKee
      wrote on last edited by
      #2

      MVVM is old news, too. Now it's MVVM-C :laugh: I'm so glad I don't do UI stuff anymore. It seems to be the discipline with the worst jargon obsession, though we're all guilty of it to some degree.

      H Richard Andrew x64R 2 Replies Last reply
      0
      • J Jon McKee

        MVVM is old news, too. Now it's MVVM-C :laugh: I'm so glad I don't do UI stuff anymore. It seems to be the discipline with the worst jargon obsession, though we're all guilty of it to some degree.

        H Offline
        H Offline
        honey the codewitch
        wrote on last edited by
        #3

        I was and professionally still am in the same boat as you, thankfully. But my side projects have lead me to C# source generator technology (which I knew I'd pick up eventually as I absolutely love making code write code) That led me to find use cases for it. That led me to the UI arena. And WinForms is basically NRND at this point. So here I am, an embedded dev, but with a hobby, looking for something to apply it to.

        Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

        1 Reply Last reply
        0
        • J Jon McKee

          MVVM is old news, too. Now it's MVVM-C :laugh: I'm so glad I don't do UI stuff anymore. It seems to be the discipline with the worst jargon obsession, though we're all guilty of it to some degree.

          Richard Andrew x64R Offline
          Richard Andrew x64R Offline
          Richard Andrew x64
          wrote on last edited by
          #4

          Jon McKee wrote:

          the discipline with the worst jargon obsession,

          I want to agree with you here. I think it's because UI is a visual thing, there's an element of fashion about it. What's in, what's out.

          The difficult we do right away... ...the impossible takes slightly longer.

          N 1 Reply Last reply
          0
          • H honey the codewitch

            I've never used MVVM. Today I realized I had to. So I started reading. It's a bunch of 10 dollar words to explain a 5 dollar concept. Microsoft, honest edition: "We originally intended you bind your business data directly to controls but when that didn't work in the real world, we noticed people would create an intermediary binding object to transform the data, and then bind to that. We formalized what y'all have been doing since VB6, and gave it a confusing name to make it our own, because you are lowly plebes."

            Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

            A Offline
            A Offline
            Amarnath S
            wrote on last edited by
            #5

            Have seen interviewers ask this question: Given a simple project, with a UI, and a simple database, how would you structure your code as per MVVM (meaning which pieces-of-code would you place in your M, VM and V parts). And have heard diverse answers; the M and V parts seem pretty straightforward, but with VM, there's lack of clarity. So, it seems like MVVM is (was?) the new buzzword (Just like OO was in the early 90s. Most programmers of that time said that they were doing OO, but very few understood its real meaning; some even thought that merely including the keyword class made a non-OO code as OO).

            H N R J 4 Replies Last reply
            0
            • A Amarnath S

              Have seen interviewers ask this question: Given a simple project, with a UI, and a simple database, how would you structure your code as per MVVM (meaning which pieces-of-code would you place in your M, VM and V parts). And have heard diverse answers; the M and V parts seem pretty straightforward, but with VM, there's lack of clarity. So, it seems like MVVM is (was?) the new buzzword (Just like OO was in the early 90s. Most programmers of that time said that they were doing OO, but very few understood its real meaning; some even thought that merely including the keyword class made a non-OO code as OO).

              H Offline
              H Offline
              honey the codewitch
              wrote on last edited by
              #6

              Amarnath S wrote:

              So, it seems like MVVM is (was?) the new buzzword

              Yes.

              Amarnath S wrote:

              Most programmers of that time said that they were doing OO, but very few understood its real meaning;

              Kinda falls down here though, because it sort of implies that eventually mud that "what is the role of the ViewModel?" yields will give way to something more cohesive as it gains traction. It has been almost 20 years since WPF was released, and like I said I was already doing this even in VB6 in the 90s before without calling it that. The issue I think, is that the ViewModels roles can only ever be "clearly" defined in the most general sense - it is a data translation facility. They are muddy because they are an adapter between one type of presentation - the datacentric model - and another - the User centric View. So I don't think they'll ever really become clearly defined or even understood by people. And honestly? We'll come up with a different pattern ultimately because of it. Give it another 20 years.

              Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

              K 1 Reply Last reply
              0
              • H honey the codewitch

                Amarnath S wrote:

                So, it seems like MVVM is (was?) the new buzzword

                Yes.

                Amarnath S wrote:

                Most programmers of that time said that they were doing OO, but very few understood its real meaning;

                Kinda falls down here though, because it sort of implies that eventually mud that "what is the role of the ViewModel?" yields will give way to something more cohesive as it gains traction. It has been almost 20 years since WPF was released, and like I said I was already doing this even in VB6 in the 90s before without calling it that. The issue I think, is that the ViewModels roles can only ever be "clearly" defined in the most general sense - it is a data translation facility. They are muddy because they are an adapter between one type of presentation - the datacentric model - and another - the User centric View. So I don't think they'll ever really become clearly defined or even understood by people. And honestly? We'll come up with a different pattern ultimately because of it. Give it another 20 years.

                Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                K Offline
                K Offline
                Kenneth Haugland
                wrote on last edited by
                #7

                I always thought of it as having only one difference from "normal" programming in WinForms. The View contained all the code for animations and layout; other than that, its pretty self-explanatory.

                H 1 Reply Last reply
                0
                • K Kenneth Haugland

                  I always thought of it as having only one difference from "normal" programming in WinForms. The View contained all the code for animations and layout; other than that, its pretty self-explanatory.

                  H Offline
                  H Offline
                  honey the codewitch
                  wrote on last edited by
                  #8

                  You can do it in winforms though - and it will in fact corral you into doing it that way if you try to use its databinding facilities for anything real world. You'll end up making a viewmodel. the only differences are A) You probably won't call it that B) Not all of your controls will go through it necessarily, or you may have more than one. The reason is simple. Databinding is too basic to handle real world scenarios to the 80% rule. It's not quite there, so at some point, you're going to have to "hack" or at least indirect the databind (read: Create some kind of adapter - a viewmodel)

                  Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                  K 1 Reply Last reply
                  0
                  • H honey the codewitch

                    You can do it in winforms though - and it will in fact corral you into doing it that way if you try to use its databinding facilities for anything real world. You'll end up making a viewmodel. the only differences are A) You probably won't call it that B) Not all of your controls will go through it necessarily, or you may have more than one. The reason is simple. Databinding is too basic to handle real world scenarios to the 80% rule. It's not quite there, so at some point, you're going to have to "hack" or at least indirect the databind (read: Create some kind of adapter - a viewmodel)

                    Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                    K Offline
                    K Offline
                    Kenneth Haugland
                    wrote on last edited by
                    #9

                    I always just found bindings to leave the view clear of other code; just separate the view and other code. I used to like WinForms programming. It was so simple. Until the program got massive. And you would have to scroll endlessly to find the relevant code. MVVM just seems to me to be the next logical step to separate stuff and make the organization simpler.

                    H 1 Reply Last reply
                    0
                    • K Kenneth Haugland

                      I always just found bindings to leave the view clear of other code; just separate the view and other code. I used to like WinForms programming. It was so simple. Until the program got massive. And you would have to scroll endlessly to find the relevant code. MVVM just seems to me to be the next logical step to separate stuff and make the organization simpler.

                      H Offline
                      H Offline
                      honey the codewitch
                      wrote on last edited by
                      #10

                      Again, you can do it in winforms, as winforms does have databinding mechanisms in it, just like VB6 did You just need to create your ViewModel object to bind to. It's just a pattern, not a technology.

                      Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                      K 1 Reply Last reply
                      0
                      • H honey the codewitch

                        Again, you can do it in winforms, as winforms does have databinding mechanisms in it, just like VB6 did You just need to create your ViewModel object to bind to. It's just a pattern, not a technology.

                        Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                        K Offline
                        K Offline
                        Kenneth Haugland
                        wrote on last edited by
                        #11

                        honey the codewitch wrote:

                        It's just a pattern, not a technology.

                        Totally agree. I'm curios: Who says otherwise? :doh:

                        H 1 Reply Last reply
                        0
                        • K Kenneth Haugland

                          honey the codewitch wrote:

                          It's just a pattern, not a technology.

                          Totally agree. I'm curios: Who says otherwise? :doh:

                          H Offline
                          H Offline
                          honey the codewitch
                          wrote on last edited by
                          #12

                          It sounded like you were suggesting that it was new with WPF, and that you couldn't do the same thing with winforms. Not anything you said explicitly specifically, but the read I got from your comments. Guess I was mistaken.

                          Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                          K 1 Reply Last reply
                          0
                          • H honey the codewitch

                            It sounded like you were suggesting that it was new with WPF, and that you couldn't do the same thing with winforms. Not anything you said explicitly specifically, but the read I got from your comments. Guess I was mistaken.

                            Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                            K Offline
                            K Offline
                            Kenneth Haugland
                            wrote on last edited by
                            #13

                            It was just a trick that made some things easier; there was nothing else special about it in my mind. And you could give your designer the Xaml and tell him/her to do their thing without having the need to speak to them. Kind of :laugh:

                            1 Reply Last reply
                            0
                            • H honey the codewitch

                              I've never used MVVM. Today I realized I had to. So I started reading. It's a bunch of 10 dollar words to explain a 5 dollar concept. Microsoft, honest edition: "We originally intended you bind your business data directly to controls but when that didn't work in the real world, we noticed people would create an intermediary binding object to transform the data, and then bind to that. We formalized what y'all have been doing since VB6, and gave it a confusing name to make it our own, because you are lowly plebes."

                              Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                              J Offline
                              J Offline
                              Jacquers
                              wrote on last edited by
                              #14

                              It's actually come in quite handy before. I've reused the viewmodel for different views.

                              H 1 Reply Last reply
                              0
                              • Richard Andrew x64R Richard Andrew x64

                                Jon McKee wrote:

                                the discipline with the worst jargon obsession,

                                I want to agree with you here. I think it's because UI is a visual thing, there's an element of fashion about it. What's in, what's out.

                                The difficult we do right away... ...the impossible takes slightly longer.

                                N Offline
                                N Offline
                                Nelek
                                wrote on last edited by
                                #15

                                Richard Andrew x64 wrote:

                                What's in, what's out.

                                Didn't you want to mean "crap in, crap out"? :rolleyes:

                                M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

                                1 Reply Last reply
                                0
                                • J Jacquers

                                  It's actually come in quite handy before. I've reused the viewmodel for different views.

                                  H Offline
                                  H Offline
                                  honey the codewitch
                                  wrote on last edited by
                                  #16

                                  Sure, especially if you have several views of essentially the same data. But in general the viewmodel is kind of a place to shove the big ball of mud in your app. - at least the mud involved with putting data onto the screen. I'm not trying to be too critical here, as that mud will always exist in some form - it just gets shoved around depending on the technologies being employed. That mud exists because programming patterns are little more than formalized limitations in programming languages, essentially. You know that when you employ one, there's mud involved. How much, and where depends on the particular pattern and how effective it is at papering over the given language or runtime limitation. And at least putting it in the viewmodel sticks all the mud in one place.

                                  Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                                  K 1 Reply Last reply
                                  0
                                  • A Amarnath S

                                    Have seen interviewers ask this question: Given a simple project, with a UI, and a simple database, how would you structure your code as per MVVM (meaning which pieces-of-code would you place in your M, VM and V parts). And have heard diverse answers; the M and V parts seem pretty straightforward, but with VM, there's lack of clarity. So, it seems like MVVM is (was?) the new buzzword (Just like OO was in the early 90s. Most programmers of that time said that they were doing OO, but very few understood its real meaning; some even thought that merely including the keyword class made a non-OO code as OO).

                                    N Offline
                                    N Offline
                                    Nelek
                                    wrote on last edited by
                                    #17

                                    Amarnath S wrote:

                                    And have heard diverse answers; the M and V parts seem pretty straightforward, but with VM, there's lack of clarity.

                                    If M and V are clear... for me VM would be all what doesn't fit the other two. Exclusion principe can simplify things too :rolleyes: :-D

                                    M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

                                    H 1 Reply Last reply
                                    0
                                    • H honey the codewitch

                                      Sure, especially if you have several views of essentially the same data. But in general the viewmodel is kind of a place to shove the big ball of mud in your app. - at least the mud involved with putting data onto the screen. I'm not trying to be too critical here, as that mud will always exist in some form - it just gets shoved around depending on the technologies being employed. That mud exists because programming patterns are little more than formalized limitations in programming languages, essentially. You know that when you employ one, there's mud involved. How much, and where depends on the particular pattern and how effective it is at papering over the given language or runtime limitation. And at least putting it in the viewmodel sticks all the mud in one place.

                                      Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                                      K Offline
                                      K Offline
                                      Kenneth Haugland
                                      wrote on last edited by
                                      #18

                                      I think it stinks at that job. Why has there been no improvement in the connection between UI and properties? All the errors and limitations of inputs connected to the UI are so tedious to do. Is the current situation really the best we can do?

                                      H 1 Reply Last reply
                                      0
                                      • H honey the codewitch

                                        I've never used MVVM. Today I realized I had to. So I started reading. It's a bunch of 10 dollar words to explain a 5 dollar concept. Microsoft, honest edition: "We originally intended you bind your business data directly to controls but when that didn't work in the real world, we noticed people would create an intermediary binding object to transform the data, and then bind to that. We formalized what y'all have been doing since VB6, and gave it a confusing name to make it our own, because you are lowly plebes."

                                        Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                                        Sander RosselS Offline
                                        Sander RosselS Offline
                                        Sander Rossel
                                        wrote on last edited by
                                        #19

                                        I recently saw a gif "explaining" (more like a moving diagram) MVVM and something like twelve(!) alternatives like MVC and MVP :wtf:

                                        Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript

                                        H 1 Reply Last reply
                                        0
                                        • A Amarnath S

                                          Have seen interviewers ask this question: Given a simple project, with a UI, and a simple database, how would you structure your code as per MVVM (meaning which pieces-of-code would you place in your M, VM and V parts). And have heard diverse answers; the M and V parts seem pretty straightforward, but with VM, there's lack of clarity. So, it seems like MVVM is (was?) the new buzzword (Just like OO was in the early 90s. Most programmers of that time said that they were doing OO, but very few understood its real meaning; some even thought that merely including the keyword class made a non-OO code as OO).

                                          R Offline
                                          R Offline
                                          Rage
                                          wrote on last edited by
                                          #20

                                          Amarnath S wrote:

                                          very few understood its real meaning

                                          This is in essential the difference between "programming" and "SW engineering". Everybody can program, not everybody has the knowledge and skills to engineer SW.

                                          Do not escape reality : improve reality !

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups