Is it Ok if Domain Object cross Service-Boundary?

Everyone recommend that only DTO should be returned by Services. I am creating simple CRUD application.

Is it ok if my service methods return Domain object instead of flat DTO objects. It will save me from lots of mapping related setup. Is there any alternative approach?

  • 3
    There is not some DDD police that come up and break your hands when you violate some principle. I'm just sayin' Aug 27, 2012 at 13:04
  • 2
    If you're really doing a simple CRUD application, I don't think you need all those DDD principles. Aug 27, 2012 at 13:17

1 Answer 1


Martin Fowler states the first rule of distributed object design is: Don't distribute your objects!

It's understandable that you don't want to write mapping code to map from Domain to DTO and vice versa. Especially, because initially their data might be same. But doing so you couple the domain model to all the clients of the service. Changing your domain becomes impossible without breaking all the clients.

In .NET there is a library called AutoMapper to help mapping between objects. Other languages probably have similar tools.

  • +1 for this answer, but just for fairness Automapper is not the only tool available for this job :)
    – MattDavey
    Aug 27, 2012 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.