Facade
In different implementations and approaches, Facade may resemble either an Adapter or anAbstract Factory.
Its goal seems straightforward—to simplify interacting with another class or a family of classes:
- When we think aboutsimplifying, we usually think of the Adapter design pattern
- When we think about the family of classes, we usually think of an Abstract Factory
That's where all the confusion usually comes from. To better understand it, let's go back to the example we used for the Abstract Factory design pattern.
Keep it simple
Let's say that we would like to implement the loadGame()
method. This method would take a file we already created (we'll discuss how later), or, at the least, the following will be required:
- At least two HQs will fave to be created (otherwise, the game is already won)
- Each HQ will have to produce the buildings it had
- Each building will have to produce the units it had
- All units will have to magically teleport to the positions they were at when the game was saved
- If...