The next batter that we are going to discuss is the factory pattern, so the factory pattern is one
of the most common design patterns out there and definitely it's widely used even by the developers
that created Java, one of the libraries that are inside that sit inside core Java distribution.
The calendar, the calendar framework is created using the factory budget.
Basically, according to this pattern, you create an object factory that will create whatever object
you may need.
Let's discuss a bit about the advantages of using the factory pattern so it will hide the internal logic
of creating objects.
The client will know next to nothing about what it takes to create your object.
It will enable the programmer to add different objects of the same type.
So basically you will need to modify anything to in order to add a new object, you will just make use
of of the factory and you will extend its capabilities to create other objects as well.
Some of the disadvantages are the complexity of this pattern.
So it's quite complex.
And you will see from the diagram that it's actually a bit difficult to to implement it.
And also, you cannot refactor your current code into a factory either.
You will need to think about using factory pattern from the beginning.
This is an example that we will use in our code.
So basically we have an interface old computer.
The computer will have a method called compute and there were there will be three objects that will
implement this interface.
So we will have laptop, phone and smart TV.
All three of them will have different computer implementations.
And alongside them you will have a computer, you have a computer factory actually that will have a
method, get a computer that will return a type of computer.
One of the three objects that implement this this interface.
So let's see in the code how this looks like.