views:

81

answers:

3

Is there a name for the software design pattern that involves MVC with domain models and view models? It's the pattern used when a tool like AutoMapper is employed.

I was attempting to explain the advantages of such a design to some fellow programmers and was calling it MVVM but I'm now of the opinion that's not right and the MVVM pattern is where the view stage is refining the model for its own purposes rather than changing what's passed between the Controller and the View.

Of course it all gets confusing with the number of M's and V's and rather than getting tied up in more knots I thought I'd ask the experts.

+2  A: 

Its called MVC. No, seriously. Your website's models just happen to be called ViewModels.

MVC doesn't say what the model is supposed to be, just how its supposed to interact with M and C.

jfar
I agree that the approach does conform to the MVC pattern but it's a subtle but significant refinement that it would be very helpful for me to be able to put a label on.
sipwiz
Why not just MVC View Model?
jfar
No reason not to use that or anything other alternatives I was just looking to see if there was already something in widespread use. Now VMVC or (V)MVC or M(VM)VC or MVC(VM) it does get a bit silly but at least in my case the difference between MVC and MVC(VM) could be 100 extra database roundtrips per page request so I'd like to get the concepts and the way they are conveyed straight.
sipwiz
I think its a two part-er. Are you using MVC? If so, are you using View Models? I'd almost argue that nobody develops dictionary based MVC apps. Even in the rare case I see a question ( and I troll this tag hard ) with weakly typed views somebody, usually @Darin Dimitrov, points them in a strongly typed direction.
jfar
A: 

The "Related" questions provided me with the best answer I think I'm going to get.

The design pattern is defined fairly well in the article How we do MVC – View models and the appropriate monica seems to be MVC-ViewModels or MVC-VM.

sipwiz
+2  A: 

As you might have read or experienced that Automapper is used to map objects. When it comes to MVC, the V (View) and C (Controller) are pretty clear. What confuses many people is the M (Model). MVC doesn't lay strong emphasis on how model should be contructed. You can construct your models by running a direct SQL query or using an ORM tool like NHibernate or LINQ2SQL or Entity Framework of your choice.

If you really want to separate the concerns you can go a step ahead and do what most people do. You can introduce repository pattern to handle model data which can be retrieved using a service. This is the situation where Automapper would come into the picture where you need to map entities and Dto's.

I don't think there is any need to abbriviate this method of building models from service layer. The normal MVC stands valid in this case as well :)

Nilesh Gule