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 (99 videos)
💡 Learn how to design great software in 7 steps: https://arjan.codes/designguide. This tutorial on the observer pattern is the fourth part of my series on how to write better Python code, I show you how to use events to write code that's really easy to change and extend. Events are a variant of the observer / listener design pattern. This video is inspired by a real-life example I recently encountered, where implementing an event-based approach provided a great solution to a design problem I had. Next to showing how to use events in your code, you'll also see what the effect is on the cohesion and coupling of the functions you write. GitHub repository: https://github.com/arjancodes/betterpython. 🎓 ArjanCodes Courses: https://www.arjancodes.com/courses. 💬 Join my Discord server: https://discord.arjan.codes. ⌨️ Keyboard I’m using: https://amzn.to/49YM97v. 🔖 Chapters: 0:00 Intro 1:24 Explaining the code example 3:16 Analysis 4:45 Creating a simple event handler 7:19 Moving to an event-based approach 10:40 The complete solution 12:44 The power of an event-based system 14:12 Final thoughts