The facade pattern
The facade pattern is perhaps one of the simplest of the structural pattern to understand and create. As its name suggests, it act as a face that sits in front of a complex system. When programming client code, we never have to concern ourselves with the complex logic of the rest of our system, if we have a facade to represent it. All we have to do is deal with the facade itself, and this means we can devise facades to maximize simplicity.
Think of the facade pattern like the simple keypad you might find on a typical vending machine. Vending machines are very complex systems, combining all manner of mechanical and physical components. However, to operate one, all we need is to know how to punch in a number or two on its keypad. The keypad is the facade and it hides all the complexity behind it. We can demonstrate this by considering the imaginary vending machine, outlined in the following steps:
Start by creating the following interface:
public interface Product { ...