Friday, January 14, 2022

Repository pattern



Repository pattern is a software design pattern that provides an abstraction of data, so that your application can work with a simple abstraction of data layer that has an interface.

Using this pattern can help achieve loose coupling and can keep domain objects persistence ignorant.

It also makes code more testable as it allows us to inject as a dependency a mock repository that implements that defined interface.

Finally, it is a way of centralising the handling of the domain objects.

In Microsat app, this pattern allows me to abstract the domain layer from the data layer and also, inside data layer, the data repository from its data sources (WebAPI, Sqlite, User Defaults, etc.).