Search code examples
wpfweb-servicesarchitecturemvvm3-tier

MVVM to interact with a web-service in a 3-tiered application


Question:

Does it make sense to use MVVM for a UI that interacts with a web-service in a 3-tiered application?


Details:

  1. Application's architecture is 3-tiered:

    Presentation Layer <--Web-Service-->| Business Layer | Data Access Layer

  2. Front-end: .NET (WPF and C#)

  3. Back-end: Java EE

Does it make sense to use MVVM for the UI?

  1. How can the Model abstract the database since it cannot access it directly without the web-service in between?
  2. If it was in fact possible to abstract the database via the Model, is it even a good idea to do it that way?

Other considerations:

Don't need to have a live update of data:

  • Updates on the DB needn't be instantly reflected on the UI and vice versa.

  • This makes me think that I don't need to have a Model as such. Is MVVM appropriate in my case?


EDIT

Links:

It'll help if you can post links to projects that have used an MVVM for a UI in a 3-tiered application.


Solution

  • The Model in MVVM is not necessarily provided by the database.

    In this case I would consider the data structure that is published by the Business Layer the Model.

    The data structure in the database should be optimized for storage and querying. The data structure exposed by the Business Layer should be optimized for (all) possible clients and considerations such as bandwidth.

    The data structure in a client should be optimized for presentation and this is what we call the Viewmodel in MVVM.

    MVVM is very appropriate because it allows you to translate between the data structure exposed by the Business Layer and the required data structure by the UI.