DRY vs Security and Maintainability with MVC and View Models

Posted by Mystere Man on Stack Overflow See other posts from Stack Overflow or by Mystere Man
Published on 2010-12-30T16:48:29Z Indexed on 2010/12/30 16:54 UTC
Read the original article Hit count: 198

Filed under:
|
|

I like to strive for DRY, and obviously it's not always possible. However, I have to scratch my head over a concept that seems pretty common in MVC, that of the "View Model".

The View Model is designed to only pass the minimum amount of information to the view, for both security, maintainability, and testing concerns. I get that. It makes sense.

However, from a DRY perspective, a View Model is simply duplicating data you already have. The View Model may be temporary, and used only as a DTO, but you're basically maintaing two different versions of the same model which seems to violate the DRY principal.

Do View Models violate DRY? Are they a necessary evil? Do they do more good than bad?

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about viewmodel