The Morning Dev

Only the news worth knowing

‹
 
  • AAPL 344.17 ▼ 1.53%
  • MSFT 535.93 ▼ 3.58%
  • NVDA 181.60 ▼ 9.26%
  • GOOGL 282.57 ▼ 2.20%
  • AMZN 260.21 ▼ 2.19%
  • META 605.08 ▼ 3.96%
  • TSLA 343.69 ▼ 10.77%
  • AVGO 291.53 ▼ 10.43%
  • TSM 353.10 ▼ 10.78%
  • ORCL 115.16 ▼ 6.93%
  • AMD 404.40 ▼ 17.26%
  • NFLX 65.56 ▼ 1.25%
  • CRM 222.41 ▼ 2.07%
  • ADBE 246.44 ▼ 0.82%
  • INTC 52.25 ▼ 10.33%
  • IBM 247.11 ▼ 2.84%
  • PLTR 154.99 ▼ 9.73%
  • SNOW 269.54 ▼ 7.25%
  • NET 244.51 ▼ 8.28%
  • SAP 243.53 ▲ 1.45%

Watch · Python and software design

The Visitor Pattern in Python (And Better Alternatives)

ArjanCodes

Watch on YouTube ↗

Chapters

  1. 0:00Intro
  2. 1:23Methods on the Nodes
  3. 2:41Pattern Matching Groups Code by Operation
  4. 3:53Classic Visitor
  5. 6:23The Design Problem
  6. 7:06The Dispatch Matrix Underneath Visitor
  7. 9:35Let Python Maintain the Matrix
  8. 11:46Final Thoughts
Show the full video description ›

💡 Learn how to design great software in 7 steps: https://arjan.codes/designguide. The Visitor pattern has a reputation for being complicated, but the problem it solves is actually quite simple: what happens when you keep adding new operations to the same set of objects? In this video, I use a document editor to compare several ways to solve that problem: methods, pattern matching, the classic Visitor pattern, a dispatch matrix, and Python’s `singledispatch`. More importantly, we’ll look at the trade-offs of each approach and when Visitor is actually worth using. 🔥 GitHub Repository: https://git.arjan.codes/2026/visitor. 💬 Join my Discord server: https://discord.arjan.codes. ⌨️ Keyboard I’m using: https://amzn.to/49YM97v. 🔖 Chapters: 0:00 Intro 1:23 Methods on the Nodes 2:41 Pattern Matching Groups Code by Operation 3:53 Classic Visitor 6:23 The Design Problem 7:06 The Dispatch Matrix Underneath Visitor 9:35 Let Python Maintain the Matrix 11:46 Final Thoughts #arjancodes #softwaredesign #python

More from ArjanCodes

More to watch