Tuesday, October 7, 2014


Model, View, Controller implies separation of concerns between the business logic and the presentation layer, but it's easy to mix them if you're not paying proper attention. One way to mix them is to put all your business logic in the controller. Since MVC is a pattern for presentation, you can separate your layers further by abstracting the data and the business rules from the entire layer. Let your controllers consume contracts and DTOs or Domain Models if you're into DDD. But map the DTO or domain model to a view model that's specific to the views in the UI. The views should only consume the view models or domain models that are contained within the app. Mapping should be defined separately and not attempted within the controllers since a view can be reused, by implication so can the model. If the mapping is separate, then it can be reused along with them.

No comments:

Post a Comment