Coffeehouse Post

Single Post Permalink

View Thread: MVVM
  • User profile image

    spivonious said:
    wkempf said:

    Okay, that means I understand the pattern then, which is good. It's definitely different using commands instead of events.

    Thanks everyone for your posts. It's good to see things from a different perspective.


    Oh, one last question. My commands (currently just a save and a load) are in the ViewModel, as are the functions they call when executed. Since these functions are just simple mappings to functions in the Model, would it be "wrong" to attach the command execute directly to the model?

    If you are considering the 'model' being a DataSet within the ViewModel, sure, wire up to it. I would request you refer to the DataSet not as the model, but a datatype within your ViewModel that was delivered from The Model (Oracle/DAL/etc)... Perhaps it's a trivial distinction, but I'm sure you get my meaning.

    But if you mean you want to call functions that are on the Model directly from the ViewModel, well, it is the place to call into the Model...

    What would be handy is to be mindful of dependencies on the Model with regard to your unit tests. If you use an interface for the Model to implement, then you can Mock that Model within unit tests that can fully exercise the ViewModel.