views:

31

answers:

2

Hey everyone,

I've just started on a new project which currently contains a fair few ViewModel DTO classes.

I'm wondering whether it would be useful and even good practice to replace many of these DTOs with Tuples and to use that as my method of transfering a bunch of objects to my views.

What do you think? Is this a correct usage of the tuple or am I off the mark here?

+1  A: 

Usually view models have metadata associated with them which among other allows you to perform validation and integrates with editor/display templates. Tuples don't seem appropriate. Another disadvantage is that they express less clearly the purpose of each property in the view model (Model.Item1, Model.Item2, ..., no-one else than the original developer can make any sense of this, and if he is like me after few days even he won't be able to make sense).

Darin Dimitrov
Thanks to both of you (@Darin and @Mathew Abbott) for your answers. Very helpful. I had to choose one as the accepted and I went for this one because it had some extra information. Both really helpful though cheers.
Jamie Dixon
+1  A: 

One of the issues I see with using a Tuple, is that in your view:

inherits="ViewPage<Tuple<Model1, Model2>>"

...etc, when you use these models you have to access them as:

Model.Item1,
Model.Item2

...which isn't as clear as using a nice strongly-typed view model.

Matthew Abbott