The Morning Dev

Only the news worth knowing

‹
 
  • AAPL 339.69 ▼ 1.30%
  • MSFT 527.18 ▼ 1.63%
  • NVDA 190.88 ▲ 5.11%
  • GOOGL 285.18 ▲ 0.92%
  • AMZN 259.61 ▼ 0.23%
  • META 608.49 ▲ 0.56%
  • TSLA 348.96 ▲ 1.53%
  • AVGO 311.13 ▲ 6.72%
  • TSM 378.73 ▲ 7.58%
  • ORCL 119.40 ▲ 3.77%
  • AMD 442.03 ▲ 9.31%
  • NFLX 63.91 ▼ 2.52%
  • CRM 216.51 ▼ 2.64%
  • ADBE 239.06 ▼ 2.99%
  • INTC 55.02 ▲ 5.29%
  • IBM 247.11 ▼ 2.84%
  • PLTR 158.38 ▲ 2.19%
  • SNOW 279.20 ▲ 3.56%
  • NET 281.86 ▲ 14.87%
  • SAP 233.82 ▼ 4.03%

Watch · Python and software design

The Memento Pattern: Saving State Without Breaking Encapsulation

ArjanCodes

Watch on YouTube ↗

Chapters

  1. 0:00Intro
  2. 1:20The Workflow
  3. 2:40Take a Snapshot
  4. 6:08Originator, Memento, and Caretaker
  5. 11:02What Should Be in the Snapshot?
  6. 12:03Undo and Redo
  7. 13:12Memento vs Command
  8. 14:01Beyond Undo
  9. 14:35When Not to Use It
  10. 15:07Final Thoughts
Show the full video 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 sounds simple until every change needs its own reverse logic. The Memento pattern offers a different approach: save an object's state and restore it when you need to go back. In this video, I show how to implement the Memento pattern in modern Python using snapshots, dataclasses, protocols, and generics. 🔥 GitHub Repository: https://git.arjan.codes/2026/memento. 💬 Join my Discord server: https://discord.arjan.codes. ⌨️ Keyboard I’m using: https://amzn.to/49YM97v. 🔖 Chapters: 0:00 Intro 1:20 The Workflow 2:40 Take a Snapshot 6:08 Originator, Memento, and Caretaker 11:02 What Should Be in the Snapshot? 12:03 Undo and Redo 13:12 Memento vs Command 14:01 Beyond Undo 14:35 When Not to Use It 15:07 Final Thoughts #arjancodes #softwaredesign #python

More from ArjanCodes

More to watch