Memento Pattern
The Memento Pattern is a design pattern used in software development that allows an object to capture and store its internal state without exposing its details. This enables the object to be restored to a previous state later, which is particularly useful for implementing features like undo functionality in applications.
In this pattern, there are typically three components: the Originator, which is the object whose state needs to be saved; the Memento, which stores the state; and the Caretaker, which manages the memento but does not modify its content. This separation helps maintain encapsulation and allows for easy state management.