1 00:00:00,840 --> 00:00:06,630 The strategy pattern is a behavioral pattern which enables you to choose an algorithm at runtime. 2 00:00:08,070 --> 00:00:13,320 Like the state pattern, the strategy enables you to refactor a long switch case statements. 3 00:00:15,050 --> 00:00:20,750 According to this pattern, we can create strategies as objects and a complex object whose behavior 4 00:00:20,750 --> 00:00:23,830 varies depending on the chosen strategy. 5 00:00:25,000 --> 00:00:30,100 The strategy object changes the executing algorithm of the context object. 6 00:00:31,540 --> 00:00:37,500 Some of the drawbacks for this pattern are the fact that the client needs to know the strategies beforehand, 7 00:00:37,750 --> 00:00:43,120 in contrast to the state pattern where the client does not have to choose that object state. 8 00:00:44,580 --> 00:00:49,350 Also, it adds a bit of overhead because of the size that the cold may take. 9 00:00:50,460 --> 00:00:56,340 The problem is that if you have multiple strategies, you will have automatically a lot of classes in 10 00:00:56,340 --> 00:00:58,630 your code making it harder to maintain. 11 00:00:59,640 --> 00:01:02,430 Let's have a look at the implementation for this pattern in the code.