I’m enjoying the lack of ‘magic strings’ in my views and controllers but are there any draw backs to this approach?
It doesn’t seem like there are. I’ve read blog entries here and there implying otherwise though.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The proliferation of models, in the extreme case to model-per-action, to support additional view properties that may not be directly related to the data model. For example if your view is different depending on a role, you’ll need to create a new model to encapsulate the data model and the role-related settings. The same effect could be achieved by using the data model as the view model and adding a few settings to the ViewData via ‘magic strings.’
EDIT This is not a reason to ‘avoid’ strongly-typed views, but to give some balance to choosing when to create a new, view-specific model rather than use an existing model and extend it with ViewData properties.