1 00:00:00,390 --> 00:00:05,190 Built pattern is another design pattern from the creation of design patterns category. 2 00:00:06,700 --> 00:00:13,420 The features of the Singleton pattern are the following, it prevents the instantiation of a class more 3 00:00:13,420 --> 00:00:14,000 than once. 4 00:00:14,350 --> 00:00:20,770 So basically you cannot create two objects of the same class, that class that implements the Singleton 5 00:00:20,770 --> 00:00:24,160 pattern and also provide single access to an object. 6 00:00:25,470 --> 00:00:28,010 Where can you use the singleton patterns? 7 00:00:28,910 --> 00:00:35,470 If, for example, your scope is to create a longer for for your actions, for the actions that your 8 00:00:35,480 --> 00:00:42,740 program performs, you can create a Singleton class that will log all the actions that your program 9 00:00:42,740 --> 00:00:43,340 executes. 10 00:00:43,850 --> 00:00:47,830 This is the example that we will use later on in our code. 11 00:00:49,130 --> 00:00:51,130 Another use case might be a report. 12 00:00:51,140 --> 00:00:56,420 So, for example, you want to create a report of your unique tests. 13 00:00:56,840 --> 00:01:03,440 So, for example, you don't you don't you don't want to use something, an external library that will 14 00:01:03,440 --> 00:01:05,720 do that for you and you want to implement your own. 15 00:01:05,990 --> 00:01:14,150 You may use the Singleton pattern to create such a report, a and also a cache. 16 00:01:14,720 --> 00:01:21,050 So it doesn't make sense to have multiple objects that will store your cache, some objects in your 17 00:01:21,050 --> 00:01:21,500 cache. 18 00:01:21,980 --> 00:01:26,780 It might make sense to have a single instance of an object that will store everything. 19 00:01:27,020 --> 00:01:31,580 And you can call this instance from many, many places in your code. 20 00:01:32,660 --> 00:01:39,140 Let's take a look in the code to see how exactly we can implement the Singleton pattern.