If we were to solve the main objective without the facade pattern, it would imply that we are working with the complex procedure directly in the working context.
As described in the previous section, the procedure of collecting rent requires three steps: finding the tenant’s address, contacting the tenant, and collecting the payment.
Each of the three steps are part of the Apartment-class. In the current context we have four instances of this class, which means that we would have to make twelve method calls to collect rent for all four apartments. (3 [Calls/Apartment] x 4 [Apartments] = 12 [Calls])
As we can see from the code example, this actually solves the main objective of collecting the rent. However, it does not help our landlord to fulfill the secondary objective of simplifying the procedure.
Since the landlord still have to manage the whole procedure for each apartment, the amount of code in the working context will continue to grow. This type of code does not uphold the DRY (Don’t Repeat Yourself) principle, neither is it maintainable (e.g. too long method – Link), and finally it leaves a code smell. (e.g. main-method does more than one thing – Link)
To say the least, this piece of code suffers from many problems. How to solve this? Well, let’s take a look at the facade pattern and see if it can help us out.