1 00:00:01,080 --> 00:00:05,440 The mental pattern is used whenever you want to restore an object to a previous state. 2 00:00:06,740 --> 00:00:10,400 This is equivalent to providing an undue functionality in your application. 3 00:00:12,260 --> 00:00:18,380 An example of usage of this pattern in the Java API are the Java dot to date into Java that are your 4 00:00:18,590 --> 00:00:20,000 serializable interface. 5 00:00:21,580 --> 00:00:25,900 The serializable interface allows you to have an object with regretable state. 6 00:00:27,990 --> 00:00:33,600 This is how the UML diagram, for this matter, looks like we have an originator, which is the object 7 00:00:33,600 --> 00:00:39,180 for which we want to perform a snapshot than the mental object contains the state of the originator 8 00:00:39,360 --> 00:00:41,670 and it is also able to retrieve that state. 9 00:00:43,200 --> 00:00:46,530 A copy of the state is safe in the caretaker class. 10 00:00:47,980 --> 00:00:53,510 Some of the weaknesses are it can create a memory overhead by storing multiple states of an object. 11 00:00:54,760 --> 00:00:59,110 This can be addressed by deleting the history of states after a certain number of states. 12 00:01:00,300 --> 00:01:05,490 Also, the information about the originator may be exposed to this matter, and this is why you need 13 00:01:05,490 --> 00:01:09,920 to be extra careful when dealing with this and not exposing the state to other objects. 14 00:01:09,960 --> 00:01:10,890 Just a moment of. 15 00:01:12,300 --> 00:01:14,680 Let's see how this button can be implemented in local.