First Appraoch
/\
/ \
V/ \ C <=WCF=> {Business Layer (with business logic) <=> ORM <=> Database}
/ \
--------
M
Second Approach
/\
/ \
V/ \ M <=WCF=> {Business Layer (with business logic) <=> ORM <=> Database}
/ \
--------
C
Main Difference:
– In first approach, business object will have 2 versions. One loaded with properties inside business layer and other dumb version with few View specific properties to be populated by Controller. While in second appraoch, there will be one class with all properties.
– First approach seem a bit more decoupled from presentation layer
In both approach, Controller would be starting point.
As far from views I’ve recevied from different people, both are valid approaches and can be toggled as per development preference.
Please share thoughts.
The first one. ViewModels (as you refer as “M” in your triad) should not know of anything in the View or in your business layer.
The real MVC definition:
Microsoft added the ViewModel to make the separation more clear. For starters, the view shouln’t be dependent of your domain models. And it should not contain logic.
I’ve listed the main reasons to use view models here: http://blog.gauffin.org/2011/07/three-reasons-to-why-you-should-use-view-models/