Observer Pattern Tutorial: I NEVER Knew Events Were THIS Powerful 🚀

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ส.ค. 2024
  • 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:...
    Part 2: Dependency inversion - • Dependency Inversion: ...
    Part 3: The strategy pattern - • The Strategy Pattern: ...
    Part 4: The observer pattern - • Observer Pattern Tutor...
    Part 5: Unit testing and code coverage - • 100% CODE COVERAGE - T...
    Part 6: Template method and bridge - • Two UNDERRATED Design ...
    Part 7: Exception handling - • Exception Handling Tip...
    Part 7b: Monadic error handling - • Monadic Error Handling...
    Part 8: Software architecture - • Why You Should Think A...
    Part 9: SOLID principles - • Uncle Bob’s SOLID Prin...
    Part 10: Object creation patterns - • QUESTIONABLE Object Cr...
    💡Here's my FREE 7-step guide to help you consistently design great software: arjancodes.com/designguide.
    Relevant books:
    - Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides: amzn.to/3jllgyH
    - Principles of Package Design: Creating Reusable Software Components by Matthias Noback: amzn.to/2NETK3l
    - Clean Code: A Handbook of Agile Software Craftsmanship by Robert Martin: amzn.to/3qVZgNs
    - The original Design Principles and Design Patterns article by Robert Martin: fi.ort.edu.uy/innovaportal/fi...
    🎓 Courses:
    The Software Designer Mindset: www.arjancodes.com/mindset
    The Software Designer Mindset Team Packages: www.arjancodes.com/sas
    The Software Architect Mindset: Pre-register now! www.arjancodes.com/architect
    Next Level Python: Become a Python Expert: www.arjancodes.com/next-level...
    The 30-Day Design Challenge: www.arjancodes.com/30ddc
    🛒 GEAR & RECOMMENDED BOOKS: kit.co/arjancodes.
    You can find the code I worked on in this episode in my GitHub repository: 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!

