In this series, I talk about design patterns and principles and show you how you can use them to improve the quality of your code. All examples are in Python.
Curated by: ArjanCodes (103 videos)
💡 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