DDD and MVC: Difference between 'Model' and 'Entity'

后端 未结 5 722
夕颜
夕颜 2020-12-12 11:27

I\'m seriously confused about the concept of the \'Model\' in MVC. Most frameworks that exist today put the Model between the Controller and the database, and the Model alm

5条回答
  •  误落风尘
    2020-12-12 11:56

    All answers are a heavy mashup of different things and simply wrong.

    A model in DDD is much like a model in the real world: A simplification and abstraction of something. No less and no more. It has nothing to do with data nor objects or anything else. It's simply the concept of a domain part. And in also every complex domain there is always more than one model, e.g. Trading, Invoicing, Logistics.

    An entity is not a "model with identity" but simply an object with identity.

    A repository is not just a 1st level cache but a part of the domain too. It is giving an illusion of in-memory objects and responsible for fetching Aggregates (not entities!) from anywhere and saving them i.e. maintaining the life cycle of objects.

提交回复
热议问题