ความคิดเห็น • 360

  • @ArjanCodes
    @ArjanCodes  3 ปีที่แล้ว +52

    Event systems are a good example of a design that results in code with low coupling and strong cohesion. This video delves into coupling and cohesion in more detail: th-cam.com/video/eiDyK_ofPPM/w-d-xo.html.

    • @qizhang5749
      @qizhang5749 3 ปีที่แล้ว +3

      Any real world use cases in python systems?

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว +11

      Absolutely. I think events are particularly useful in backend systems, where you need to perform different tasks depending on what happens. There's an example in the video about performing tasks such as sending a welcome email after a user has registered. Event systems are very useful for that, since it allows you to group/batch operations. I didn't mention specific backend platforms, but for example Django has something called Signals, which is a variation of an event system, see: docs.djangoproject.com/en/3.1/topics/signals/

    • @isofruitfruit9357
      @isofruitfruit9357 3 ปีที่แล้ว +2

      @@ArjanCodes Hah! Just used that a couple days ago to keep data in sync between my main database and a search database.
      In slightly different words I think events make sense particularly when the actual events you are firing don't inherently seem like they belong together (Sending a slack message doesn't seem like it inherently "belongs" with sending an email for example). So when you're effectively just working through "ToDo" lists for a given action. Observer patterns allow you very neatly to create and store such todo lists in the observing object, in this case the subscriber dictionary. Would you agree with that assessment so far?

    • @janekschleicher9661
      @janekschleicher9661 ปีที่แล้ว +1

      @@qizhang5749 Especially in backend services, you'll often use asynchronous event management systems like Celery, RabbitMQ, Kafka, ... . Typical use case is that you have a web application where some tasks need to be triggered that could take a while and maybe even shouldn't be part of the web application, just as they need completely different dependencies or hardware requirements. E.g. because the do heavy computations, some machine learning stuff, or just have to make external requests on their own with a high latency, or you'll trigger a batch job and are only interested to get the results, once the job is done. Then one option would be to build up this as microservices, call them asynchronously, fetch the results and deliver from the web application. Works, but it is highly coupled and not very robust if either the web application or the microservices crash or get updated inbetween. Or, you build some stand alone workers doing these jobs, but let them communicate via events. Those jobs will have to communicate back via a job_done kind of event, but in the end, you have a very decoupled, easy scalable (just add more workers if you need more) way to get your jobs done and if the messaging system is persistent and ensures messages get delivered, everything will work even on crashes or system updates. In addition, from a practical point of view, you also get a nice automatic logging of what happens when in your system. Feed the messages into a log aggregation and a dashboard and you can built up dashboards, alerting and ad hoc introspection to your running system, even though it might work distributed or even in different programming languages. The latter, in principle, works also with logging, but this is something you have to do by hand when programming, while an event driven system automatically can keep track of all (important) events, what is really useful in practice. It's definitely better than having to reverse engineer foreigners code in case of problems.
      This also is very useful for smaller projects. I've been using celery + django admin panel multiple times to easily have all of this from above for close to no extra project costs or exploding tech stack (assuming django already included). You can even fire with django admin panel actions such events or autoschedule some or configure to ignore specific messages and so on.

  • @RoamingAdhocrat
    @RoamingAdhocrat 3 ปีที่แล้ว +54

    Arjan: "I'm going to show you how to use the Observer pattern…"
    Me:

  • @MatheusAugustodaSilva
    @MatheusAugustodaSilva 2 ปีที่แล้ว +50

    I love the sense of humour all over the place. Your tutorials are the first ones that actually managed to get me interested in design patterns. Please never stop making videos!

    • @ArjanCodes
      @ArjanCodes  2 ปีที่แล้ว +7

      Thank you Matheus, I’m not planning to stop, no worries ;).

  • @fat_pigeon
    @fat_pigeon 2 ปีที่แล้ว +20

    Clear and useful explanation! Using an observer can be extended to abstract over the event transport. Then you can do things like retry failures or even plug in a distributed pub/sub system.
    Constructive feedback: I would like if you spent a little time to also cover limitations/drawbacks of the pattern you're discussing in each video, and the circumstances when it would be inappropriate or overkill. Design patterns are tools for architecting software, and it's important to know when each tool is the best for the job, and also when one should look for a different tool.

  • @willemvdk4886
    @willemvdk4886 3 ปีที่แล้ว +41

    These kinds of tutorials are incredibly refreshing! Thanks, Arjan!
    Most programming tutorials are about either learning a language, a framework or building some kind of bogus app. These topics are usefull of course, but at a point they will either be too basic or too specific. Your video's are both advanced/expert level AND generic enough to be interesting/educational for a lot of programmers. Kudo's, vriend!

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว +7

      Hi Willem, thank you very much - glad you like the videos! You're absolutely right: I try to create content that is interesting for intermediate/advanced developers but at the same time is not a very specific recipe for something, but a bit more generic.

  • @jeanhadrien
    @jeanhadrien 3 ปีที่แล้ว +22

    This is insane quality content, keep it up !

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว +1

      Thank you so much!

  • @CodingEntrepreneurs
    @CodingEntrepreneurs 3 ปีที่แล้ว +48

    Great video! Keep up the great work. Looking forward to watching more.

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      Thank you so much! :)

  • @bilbo1337
    @bilbo1337 3 ปีที่แล้ว +54

    Just want to complement the production quality of this tutorial, both the editing and content are great!

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว +1

      That’s very kind - thank you!

  • @TheWarmestWaffle
    @TheWarmestWaffle 3 ปีที่แล้ว +21

    Arjan if you keep up these videos, this channel is going to explode. As an amateur python user who has gone through some Kaggle courses, freeCodeCamp courses, and primarily written code as a hobby and as a necessity when needs have arisen, these videos are phenomenal and engaging content. I took the time to like and comment, and am subscribing and look forward to future content!

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว +4

      Thanks so much - that's really kind. I'm glad you're enjoying the videos!

  • @rishanriyal
    @rishanriyal 3 ปีที่แล้ว +12

    Never commented on a Programming video before, the way u presented the whole idea made me to comment on. Kudos, and keep up the good work.

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว +3

      Thank you Rishan, that’s so kind and happy you are enjoying it.

  • @Omnifarious0
    @Omnifarious0 3 ปีที่แล้ว +5

    I would not have decoupled logging in that way. That feels integral to what the function is supposed to do. And I like logs to be very obviously and simply related to code that's doing the logging.
    But yes, this pattern is powerful and useful, and the example you chose was (aside from the logging bit) compelling.

  • @ishaanme91
    @ishaanme91 ปีที่แล้ว

    This is such a useful pattern that can be applied in so many of the automations I work on day to day. Thank you for the wonderful content you create on this channel!

  • @grantwilliams630
    @grantwilliams630 3 ปีที่แล้ว +8

    This is my favorite pattern. Event-based programming works amazingly well with micro services and allows you to super easily scale asymmetrically i.e. the ML portion of your architecture vs the I/O portion.

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว +1

      Couldn't agree more!

  • @thatguy6664
    @thatguy6664 3 ปีที่แล้ว +1

    Thank you. I'm looking forward to the rest of the series. This type of content is rare, much needed and much appreciated!

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      Thank you and glad that you’re enjoying the videos!

  • @mateuszrosiek1668
    @mateuszrosiek1668 2 ปีที่แล้ว

    Just wow. Such good practical example of refactor using observer pattern. It really helps because as you said there are lot of examples out there but they are ridiculously simple or not very much useful to fully grasp the advantages of this approach. Definitely your channel deserves subscription so one could become rightful observer :D

  • @SuperSlugger94
    @SuperSlugger94 3 ปีที่แล้ว +1

    These videos provide so much help for me! As you said, there are a lot of tutorials out there on design pattern recepies but no one really explains when it might be a good idea to use them and their advantages when it comes to get a better cohesion and decoupling your code.
    This channel is a real treasure trove!
    Cheers from Sweden

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      Glad you like the videos Mikael!

  • @eatcheese5486
    @eatcheese5486 3 ปีที่แล้ว +7

    Great overview! There are tons of use-cases for this, I'm glad to have now seen a concrete example of how to use it. And fun fact, this would have helped me in an interview with Amazon about a year ago!

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว +1

      Thank you Mark, and that’s an interesting story. So did you get the job? :)

  • @lordGaruda
    @lordGaruda 2 ปีที่แล้ว

    Your attention to details, all the way down to the volume of the background music, is immaculate.

  • @golammuhaimeen2825
    @golammuhaimeen2825 3 ปีที่แล้ว

    Arjan really great work my man! I'm enjoying your series here

  • @AmirIskandar
    @AmirIskandar 3 ปีที่แล้ว

    This is genuinely high quality stuff. Keep it up!

  • @RabidHobbit
    @RabidHobbit 2 ปีที่แล้ว

    I really appreciate that you built the event system to show its internal workings instead of using an existing library, thanks!

  • @gibblesbits8303
    @gibblesbits8303 3 ปีที่แล้ว

    I feel honored to have found your channel when you are still so new. You are amazing at explaining these things so thank you!

  • @richardbrown1300
    @richardbrown1300 3 ปีที่แล้ว +1

    I love that you showed the UML and explained the concept really well before hand. Event handlers are used in so many places but it is not always clear what is going on when you look at existing usages.

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      Happy you are enjoying the video, Richard!

  • @cazzbr
    @cazzbr 3 ปีที่แล้ว

    Great tutorial! Thanks for sharing your knowledge with us. It was easy to follow and it's very informative. Keep the good work if you can!

  • @pratibhagupta1281
    @pratibhagupta1281 ปีที่แล้ว

    Loved your way of explaining the complex concepts in easier way. Thank you ♥

  • @_indrid_cold_
    @_indrid_cold_ 2 ปีที่แล้ว

    This video and the series in general is absolute dynamite! I cannot thank you enough. This is exactly the kind of content I have spent a fortune searching for in books and Udemy courses - and not been able to find. In fact I was beginning to think there was something seriously wrong with what I am doing because no-one seemed to be seeking answers to the problems you are tackling head on. No one seemed to be passionate about smarter ways to compose code to get the job done 'beautifully'.
    I now tend to think that I know enough to be useful about the language itself, what I was screaming out for is 'technique' , or maybe more formally, the design patterns. You not only describe the design pattern but you are providing the real world context that makes the learning content land squarely and penetrate this stupid old worn out brain of mine.
    You are addressing problems and challenges that speak precisely to where I am. I have written variations on your starting code scores of times - always realising deep inside that there had to be better ways to achieve beauty. Your content is lighting up those dark places. When you shook your head and said there was a better way - I literally got shivers.
    How can we support these? Do you have a Patreon? Have you written any books? Have you considered making a video based training course? How can I consume more of what you have to offer?
    Thank you most sincerely.

    • @ArjanCodes
      @ArjanCodes  2 ปีที่แล้ว

      I’m happy the videos are helpful to you, and thanks so much for your BMAC support! I’m working on a full blown online course on software design that will come out before Christmas. If you sign up for my email list via my website, you’ll be the first to know when it’s out!

  • @sirk390
    @sirk390 3 ปีที่แล้ว +51

    7:12 you should really use a "defaultdict(list)" instead of those two if conditions

    • @raphael9052
      @raphael9052 3 ปีที่แล้ว +1

      Sweet thinking!

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว +25

      Thank you, and that’s a great tip - I didn’t know about defaultdict, and I’ll definitely start using that more often.

    • @levblit3721
      @levblit3721 3 ปีที่แล้ว

      @@sieyk There's no need for imports with dict.setdefault(key, default)

    • @sieyk
      @sieyk 3 ปีที่แล้ว

      @@levblit3721 you can't set default to an array

    • @levblit3721
      @levblit3721 3 ปีที่แล้ว

      @@sieyk you are correct, didn't think of that

  • @bryan_hiebert
    @bryan_hiebert 3 ปีที่แล้ว

    A very good explanation! I have been trying to learn design patterns for awhile and this is one of the most understandable examples I have ever seen. Thank you!

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      You’re very welcome Bryan, I happy you enjoyed the video.

  • @santiagobustamante970
    @santiagobustamante970 2 ปีที่แล้ว

    I'm so glad I found you, thank you!!!

  • @MSSMusChaos
    @MSSMusChaos 2 ปีที่แล้ว

    OMG, this is a life saver, as a self-taught developer, this was something that I always encountered throughout my coding journey.
    This must be something that I can help make my life easier, thank you so much.

  • @fazzah777
    @fazzah777 3 ปีที่แล้ว

    Subbed. You have a great way with explaining things! Quality content!

  • @guillermokeller1985
    @guillermokeller1985 3 ปีที่แล้ว +2

    This channel became my favorite python channel. Thanks for your work, I'm learning a lot!!!!

  • @UrbanAI
    @UrbanAI 3 ปีที่แล้ว

    What could be better than illustrative examples! Thank you!

  • @grzegorzryznar5101
    @grzegorzryznar5101 2 ปีที่แล้ว

    Very useful video. Thanks for posting it!

  • @k98killer
    @k98killer ปีที่แล้ว +1

    Good overview. I tend to use Enums with specific single byte values rather than strings for the sake of smaller packed messages, either when storing or when transmitting over a network.

  • @informatik01
    @informatik01 2 ปีที่แล้ว

    Wow, a really nice tutorial: short, to the point and with simple examples.
    Great job, thanks! 👍

    • @ArjanCodes
      @ArjanCodes  2 ปีที่แล้ว +1

      Thank you, glad you enjoyed it!

  • @orie239
    @orie239 2 ปีที่แล้ว

    Is it a coincidence that I started reading the same book about Design Patterns and I suddenly come across your channel? Brilliant.

  • @kosmonautofficial296
    @kosmonautofficial296 2 ปีที่แล้ว

    Great video thanks so much! I am new to programming and python but I have recently finished some of my first projects. I see that I have a lot of things I could do to go back and improve. My first script was one giant for loop with no functions and like 1000 lines, then my next project was built with classes and functions but my main function is still 400 lines. Going to see if I can go back some time and really cut that down, add in unit testing, and then think about the design better. I hadn't considered these events or abstract classes and I could see that being very useful as these programs grow.

  • @djl3009
    @djl3009 3 ปีที่แล้ว +1

    Really like this pub/sub variation of Observer. It it seems to achieve much lower coupling via cleaner separation of concerns for most practical implementations. This has inspired me to consider the Observer pattern more often.

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      Happy to hear you enjoyed it!

  • @777dmaster
    @777dmaster 2 ปีที่แล้ว

    15 minutes well spent! Thank you!

  • @hchattaway
    @hchattaway 2 ปีที่แล้ว +1

    This was perfect! I've been using C# for about 20 years and always used a pub/sub event aggregator and was hoping there was something similar in Python.. and this was a great example of it.. will be using this right away.. The native event handling in .NET was always confusing and hard to follow.

  • @samjoel4152
    @samjoel4152 3 ปีที่แล้ว

    This channel has such an amazing content. Pls continue doing this👍👍👍

  • @mikec64
    @mikec64 3 ปีที่แล้ว

    These videos have been really helpful -- a bridge between concepts and code. Thank you.

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      Hi Mike, glad they've been helpful to you.

  • @beyondcatastrophe_
    @beyondcatastrophe_ 3 ปีที่แล้ว +36

    Something to mention is that, especially when used internally, events can obscure the flow of code. In the first code, it was pretty clear, what happens. Using events, since the `subscribe` calls can be anywhere (and anytime), it is not immediately clear which functions actually get called. This is even more difficult with `unsubscribe` in the mix.

    • @rick2591
      @rick2591 3 ปีที่แล้ว +2

      Correct, the event model can sometimes get confusing. It becomes problematic when multiple events fire off for the same action.

    • @TheProtein83
      @TheProtein83 8 หลายเดือนก่อน

      Usually this is solved writing good documentation

  • @edgeeffect
    @edgeeffect 3 ปีที่แล้ว

    I already do patterns OOP, etc in other languages. But my Python has always been for very short scripts only... trying to "up my Python game", these little tutorials are really useful. :)
    Your screens are very readable too... which certainly isn't the case with many tutorials on TH-cam... And you delivery the voiceover with a sane, calm style too... all in all, very good... keep up The Great Work.
    This is the first programming tutorial series where I haven't thought "Who is this annoying (random insulting term)? I can't bear to watch this!"... look I've even subscribed.

  • @tim_hughes
    @tim_hughes 3 ปีที่แล้ว

    Thank you for this playlist. It is very coherent and at a good pace. I have sent then around my local python group. Looking forward to more in the series. :-)

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      Thank you, Tim, I'm happy you're enjoying it. More will come in the near future ;).

  • @odnanref
    @odnanref 3 ปีที่แล้ว

    That was an awesome and concise example of the observer pattern. thanks!

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      Thanks, glad you're enjoying it :).

  • @jonathanheadley2729
    @jonathanheadley2729 2 ปีที่แล้ว

    I hope your channel grows! Also, I recently downloaded your software design guide and I'm already using it for some projects at work!

    • @ArjanCodes
      @ArjanCodes  2 ปีที่แล้ว

      Happy to hear that!

  • @loveleshsharma5663
    @loveleshsharma5663 2 ปีที่แล้ว

    This video really helped! The example using which you have demonstrated the pattern is not just like how to implement observer pattern, but how we can make use of this pattern in a real world scenario. Thank you so much :-)

    • @ArjanCodes
      @ArjanCodes  2 ปีที่แล้ว

      You're welcome - glad you enjoyed the video!

  • @mrdbourke
    @mrdbourke 2 ปีที่แล้ว

    Another fantastic video Arjan! I've had this exact problem building a machine learning system: someone uploads new data, then I want to train a model when X amount of new data is added. The observer pattern looks perfect.
    PS congratulations on 100k!

  • @ddctechinstitute6861
    @ddctechinstitute6861 ปีที่แล้ว

    You are great Arjan. Much love 🤟

  • @sval4020
    @sval4020 2 ปีที่แล้ว

    Great stuff! Keep up with this!

    • @ArjanCodes
      @ArjanCodes  2 ปีที่แล้ว

      Thanks - will do!

  • @petrnovota8238
    @petrnovota8238 2 ปีที่แล้ว

    This channel has great value. Thank you

    • @ArjanCodes
      @ArjanCodes  2 ปีที่แล้ว

      Thank you, glad you like the content!

  • @mehrnooshh.kashani2571
    @mehrnooshh.kashani2571 3 ปีที่แล้ว

    Fantastic Video! I searched for practical design pattern uses in python, I found YOURS!
    For me your video was really helpful

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      Thank you Mehrnoosh, I’m happy that my video helped you.

  • @anikethdeshpande8336
    @anikethdeshpande8336 2 ปีที่แล้ว

    best series for learning design patterns!

  • @uwuwgrhdhwj
    @uwuwgrhdhwj 3 ปีที่แล้ว

    Great content, you're not recycling material that other people do. this is a good original video, subscribed

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      Thanks for the sub, Pedro. Glad you like the content.

  • @meh.7539
    @meh.7539 2 ปีที่แล้ว

    Thank you, Prof. Arjan!

  • @jamesgardiner727
    @jamesgardiner727 3 ปีที่แล้ว +1

    Great video -- I like the practical application. Look forward to seeing more

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      Thanks James, happy you liked it!

  • @sh0ot3r12
    @sh0ot3r12 2 ปีที่แล้ว

    This example is really practical! Thank Yout for this!

    • @ArjanCodes
      @ArjanCodes  2 ปีที่แล้ว

      Glad you like it!

  • @manutiwary7232
    @manutiwary7232 2 ปีที่แล้ว

    Arjan !!! This is like million dollar wealth for me and programmers like me who want to develop their skill from just coding to designing their codes. I must thank you ...for such great contents. Keep the good work and keep showering knowledge to rest of the world.

    • @ArjanCodes
      @ArjanCodes  2 ปีที่แล้ว

      Hi Manu, thank you - I’m glad to hear you like the content!

  • @joparicutin
    @joparicutin 10 หลายเดือนก่อน

    Yes. You made me think differently about events and the observer pattern. Thank you.

    • @ArjanCodes
      @ArjanCodes  10 หลายเดือนก่อน

      You're very welcome! :)

  • @brianhacker7346
    @brianhacker7346 3 ปีที่แล้ว

    Thanks for sharing. It was easy to follow and see the difference in the end result.

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      Thank you Brian, happy you liked it.

  • @chrisajokinen
    @chrisajokinen 2 ปีที่แล้ว

    Just found your channel. I like your approach, understanding the why you would apply a certain coding pattern is very helpful, subscribed!

    • @ArjanCodes
      @ArjanCodes  2 ปีที่แล้ว

      Awesome, thank you and welcome!

  • @MMphego
    @MMphego 3 ปีที่แล้ว +1

    Your content is top notch man. Good job

  • @kuriankattukaren
    @kuriankattukaren 3 ปีที่แล้ว

    I really enjoyed these videos. Keep up the good work.

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      Thanks, Kurian, will do!

  • @rafaeldelgado7860
    @rafaeldelgado7860 2 ปีที่แล้ว

    Awesome explanation! Thanks for sharing!

    • @ArjanCodes
      @ArjanCodes  2 ปีที่แล้ว

      Glad it was helpful, Rafael!

  • @IvanAndreScheel
    @IvanAndreScheel 3 ปีที่แล้ว

    @ArjanCodes you are a Godsend! Thank you so much for your videos

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      Hi Ivan, thank you - glad you enjoy the videos!

  • @talibuddeenabdulhakeem
    @talibuddeenabdulhakeem 3 ปีที่แล้ว

    These tutorials are straight 🔥 👌 💯

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      Thank you so much!

  • @tanuvishu
    @tanuvishu 3 ปีที่แล้ว +1

    You are a simply amazing teacher. Keep up the good work.

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว +1

      Thank you Vishal, happy you are enjoying the content!

  • @quantux
    @quantux 3 ปีที่แล้ว +1

    Thank you very much for this great content. I really appreciate it.

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      Thank you, Jason!

  • @robertbrummayer4908
    @robertbrummayer4908 3 ปีที่แล้ว

    Great job!

  • @domingochavez14
    @domingochavez14 3 ปีที่แล้ว

    Very good stuff. Congrats!

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      Thank you! Cheers!

  • @MrSongism
    @MrSongism 2 ปีที่แล้ว

    This is a great video, thank you. Simple and elegant explanation.

    • @ArjanCodes
      @ArjanCodes  2 ปีที่แล้ว

      Glad you enjoyed it!

  • @neeban1339
    @neeban1339 3 ปีที่แล้ว

    This is quality! Thanks, man.

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      Thank you - glad you liked it!

  • @bckzilla
    @bckzilla 3 ปีที่แล้ว

    Quite well done. Absolutely worth watching.

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      Thank you very much - glad you liked it!

  • @tobienortje4134
    @tobienortje4134 2 ปีที่แล้ว +1

    I have been learning Python for 10 years. Lately I got a bit frustrated because I wanted to increase my Python Level from medium to more Profesional but most of the courses and posts are focussed on entry to mid level programming. I love you videos, you tackle more advanced topics but still in a very accesable way. I am keeping an eye on this channel.

    • @ArjanCodes
      @ArjanCodes  2 ปีที่แล้ว +1

      Thank you so much, glad you like the videos!

  • @isofruitfruit9357
    @isofruitfruit9357 3 ปีที่แล้ว +2

    Very good explanation of the observer pattern and how to apply it also in the backend.
    The explanation of the solution, how it works and how to write it and structure it, was flawless in my opinion.
    Only suggestion I had would be to maybe to explain the pattern of the problem better, to give the viewer an easier time spotting where applying the solution could be useful.

  • @sharknitro7285
    @sharknitro7285 2 ปีที่แล้ว

    I swear, I saw his subscriber count this morning it was 100K, approximately 18hrs later it's 101K. Nice one, I really love these videos they make me feel like senior developer.

  • @raphael9052
    @raphael9052 3 ปีที่แล้ว

    Thank you, I just learned a lot! Just subscribed

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว +1

      Thank you Raphael, happy that you like it.

  • @gregetto2009
    @gregetto2009 ปีที่แล้ว

    former web dev coming back to coding later in my career, and these videos are pure gold. 🥇

  • @python_lover_01
    @python_lover_01 3 ปีที่แล้ว

    Awesome video, really nice example to show how to implement this design pattern... Thanks a lot... Keep it up...

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      Thank you! And will do!

  • @nicolasduque9469
    @nicolasduque9469 2 ปีที่แล้ว

    Fantastic video!

    • @ArjanCodes
      @ArjanCodes  2 ปีที่แล้ว

      Thank you very much, Nicolas!

  • @timlind3129
    @timlind3129 2 ปีที่แล้ว

    This is such a great way to write code for this type of use case

    • @ArjanCodes
      @ArjanCodes  2 ปีที่แล้ว

      Thank you Tim, glad you liked it.

  • @kovalensue
    @kovalensue 2 ปีที่แล้ว +16

    Is it a good idea to create a decorator for the post_event method? It seems like a handy syntactic sugar because I can see right from the method definition, that it uses some events...
    for example:
    @post_event("event_type")
    def register_new_user(name, psw, email): ....

    • @OlliWilkman
      @OlliWilkman ปีที่แล้ว

      The downside seems to be that you lose the ability to add data to the event from inside the function. Of course your decorator may e.g. add whatever the function returns as data, but you might want your function to return something else to the context it was called from.

    • @plouf1969
      @plouf1969 ปีที่แล้ว

      Can be useful, but it prevents you from unsubscribing during runtime. You only subscribe at startup time I guess. Also, this does nothing if it is in a library that you do not import, so you may have to import that library even if you do not use any of it's functions explicitly

  • @oghry
    @oghry 3 ปีที่แล้ว

    I really like your style. Thank you for the video.

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      That’s very kind, Alexey - thank you!

  • @astolfo4848
    @astolfo4848 2 ปีที่แล้ว

    Thank you, this really helped me out! I am working on code which handles several APIs, websockets and logging.

  • @ivankudinov4153
    @ivankudinov4153 9 หลายเดือนก่อน

    I don't even code in python professionally yet I've subscribed. You're genuine and well-rounded lecturer

    • @ArjanCodes
      @ArjanCodes  9 หลายเดือนก่อน

      Thank you for these kind words! Welcome aboard, Ivan.

  • @bonastreyair
    @bonastreyair 2 ปีที่แล้ว

    Great content! I would love to see some async event related examples too!

  • @smann43231816
    @smann43231816 3 ปีที่แล้ว

    Another great video. Thanks

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      Glad you enjoyed it, Steve!

  • @proofit404
    @proofit404 3 ปีที่แล้ว +5

    Great video. I wish you would mention common problems with event systems as well. Like call back hell & unreadable error messages (tracebacks). It would be easy to introduce change to such system. But the cost of search for a specific place where this change need to be made - would be a huge headache.

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      Thanks! And that’s a good suggestion to cover in a followup video.

  • @burnarakiss9122
    @burnarakiss9122 3 ปีที่แล้ว

    Very cool, learned a lot. Thank you

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      Glad it was helpful!

  • @plouf1969
    @plouf1969 ปีที่แล้ว

    Another cool application of events is that it's straightforward to add debugging instrumentation, say, write a func that lists all events that are registered to, and another one allowing to set breakpoints programmatically when a given event is posted.

  • @kylejameswalker
    @kylejameswalker 3 ปีที่แล้ว +1

    Great video, I'd love to see more on exception handling using this event system.

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      Thank you, and great suggestion!

  • @Baroquepassion
    @Baroquepassion 3 ปีที่แล้ว

    great illustration of decoupling

  • @kevinduigou3212
    @kevinduigou3212 ปีที่แล้ว

    This pattern is the mother of decoupling! My favorite GoF pattern!

    • @ArjanCodes
      @ArjanCodes  ปีที่แล้ว

      Thanks, Kevin, Glad that you liked it.

  • @EdwinFairchild
    @EdwinFairchild 2 ปีที่แล้ว

    this is gold! thanks!

    • @ArjanCodes
      @ArjanCodes  2 ปีที่แล้ว

      Thanks - glad you liked it!

  • @manojsitapara
    @manojsitapara 3 ปีที่แล้ว

    OMG !! It's so simple to understand. Thank you so much for videos. Liked and subscribed your channel.

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว +1

      Thanks and you're welcome, Manoj!

  • @brian_ball
    @brian_ball 2 ปีที่แล้ว

    I agree with the closing comments. Just following a tutorial is insufficient. I want to hear / discuss / dialog more about the whys. This video is terrific synaptic sugar.

    • @ArjanCodes
      @ArjanCodes  2 ปีที่แล้ว

      Thank you Brian, happy you liked the video.

  • @drewcannedy3045
    @drewcannedy3045 3 ปีที่แล้ว +1

    great video, underrated channel

    • @ArjanCodes
      @ArjanCodes  3 ปีที่แล้ว

      Thanks for your compliments, Drew!

  • @thomasmeister8476
    @thomasmeister8476 3 ปีที่แล้ว

    Thank you! Instant sub.