1 00:00:00,690 --> 00:00:06,480 The prototype pattern is used whenever your object is very expensive, to create an example would be 2 00:00:06,480 --> 00:00:12,060 creating a very complex object that requires a lot of memory to store all its properties and methods. 3 00:00:13,200 --> 00:00:19,140 Usually the prototype pattern fits when your object is costly to create, and Cloninger object by copying 4 00:00:19,140 --> 00:00:21,240 all its member variables would do the trick. 5 00:00:22,490 --> 00:00:23,990 Some of its features are. 6 00:00:25,160 --> 00:00:31,190 New objects are typically not created with new, but with clothing only the first instance would use 7 00:00:31,190 --> 00:00:34,850 the keyword new and requiring other objects of the same type. 8 00:00:35,210 --> 00:00:37,160 Nickel metal would be used instead. 9 00:00:38,510 --> 00:00:43,190 Another feature is that this pattern makes use of an interface for implementing the prototype, for 10 00:00:43,190 --> 00:00:49,820 instance, the interface is usually implementing learnable in order to allow Cloninger objects. 11 00:00:51,630 --> 00:00:56,470 Also, it provides two methods for cloning or objects, shadow cloning and cloning. 12 00:00:57,240 --> 00:01:02,790 The difference between the two is that the shadow clone will copy only the instance variables of an 13 00:01:02,790 --> 00:01:08,060 object, whereas a decoding will copy the other object references as well. 14 00:01:10,280 --> 00:01:14,570 Although the object is copied, each object instance will still be unique. 15 00:01:17,180 --> 00:01:20,060 Some of the disadvantages can be the following. 16 00:01:21,290 --> 00:01:26,830 It is not very clear when to use this pattern, a problem that is frequently seen in Singleton, too, 17 00:01:27,800 --> 00:01:31,700 it is usually combined with other patterns, increasing the complexity of the code. 18 00:01:32,300 --> 00:01:38,240 And the this advantage, in my opinion, is that the club that does only a shallow copy and to implement 19 00:01:38,240 --> 00:01:43,220 a deep copy will definitely require an extra effort, which will eventually increase the complexity 20 00:01:43,220 --> 00:01:43,730 of the code. 21 00:01:44,960 --> 00:01:48,530 Let's take a look in the next video how we can implement this pattern in code.