Facade, Adapter or Mediator?
transcript
Three patterns put a class in front of other classes. The interviewer asks: which is which? Say it in one breath.
An adapter fronts one class, and fits an interface that already exists. A facade fronts several, and invents a simpler interface. A mediator sits between peers, so they stop calling each other directly.
An adapter wraps one class. The client's interface was fixed in advance. It only makes that class fit. It invents nothing.
Look at a facade's arrows. They only go out. It calls the subsystem. The subsystem never calls it back. The subsystem doesn't know the facade exists.
Now a mediator. The arrows go both ways. Each colleague holds a reference to it, calls it, and is called by it. That is coordination. A facade is simplification.
The test is one question. Does it call back? No: a facade. Yes: a mediator. That is the whole interview answer.
Full breakdown in the lecture.