Let's focus first on the program that will receive the facade, so basically we have a single interface
with only one method to be implemented and we have to object to the computer object, which will implement
this reform operation method with a sound argument and a robot object which will do the same, but with
a different it will output the different tacks here.
So this is an oversimplification, but imagine if you would have had a complex and very complex program
here with many other methods, many objects with a very complicated lifecycle.
It's not it's not a good practice to to leave to to expose this program to a client application.
It's better to have a facade like an interface that will manage all the operations and will will do
the will simplify all on the structure of the internal structure, will hide all the implementation
complexities and will expose just these operations that the client application is interested in.
So let's see this for.
So basically, it's using composition.
It has two objects, the computer and the robot object into a constructor itself.
It's initializing those those objects.
And it has two methods for a computer to perform operation and for the robot to perform operation.
So this is a very simple way to hide all the complexities of the underlying program.
And this is the main the main usage for the facade pattern and let's see destination's.
So in the main method here, we create a facade class, which will create an instance of the computer
at the robot class, and it will will have two lines here for performing the operations, using the
computer and the robot.
So let's see this in action.
So as you can see, the two lines are outputted here in the console.
Everything works as expected.
So instead of creating the objects yourself and supposedly doing some other complicated stuff, first
you have the facade class, which contains the final the end result.
Right.
That method that will perform the all the action, all the although all the flow of the application
and it will output the end result using a single method.
So much, much easier than having to call all the underlying program objects and dealing with the emotional
complexity of that of that program.
So that's about it.
This is a very simple design pattern to explain, Jean.
And next story where we are going to discuss about the flyweight pattern.