Repositories

In order to interact with a Domain object, you need to hold a reference to it. One way of achieving this is by creation. Alternatively, you can traverse an association. In Object-Oriented programs, objects have links (references) to other objects, which makes them easily traversable, thereby contributing to the expressive power of our models. But here's the catch: you need a mechanism to retrieve the first object, the Aggregate Root.

Repositories act as storage locations, where a retrieved object is returned in the exact same state it was persisted in. In Domain-Driven Design, every Aggregate type typically has a unique associated Repository, which is used for its persistence and fetching needs. However, in the case where it's required to share an Aggregate object hierarchy, the types might share a Repository.

Once you've successfully retrieved the Aggregate from the Repository, every change you make is persisted, which removes the need to go back to the Repository.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset