mauryat
mauryat

Reputation: 1646

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:


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.

Upvotes: 2

Views: 1659

Answers (2)

Patrick McCurley
Patrick McCurley

Reputation: 2054

I have seen in enterprise archicture an additional layer known as an Integration Layer. In the context of MVVM I imagine this still 'sits' within the Model, but never-the-less it acts an arbiter between the database, and any other external data layers. In the example I saw, the Integration Layer connected a 3rd party web-service, some input that came over a WCF service, and the main application database.

I think you might be a little off with what the Model means in MVVM. It doesn't mean that the UI/Presentation layer is instantly updated (however it can be configured as such) but more that any business objects, or data-access components are stored in the Model. In that was, there is really no such thing as VVM as the View Model is dependant upon the business objects defined in the Model.

Anyway, I think MVVM is completely appropriate for what you described, but then so are a lot of other architectures. MVVM is particularly good for a WPF frontend, and it fits in very well with the UI databinding model. Model-View-Presenter is very good for Winforms applications, as state is handled differently to Model-View-Controller, which is great for an ASP.net enterprise application. All these archictures support the integration you have described in the OP.

See How to store business logic in domain object? for my recent description of MVVM.

http://www.codeproject.com/Articles/66585/Comparison-of-Architecture-presentation-patterns-M is a great comparison article, a lot of content coming from Martin Fowler - a pioneer of a lot of enterprise software architecture and patterns.

Upvotes: 1

Emond
Emond

Reputation: 50682

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.

Upvotes: 3

Related Questions