Double Dispatch: Prelude to the Visitor Pattern

Double Dispatch: Prelude to the Visitor Pattern

2.355 Lượt nghe
Double Dispatch: Prelude to the Visitor Pattern
One reason the Visitor Pattern can feel confusing is because of double dispatch. So before we dive into the Visitor Pattern itself, let’s take a closer look at double dispatch—what it is, how it’s traditionally handled in single-dispatch languages, and how a few Kotlin language features can make it much simpler. 📘 My book, Kotlin: An Illustrated Guide is now available in paperback! https://www.amazon.com/Kotlin-Illustrated-Guide-Dave-Leeds/dp/B0F3Q1DKGX/ ✨ New to Kotlin? Start your journey here: https://typealias.com/start/ 🚀 Get the inside scoop on everything I'm working on - join my new email newsletter! Sign up here: https://newsletter.typealias.com/ 👨🏽‍💻 Source code for today's video: https://github.com/typealias-studios/video-2025-04-double-dispatch 📚 Chapters 00:00 Introduction 00:36 Dispatch and Multiple Dispatch 04:38 Simulating Double Dispatch in Kotlin 08:01 A Simpler Approach 09:48 Wrap-up