Chapter 8. Dividing responsibilities
This chapter covers
- Making a distinction between read and write models
- Defining separate repositories for read and write models
- Designing read models for their specific use cases
- Building up a read model from events or a shared data source
We’ve looked at how objects can be used to retrieve information or perform tasks. The methods for retrieving information are called query methods, and the ones that perform tasks are command methods.
Service objects may combine both of these responsibilities. For instance, a repository (like the one in the following listing) could perform the task of saving an entity to the database and also retrieving an entity from the database.
Listing 8.1. PurchaseOrderRepository ...
Get Object Design Style Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.