Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

While starting work on a brand new ASP.net MVC application we've learned that we should have all of our available data pushed to make it easy to create a full view. While learning this we've started using a concept of a ViewModel, or a complex object full of properties from other basic data transfer objects.

Now our problem has been in naming these ViewModels. We've run across the idea of using a name created from the DTO object names like MemberContactViewModel. while this is okay, I feel that names should be more unique or more related to what the complex object will be doing rather than what it's made up of.

What are your thoughts. How should a complex ViewModel be named, based on the data it holds, or the view where it will interact with.

Thanks for the input.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

Definitely the View it will interact with.

BUT

If you're finding they all related to domain objects, why bother having view models? Why not just let the action interact with the domain layer?

share|improve this answer
    
So far we've found that we're needing bits and pieces from a couple different domain objects. For example we have a profile showing personal information, and then we have collections for phone, email and mailing addresses. All of these are combined into one view model. But for editing, we actually access each chunk via its own domain model. Hence needing some way of naming these complex objects without repeating domain objects names. –  Chris Apr 7 '11 at 20:52
    
@Chris - Have you looked at CQRS? blog.fossmo.net/post/… –  pdr Apr 7 '11 at 21:12
    
@pdr: I find it quite odd that a person who knows of and would even suggest CQRS would also recommend letting the view depend directly on domain objects. –  qes Apr 7 '11 at 21:40
    
@qes - Match the tool to the problem. I think all of these approaches are valid in the right context –  pdr Apr 7 '11 at 22:00
    
@pdr: true, of course. Difference in semantics I suppose, if I had "domain objects" exposing a bunch of data publicly and referenced them in the views I wouldn't really consider the application to be following DDD much at all and consequently wouldn't call them "domain" objects. –  qes Apr 7 '11 at 22:18
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.