A class whose purpose is to provide data (let's say it provide Student
s) and client code would look like this:
students = StudentProvider.getAllStudents()
Its underlying implementation will encapsulate the retrieval of Student
s from a remote server with an instance of RemoteStudentRepository
, and then save it locally using an instance of LocalStudentRepository
:
// StudentProvider#getAllStudents()
students = remoteStudentRepo.GetAll((students) => {
// Callback with a list of students as a parameter
for student in students {
localStudentRepo.updateOrInsert(student);
}
});
return students;
I know Facade is structural and Mediator is behavioural, so it makes me think this is a Mediator example because it encapsulates the logic of how object interacts (remote fetch and local storage), but I'm not so sure if this "added functionality" is enough to call it a Mediator.
So what is it?