Why should I isolate my domain entities from my presentation layer?

后端 未结 14 2764
南旧
南旧 2020-12-02 04:07

One part of domain-driven design that there doesn\'t seem to be a lot of detail on, is how and why you should isolate your domain model from your interface. I\'m trying to c

14条回答
  •  臣服心动
    2020-12-02 04:49

    We are using the same model in the server and on the ui. And it's a pain. We have to refactor it some day.

    The problems are mainly because the domain model needs to be cut into smaller pieces to be able to serialize it without having the whole database referenced. This makes it harder to use on the server. Important links are missing. Some types are also not serializable and can't be sent to the client. For instance 'Type' or any generic class. They need to be non-generic and Type needs to be transferred as string. This generates extra properties for serialization, they are redundant and confusing.

    Another problem is that the entities on the UI don't really fit. We are using databinding and many entities have lots of redundant properties only for ui purposes. Additionally there are many 'BrowsableAttribute' and others in the entity model. This is really bad.

    At the end, I think it is just a matter of which way is easier. There might by projects where it just works fine and where is no need to write another DTO model.

提交回复
热议问题