DTO or Domain Model Object in the View Layer?

It really depends on the complexity of your application. Mixing domain objects into the view layer has two possible implications:

  1. You’ll be tempted to modify your domain object to accommodate things you need in the view layer
  2. Your View layer will contain extra complexity caused by a mismatch between what your domain objects offer and what your view really needs. You might not be able to get around this complexity but it probably doesn’t belong in the View layer.

If your domain objects are simple and your views are few, skipping the DTOs might be the simplest thing.

On the other hand, if your domain model is likely to evolve and become complex and if your views are likely to be numerous and varied, having view specific objects might be a good idea. In the MVC world, using ViewModels is common and makes a lot of sense to me.

Leave a Comment