Why no wiews models are used?

Jul 19, 2013 at 8:44 AM
I was working through the code of the latest version of Near Forums and was wondering why view models are not used. Instead domain models are used and bound to the views.

Would like to hear opinions
Jul 19, 2013 at 9:03 AM
Nearforums is a middle-to-small web project so it makes sense to have the domain models as viewmodels.
To express it in another way, in this project viewmodels would be identical to domain models.
Kind Regards,
Jul 19, 2013 at 9:05 AM
Thanks for the quick reply Jorge.

If I were to have a view with data from multiple tables what would you do then?
Jul 19, 2013 at 9:12 AM
Is not a matter of how many tables as how that tables map to domain objects, the complexity of your project and the relation to other domains.
For example, on the thread detail page we are displaying information from 3 tables (forums/topics/messages) and we are using domain objects (Topic has a list of messages and has a property forum).

If they are 4 unrelated tables or the object complexity is large or it would make your life easier to map from viewmodel to html elements, in that case it could make sense to have view models.

Jul 19, 2013 at 10:16 AM

Ok now a final answer relating to view models. In your project structure where would you go and add your view model classes?
Jul 19, 2013 at 10:25 AM
No problem.
I would go for: NearForums.Web
Jul 19, 2013 at 10:28 AM
Thanks for the answers and thanks for a good product. Easy to understand how your code works :)