Skip to content

Repository | The central data supplier

Benjamin Eder edited this page Dec 14, 2018 · 3 revisions

Repository

A repository mostly is a thing you put things in and retrieve them later. To the app the repository is a singleton factory class instance where you can retrieve implementations for all kinds of repositories.

For example if you want to get notice board entries you will have to get the notice board repository with a call to something like Repository().getNoticeBoardRepository(). It simply will create or reuse an instance of the NoticeBoardRepository class (or something like that). With the NoticeBoardRepository class you now can retrieve notice board entries and stuff.

Now why that complicated?

Because it provides us with the opportunity to easily swap out implementations. You might want to run tests on some classes which depend on the Repository implementation. Then you simply swap out the implementations by calling Repository.setRepositoryImplementation(...)... and you're done! Well at least if you have already written a repository implementation that fits your needs (Should be there already).

Diagram - for better understanding (maybe?)

UML diagram repository