Why does active record pattern not work with rich domain models?

后端 未结 2 1146
半阙折子戏
半阙折子戏 2021-02-08 05:31

I\'m reading the architectural patterns chapter of POEAA, and Fowler says that \"As the domain logic gets more complicated and you begin moving toward a rich Domain Model (116),

2条回答
  •  醉梦人生
    2021-02-08 05:59

    What he's trying to say is that more complex domain models are usually more than just "data from a table". These more complex models Fowler is talking about are models that get data from different tables, views or maybe even other sources.

    The Active Record pattern is not very suitable for this purpose, and the DataMapper pattern combined with just model classes (containing just the business logic and do not communicate with the data access layer) is probably more suitable in situations like these.

    The Active Record pattern fails here, because it maps more or less directly to a table in the database.

    I don't know the exact pattern definition, so please correct me if i'm wrong.

提交回复
热议问题