The prototype pattern is used whenever your object is very expensive, to create an example would be
creating a very complex object that requires a lot of memory to store all its properties and methods.
Usually the prototype pattern fits when your object is costly to create, and Cloninger object by copying
all its member variables would do the trick.
Some of its features are.
New objects are typically not created with new, but with clothing only the first instance would use
the keyword new and requiring other objects of the same type.
Nickel metal would be used instead.
Another feature is that this pattern makes use of an interface for implementing the prototype, for
instance, the interface is usually implementing learnable in order to allow Cloninger objects.
Also, it provides two methods for cloning or objects, shadow cloning and cloning.
The difference between the two is that the shadow clone will copy only the instance variables of an
object, whereas a decoding will copy the other object references as well.
Although the object is copied, each object instance will still be unique.
Some of the disadvantages can be the following.
It is not very clear when to use this pattern, a problem that is frequently seen in Singleton, too,
it is usually combined with other patterns, increasing the complexity of the code.
And the this advantage, in my opinion, is that the club that does only a shallow copy and to implement
a deep copy will definitely require an extra effort, which will eventually increase the complexity
of the code.
Let's take a look in the next video how we can implement this pattern in code.