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

前端 未结 6 1697
野性不改
野性不改 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

6条回答
  •  既然无缘
    2021-02-20 00:22

    If you're doing an MVC pattern, you need view objects; the DDD is just your model. That doesn't mean you must always use MVC; a DDD could be built, say, as a simulator, where all you look at is log messages emitted. But in MVC you really should have separate view objects.

    Now, ask yourself why that would be? The answer is that the view can change, even though the business model doesn't. The DDD model should express, in the business's terms, what is essential to the business.

提交回复
热议问题