This article is part of the Maintainable MVC Series.
As mentioned in the previous post all views are strongly typed and every view has it’s own View Model. Although this results in quite a lot of classes the upside is maintainability in that it’s very straightforward. Every bit of data displayed in the view has a corresponding property in the View Model. As soon as it’s no longer needed in the view we remove the property as well.
Of course, it sounds like it’s in opposition with the DRY principle (Don’t Repeat Yourself). However the data in the properties of the view models stems from the domain model, meaning the business rules are still in one place. To get the data from the domain model to the view models we have mapper classes in the presentation layer.
