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.
All parts in this series:
Part 1: Cohesion and coupling - Ā Ā Ā ā¢Ā CohesionĀ andĀ Coupling:Ā WriteĀ BETTERĀ P...Ā Ā
Part 2: Dependency inversion - Ā Ā Ā ā¢Ā DependencyĀ Inversion:Ā WriteĀ BETTERĀ PY...Ā Ā
Part 3: The strategy pattern - Ā Ā Ā ā¢Ā TheĀ StrategyĀ Pattern:Ā WriteĀ BETTERĀ PY...Ā Ā
Part 4: The observer pattern - Ā Ā Ā ā¢Ā ObserverĀ PatternĀ Tutorial:Ā IĀ NEVERĀ Kn...Ā Ā
Part 5: Unit testing and code coverage - Ā Ā Ā ā¢Ā 100%Ā CODEĀ COVERAGEĀ -Ā ThinkĀ You'reĀ Don...Ā Ā
Part 6: Template method and bridge - Ā Ā Ā ā¢Ā TwoĀ UNDERRATEDĀ DesignĀ PatternsĀ š”Ā Writ...Ā Ā
Part 7: Exception handling - Ā Ā Ā ā¢Ā ExceptionĀ HandlingĀ TipsĀ inĀ PythonĀ ā Ā W...Ā Ā
Part 7b: Monadic error handling - Ā Ā Ā ā¢Ā MonadicĀ ErrorĀ HandlingĀ inĀ PythonĀ ā Ā Wr...Ā Ā
Part 8: Software architecture - Ā Ā Ā ā¢Ā WhyĀ YouĀ ShouldĀ ThinkĀ AboutĀ SOFTWAREĀ A...Ā Ā
Part 9: SOLID principles - Ā Ā Ā ā¢Ā UncleĀ BobāsĀ SOLIDĀ PrinciplesĀ MadeĀ Eas...Ā Ā
Part 10: Object creation patterns - Ā Ā Ā ā¢Ā QUESTIONABLEĀ ObjectĀ CreationĀ Patterns...Ā Ā
š”Here's my FREE 7-step guide to help you consistently design great software: https://arjancodes.com/designguide.
Relevant books:
- Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides: https://amzn.to/3jllgyH
- Principles of Package Design: Creating Reusable Software Components by Matthias Noback: https://amzn.to/2NETK3l
- Clean Code: A Handbook of Agile Software Craftsmanship by Robert Martin: https://amzn.to/3qVZgNs
- The original Design Principles and Design Patterns article by Robert Martin: https://fi.ort.edu.uy/innovaportal/fi...
š Courses:
The Software Designer Mindset: https://www.arjancodes.com/mindset
The Software Designer Mindset Team Packages: https://www.arjancodes.com/sas
The Software Architect Mindset: Pre-register now! https://www.arjancodes.com/architect
Next Level Python: Become a Python Expert: https://www.arjancodes.com/next-level...
The 30-Day Design Challenge: https://www.arjancodes.com/30ddc
š GEAR & RECOMMENDED BOOKS: https://kit.co/arjancodes.
You can find the code I worked on in this episode in my GitHub repository: https://github.com/arjancodes/betterp...
š 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
š If you enjoyed this content, give this video a like. If you want to watch more of my upcoming videos, consider subscribing to my channel!
DISCLAIMER - The links in this description might be affiliate links. If you purchase a product or service through one of those links, I may receive a small commission. There is no additional charge to you. Thanks for supporting my channel so I can continue to provide you with free content each week!
Watch video Observer Pattern Tutorial: I NEVER Knew Events Were THIS Powerful š online without registration, duration hours minute second in high quality. This video was added by user ArjanCodes 18 February 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 200,556 once and liked it 6.9 thousand people.