design-patterns-typescript icon indicating copy to clipboard operation
design-patterns-typescript copied to clipboard

Memento: caretaker shouldn't have access to state but it does

Open EDSprog opened this issue 1 year ago • 0 comments

In the memento conceptual example, you have the next interface of Memento that will be used by caretakers:

interface Memento  {
    getState(): string;
    getName(): string;
    getDate(): string;
}

Following the pattern - caretakers shouldn't have access to the state that memento stores. But with the above interface, we can call memnto.getState() in any caretaker and receive the state because caretakers operate with memntos with this interface.

EDSprog avatar May 16 '24 20:05 EDSprog