Coffeehouse Post

Single Post Permalink

View Thread: MVVM
  • User profile image

    JohnAskew said:
    spivonious said:

    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.


    Good advice.  One needs to be careful with any tight-coupling, and not just because of testing concerns.  Of course, there's the pragmatic side to this as well... over engineering for a small "throw away" application just to adhere to enterprise "best practices" can be a waste of time.  If this were a mission critical and/or large application, I'd recommend the repository pattern here.