{"slug":"memento","group":"behavioral","title":"Memento","short":"Captures and restores an object's state without breaking its encapsulation.","icon":"save","aliases":[],"order":305,"status":"available","articleCount":2,"groupTitle":"Behavioral patterns","intro":"","servedLang":"en","primaryArticle":{"id":"6b08bd3a80884893657cc9b4","slug":"memento","title":"Memento: a state snapshot without breaking encapsulation","summary":"The Memento pattern through a menu editor: Halina saves versions of the menu and returns to them with one click, while the history keeps snapshots without seeing what is inside. Copies instead of references, memory costs and code in five languages.","servedLang":"en","availableLangs":["pl","en"],"topics":["memento"],"techs":["dotnet","typescript","java","go","python"],"tags":["gof","behavioral","memento","undo","snapshots","encapsulation"],"level":"intermediate","kind":"article","access":"members","status":"published","cover":null,"author":{"id":"6b08bd2e80884893657cc8cf","name":"Redakcja Art of Devs","avatar":null,"handle":"redakcja","community":false},"readingMinutes":13,"stats":{"views":2,"likes":0,"bookmarks":0,"comments":0},"publishedAt":"2026-11-26T23:14:02.576Z","updatedAt":"2026-11-27T13:10:08.081Z","challengeCount":2,"quizCount":0},"articles":[{"id":"6b08bd3c80884893657cc9f1","slug":"prototype","title":"Prototype – a new object as a copy of a ready-made template","summary":"Prototype creates objects by cloning a configured instance instead of building them from scratch. We explain the difference between shallow and deep copies using exam templates as an example.","servedLang":"en","availableLangs":["pl","en"],"topics":["prototype","abstract-factory","memento"],"techs":["dotnet","typescript","java","go","python"],"tags":["gof","creational","prototype","cloning","deep-copy"],"level":"intermediate","kind":"article","access":"members","status":"published","cover":null,"author":{"id":"6b08bd2e80884893657cc8cf","name":"Redakcja Art of Devs","avatar":null,"handle":"redakcja","community":false},"readingMinutes":10,"stats":{"views":3,"likes":0,"bookmarks":0,"comments":0},"publishedAt":"2026-11-26T23:14:04.737Z","updatedAt":"2026-11-27T13:04:32.155Z","relation":{"position":2,"primary":false,"mainTopic":{"slug":"prototype","title":"Prototype"}}}],"challenges":[{"id":"6b093dc191bd8fbaf2a0c8c8","slug":"game-checkpoint-memento","title":"Game checkpoints","summary":"Saving and restoring a hero's state with Memento – immutable snapshots without shared lists, a caretaker with limited capacity and protection against loading someone else's save.","servedLang":"en","availableLangs":["pl","en"],"kind":"code","category":"pattern","status":"published","difficulty":"easy","topics":["memento"],"techs":["typescript","javascript","python","dotnet","java","go"],"tags":["memento","snapshots","undo","immutability","behavioral"],"languages":["typescript","javascript","python","csharp","java","go"],"questionCount":null,"xp":10,"stats":{"attempts":0,"solves":0,"solutions":0,"comments":0},"solveRate":null,"publishedAt":"2026-11-27T08:22:25.224Z"},{"id":"6b093ddfbd4755deb67ee09b","slug":"serialize-binary-tree","title":"Serialize a binary tree","summary":"Write a binary tree to a string and rebuild it – with empty subtrees, negative numbers and trees thousands of levels deep. Format design, BFS and the recursion trap.","servedLang":"en","availableLangs":["pl","en"],"kind":"code","category":"algorithms","status":"published","difficulty":"hard","topics":["memento"],"techs":["typescript","javascript","python","dotnet","java","go"],"tags":["trees","binary-tree","bfs","dfs","serialization","design"],"languages":["typescript","javascript","python","csharp","java","go"],"questionCount":null,"xp":40,"stats":{"attempts":0,"solves":0,"solutions":0,"comments":0},"solveRate":null,"publishedAt":"2026-11-27T08:22:55.586Z"}],"resources":[{"id":"6b0857c53c96f2d34d0b4887","type":"video","provider":"youtube","url":"https://www.youtube.com/watch?v=ZXAt8AP3DnY","embedUrl":"https://www.youtube-nocookie.com/embed/ZXAt8AP3DnY","title":"The Memento Pattern: Saving State Without Breaking Encapsulation","description":"👨🏻‍💻 Join me in Utrecht next year for an in-person Software Design Retreat! Design, discuss, and learn alongside fellow developers. Join the waitlist: https://arjancodes.com/retreat. 🧱 Build software that lasts. Join the Software Design Mastery program → https://arjan.codes/mastery. Undo…","author":"ArjanCodes","thumbnailUrl":"https://i.ytimg.com/vi/ZXAt8AP3DnY/hqdefault.jpg","durationSec":null,"lang":"en","topics":["memento"],"techs":["python"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"youtube-rss","publishedAt":"2026-10-09T15:00:08.000Z","popularity":72,"verifiedAt":"2026-11-26T10:54:43.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:07.481Z","updatedAt":"2026-11-26T16:01:07.481Z"},{"id":"6b0857bf3c96f2d34d0b42d4","type":"article","provider":"web","url":"https://refactoring.guru/pl/design-patterns/memento","embedUrl":null,"title":"Pamiątka / Memento","description":"Pamiątka to behawioralny wzorzec projektowy pozwalający zapisywać i przywracać wcześniejszy stan obiektu bez ujawniania szczegółów jego implementacji.","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/pl/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"pl","topics":["memento"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":60,"verifiedAt":"2026-11-26T11:26:13.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"},{"id":"6b0857bb3c96f2d34d0b4009","type":"podcast","provider":"apple-podcasts","url":"https://podcasts.apple.com/us/podcast/design-patterns-part-4-adapter-facade-and-memento/id769189585?i=1000378375293","embedUrl":"https://embed.podcasts.apple.com/us/podcast/id769189585?i=1000378375293","title":"Design Patterns Part 4 – Adapter, Facade, and Memento","description":"Part 4 of our design patterns series, this time up it's Adapters, Facades, and Mementos. Oh, an which tech luminary would make the best head of state!","author":"Coding Blocks","thumbnailUrl":"https://is1-ssl.mzstatic.com/image/thumb/Podcasts113/v4/f0/b6/68/f0b6682f-e8bc-181c-95a9-0756ddf63d6e/mza_3128980961332034780.jpg/600x600bb.jpg","durationSec":4452,"lang":"en","topics":["adapter","facade","memento"],"techs":["general"],"tags":["podcast","design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"itunes","publishedAt":"2015-07-26T12:00:44.000Z","popularity":46,"verifiedAt":"2026-11-26T10:57:39.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:57.868Z","updatedAt":"2026-11-26T16:00:57.868Z"},{"id":"6b0857c33c96f2d34d0b4658","type":"book","provider":"openlibrary","url":"https://openlibrary.org/works/OL6030812W","embedUrl":null,"title":"Design Patterns: Elements of Reusable Object-Oriented Software","description":"","author":"Erich Gamma, John Vlissides, Richard Helm, Ralph Johnson","thumbnailUrl":"https://covers.openlibrary.org/b/id/6601119-L.jpg","durationSec":null,"lang":"en","topics":["factory-method","abstract-factory","builder","prototype","singleton","adapter","bridge","composite","decorator","facade","flyweight","proxy","chain-of-responsibility","command","iterator","mediator","memento","observer","state","strategy","template-method","visitor"],"techs":["general"],"tags":["book","design-patterns"],"price":"paid","featured":false,"featuredOrder":0,"packageName":null,"source":"openlibrary","publishedAt":"1995-01-01T00:00:00.000Z","popularity":71,"verifiedAt":"2026-11-26T11:00:08.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:04.995Z","updatedAt":"2026-11-26T16:01:04.995Z"},{"id":"6b0857bf3c96f2d34d0b427e","type":"article","provider":"web","url":"https://refactoring.guru/design-patterns/memento","embedUrl":null,"title":"Memento","description":"Memento is a behavioral design pattern that lets you save and restore the previous state of an object without revealing the details of its implementation.","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"en","topics":["memento"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":65,"verifiedAt":"2026-11-26T11:26:05.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"}],"resourceGroups":[{"type":"video","items":[{"id":"6b0857c53c96f2d34d0b4887","type":"video","provider":"youtube","url":"https://www.youtube.com/watch?v=ZXAt8AP3DnY","embedUrl":"https://www.youtube-nocookie.com/embed/ZXAt8AP3DnY","title":"The Memento Pattern: Saving State Without Breaking Encapsulation","description":"👨🏻‍💻 Join me in Utrecht next year for an in-person Software Design Retreat! Design, discuss, and learn alongside fellow developers. Join the waitlist: https://arjancodes.com/retreat. 🧱 Build software that lasts. Join the Software Design Mastery program → https://arjan.codes/mastery. Undo…","author":"ArjanCodes","thumbnailUrl":"https://i.ytimg.com/vi/ZXAt8AP3DnY/hqdefault.jpg","durationSec":null,"lang":"en","topics":["memento"],"techs":["python"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"youtube-rss","publishedAt":"2026-10-09T15:00:08.000Z","popularity":72,"verifiedAt":"2026-11-26T10:54:43.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:07.481Z","updatedAt":"2026-11-26T16:01:07.481Z"}]},{"type":"podcast","items":[{"id":"6b0857bb3c96f2d34d0b4009","type":"podcast","provider":"apple-podcasts","url":"https://podcasts.apple.com/us/podcast/design-patterns-part-4-adapter-facade-and-memento/id769189585?i=1000378375293","embedUrl":"https://embed.podcasts.apple.com/us/podcast/id769189585?i=1000378375293","title":"Design Patterns Part 4 – Adapter, Facade, and Memento","description":"Part 4 of our design patterns series, this time up it's Adapters, Facades, and Mementos. Oh, an which tech luminary would make the best head of state!","author":"Coding Blocks","thumbnailUrl":"https://is1-ssl.mzstatic.com/image/thumb/Podcasts113/v4/f0/b6/68/f0b6682f-e8bc-181c-95a9-0756ddf63d6e/mza_3128980961332034780.jpg/600x600bb.jpg","durationSec":4452,"lang":"en","topics":["adapter","facade","memento"],"techs":["general"],"tags":["podcast","design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"itunes","publishedAt":"2015-07-26T12:00:44.000Z","popularity":46,"verifiedAt":"2026-11-26T10:57:39.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:57.868Z","updatedAt":"2026-11-26T16:00:57.868Z"}]},{"type":"article","items":[{"id":"6b0857bf3c96f2d34d0b42d4","type":"article","provider":"web","url":"https://refactoring.guru/pl/design-patterns/memento","embedUrl":null,"title":"Pamiątka / Memento","description":"Pamiątka to behawioralny wzorzec projektowy pozwalający zapisywać i przywracać wcześniejszy stan obiektu bez ujawniania szczegółów jego implementacji.","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/pl/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"pl","topics":["memento"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":60,"verifiedAt":"2026-11-26T11:26:13.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"},{"id":"6b0857bf3c96f2d34d0b427e","type":"article","provider":"web","url":"https://refactoring.guru/design-patterns/memento","embedUrl":null,"title":"Memento","description":"Memento is a behavioral design pattern that lets you save and restore the previous state of an object without revealing the details of its implementation.","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"en","topics":["memento"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":65,"verifiedAt":"2026-11-26T11:26:05.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"}]},{"type":"book","items":[{"id":"6b0857c33c96f2d34d0b4658","type":"book","provider":"openlibrary","url":"https://openlibrary.org/works/OL6030812W","embedUrl":null,"title":"Design Patterns: Elements of Reusable Object-Oriented Software","description":"","author":"Erich Gamma, John Vlissides, Richard Helm, Ralph Johnson","thumbnailUrl":"https://covers.openlibrary.org/b/id/6601119-L.jpg","durationSec":null,"lang":"en","topics":["factory-method","abstract-factory","builder","prototype","singleton","adapter","bridge","composite","decorator","facade","flyweight","proxy","chain-of-responsibility","command","iterator","mediator","memento","observer","state","strategy","template-method","visitor"],"techs":["general"],"tags":["book","design-patterns"],"price":"paid","featured":false,"featuredOrder":0,"packageName":null,"source":"openlibrary","publishedAt":"1995-01-01T00:00:00.000Z","popularity":71,"verifiedAt":"2026-11-26T11:00:08.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:04.995Z","updatedAt":"2026-11-26T16:01:04.995Z"}]}],"siblings":[{"slug":"chain-of-responsibility","title":"Chain of Responsibility","icon":"link","status":"available","current":false},{"slug":"command","title":"Command","icon":"terminal","status":"available","current":false},{"slug":"iterator","title":"Iterator","icon":"list-ordered","status":"available","current":false},{"slug":"mediator","title":"Mediator","icon":"messages-square","status":"available","current":false},{"slug":"memento","title":"Memento","icon":"save","status":"available","current":true},{"slug":"observer","title":"Observer","icon":"eye","status":"available","current":false},{"slug":"state","title":"State","icon":"toggle-right","status":"available","current":false},{"slug":"strategy","title":"Strategy","icon":"route","status":"available","current":false},{"slug":"template-method","title":"Template Method","icon":"layout-template","status":"available","current":false},{"slug":"visitor","title":"Visitor","icon":"footprints","status":"available","current":false}]}