I'm wondering if you would use the mediator pattern on the following scenario.
First of at all, the program must call an API, and persist this response on somewhere (it could be a database, a file, on a blog storage, and so on).
I see two responsibilities involved here:
- pull data from the API, and
- place it in some storage.
There would be a class per each responsibility (trying to following Single Responsibility Principle); and both classes must not interact directly (API's client class must don't know that their response are being persisted, and the Persistence class must don't know that the models/entities persisted are coming from an API). So here's where a mediator should come: the mediator should orchestrate the interaction between two classes's instances, and accomplish the program's purpose.
I'm trying to increase the classes cohesion the most I can, and also ensuring that I got a low coupling between both classes (responsibilities actually). By doing this, I can change to whatever API I want, and also persist on somewhere I want.
So question: do you think guys I can achieve this by implementing the mediator pattern? Or is there a better approach for achieve this? I'm totally open to any suggestion!!