1 00:00:00,950 --> 00:00:05,840 The state button issues, whenever you want to change the state of your object, but you don't want 2 00:00:05,840 --> 00:00:08,550 to have these changes in the underlying class. 3 00:00:09,560 --> 00:00:14,930 It is a very good choice for factoring in classes where you use many, if else, statements. 4 00:00:16,430 --> 00:00:22,850 Imagine having a product in a store, the product can take multiple states, the product can be for 5 00:00:22,850 --> 00:00:25,700 sale or it can be sold or even borrowed. 6 00:00:26,180 --> 00:00:30,350 With this backing, you delegate the state changes to the respective state objects. 7 00:00:30,620 --> 00:00:37,190 So you won't need to rely on many, if any, statements to capture the changes in the state of the initial 8 00:00:37,190 --> 00:00:37,560 object. 9 00:00:39,140 --> 00:00:42,620 Looking at the U.N. diagram, the context object would be the product. 10 00:00:43,850 --> 00:00:47,750 The state interface will contain the contract for the state implementation. 11 00:00:48,800 --> 00:00:53,240 The context clause will delegate its state to the concrete state implementations. 12 00:00:54,230 --> 00:00:57,440 You can have many implementations, not just you, but for simplicity. 13 00:00:57,440 --> 00:01:00,250 The standard diagram for this matter includes only two. 14 00:01:01,040 --> 00:01:02,990 Let's see how this pattern can be implemented. 15 00:01:02,990 --> 00:01:03,470 Endako.