In Domain-Driven Design, can you use your domain entities in your UI?

前端 未结 6 1154
野性不改 2021-02-20 00:03

In many leading DDD projects, especially MVC style, I see the UI using display objects that mirror domain entities, rather than using those domain objects directly. This style

  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-20 00:19

    Domain objects are really the internal logic inside your business logic layer. They shouldn't be directly exposed to your clients (UI layer). Instead, encapsulate the usage of your domain model into application services. The application services can utilize lightweight DTOs and/or command objects to pass data and intent between the client and the domain model.