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

Поделиться
HTML-код
  • Опубликовано: 16 ноя 2024

Комментарии • 362

  • @ArjanCodes
    @ArjanCodes  3 года назад +53

    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: ruclips.net/video/eiDyK_ofPPM/видео.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 2 года назад +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.

  • @MatheusAugustoDaSilva
    @MatheusAugustoDaSilva 2 года назад +52

    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 ;).

  • @RoamingAdhocrat
    @RoamingAdhocrat 3 года назад +58

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

  • @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 года назад +8

      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.

  • @fat_pigeon
    @fat_pigeon 3 года назад +21

    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.

  • @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 11 месяцев назад

      Usually this is solved writing good documentation

  • @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.

  • @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!

  • @lordGaruda
    @lordGaruda 2 года назад

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

  • @jeanhadrien
    @jeanhadrien 3 года назад +22

    This is insane quality content, keep it up !

  • @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!

  • @ivankudinov4153
    @ivankudinov4153 Год назад

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

    • @ArjanCodes
      @ArjanCodes  Год назад

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

  • @orie239
    @orie239 3 года назад

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

  • @CodingEntrepreneurs
    @CodingEntrepreneurs 3 года назад +48

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

  • @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.

  • @RabidHobbit
    @RabidHobbit 2 года назад

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

  • @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!

  • @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!

  • @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.

  • @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? :)

  • @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!

  • @_indrid_cold_
    @_indrid_cold_ 3 года назад

    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  3 года назад

      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!

  • @tobienortje4134
    @tobienortje4134 3 года назад +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  3 года назад +1

      Thank you so much, glad you like the videos!

  • @guillermokeller1985
    @guillermokeller1985 3 года назад +2

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

  • @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!

  • @gregetto2009
    @gregetto2009 2 года назад

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

  • @brian_ball
    @brian_ball 3 года назад

    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  3 года назад

      Thank you Brian, happy you liked the video.

  • @kevinduigou3212
    @kevinduigou3212 Год назад

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

    • @ArjanCodes
      @ArjanCodes  Год назад

      Thanks, Kevin, Glad that you liked it.

  • @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!

  • @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!

  • @777dmaster
    @777dmaster 3 года назад

    15 minutes well spent! Thank you!

  • @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.

  • @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

  • @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!

  • @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.

  • @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.

  • @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

  • @nahoskins
    @nahoskins Год назад

    The background music is exactly what I listen to when working. It has had me in Pulsemixer trying to work out what is going on several times.

    • @ArjanCodes
      @ArjanCodes  Год назад

      Thanks so much Nick, glad you liked it!

  • @anikethdeshpande8336
    @anikethdeshpande8336 2 года назад

    best series for learning design patterns!

  • @UrbanAI
    @UrbanAI 3 года назад

    What could be better than illustrative examples! Thank you!

  • @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.

  • @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.

  • @joparicutin
    @joparicutin Год назад

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

  • @pratibhagupta1281
    @pratibhagupta1281 Год назад

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

  • @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!

  • @ishaanme91
    @ishaanme91 2 года назад

    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!

  • @informatik01
    @informatik01 3 года назад

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

    • @ArjanCodes
      @ArjanCodes  3 года назад +1

      Thank you, glad you enjoyed it!

  • @tomasnovellino5980
    @tomasnovellino5980 Год назад

    That's a great pattern and is also compatible with queues or API calls... the only thing I do differently is that each "listener" will also be responsible of subscribing instead if having a centralised file.

  • @timlind3129
    @timlind3129 3 года назад

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

    • @ArjanCodes
      @ArjanCodes  3 года назад

      Thank you Tim, glad you liked it.

  • @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.

  • @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.

  • @hansdietrich1496
    @hansdietrich1496 Год назад

    I'm a largely self-taught developer and felt a lack of competent feedback when coding. So even after years of coding practice, your videos give me some food for thought. Thanks for your videos!

  • @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!

  • @golammuhaimeen2825
    @golammuhaimeen2825 3 года назад

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

  • @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.

  • @hchattaway
    @hchattaway 3 года назад +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.

  • @drewcannedy3045
    @drewcannedy3045 3 года назад +1

    great video, underrated channel

    • @ArjanCodes
      @ArjanCodes  3 года назад

      Thanks for your compliments, Drew!

  • @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.

  • @weihu-ai
    @weihu-ai 3 года назад

    Great video. In my view, this is an abstraction. Event abstracts the messaging services into two functions: register and post. It hides the detailed implementation internally.

  • @samjoel4152
    @samjoel4152 3 года назад

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

  • @MMphego
    @MMphego 3 года назад +1

    Your content is top notch man. Good job

  • @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.

  • @petrnovota8238
    @petrnovota8238 2 года назад

    This channel has great value. Thank you

    • @ArjanCodes
      @ArjanCodes  2 года назад

      Thank you, glad you like the content!

  • @AmirIskandar
    @AmirIskandar 3 года назад

    This is genuinely high quality stuff. Keep it up!

  • @presstv
    @presstv 2 года назад

    it's very popular pattern in Python. good job 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!

  • @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 RUclips... 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.

  • @santiagobustamante970
    @santiagobustamante970 2 года назад

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

  • @danielismyhandle
    @danielismyhandle 3 года назад +1

    One thing i would add to this is instead of using string event names you could use enums and group them by type. That way it will be easy to see which events are available. Great content!

    • @ArjanCodes
      @ArjanCodes  3 года назад

      Good point! I've been using Enums for these kinds of things already in my more recent videos.

    • @danielismyhandle
      @danielismyhandle 3 года назад

      @@ArjanCodes I just found your channel, will look through some more of your newer videos aswell. thanks!

    • @GrowlyGaming
      @GrowlyGaming 2 года назад

      Hello Arjan. Could you point me to the actual videos where you enhance this with Enums? Thanks for a great tutorial!

  • @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!

  • @tobiasbergkvist4520
    @tobiasbergkvist4520 3 года назад +13

    Although this has made the code easier to change, it has also made it harder to read - since figuring out which side-effects occur when a new user is registered requires looking in multiple files.
    I guess there is always a tradeoff being made when using these kinds of patterns.

    • @RasmusSchultz
      @RasmusSchultz 3 года назад +6

      I had to scroll a lot to find this comment. You are absolutely right. Code like this is much less obvious. I would in the past, but these days I would never reach for a pattern like this, unless I was building a modular system - something that gets deployed with many different configurations. The original code was more readable, easier to understand, and already factored so you could comment-out each function call with a line of code. In a large system, there is maybe an argument to be made about testing too - but that was never even mentioned here.

    • @fat_pigeon
      @fat_pigeon 3 года назад +1

      @@RasmusSchultz The decoupling does sometimes help. He did mention that it makes it easier to disable Slack: comment out the single line that registers Slack handlers, instead of having to comment out the Slack call in each event implementation. Essentially we're restructuring the code and slicing it in a different dimension, which makes some things easier but other things harder. Still I would have liked him to discuss the drawbacks and when using the pattern is inappropriate or overkill.

    • @bloodgain
      @bloodgain 3 года назад

      @@fat_pigeon You could replace the implementation of the Slack call with a no-op. That's pretty much the equivalent effort. Granted, it _does_ mean completely removing the Slack calls is more effort if you decide to do it later.

    • @fat_pigeon
      @fat_pigeon 3 года назад

      ​@@bloodgain Except that would break all the unit tests for the Slack implementation, so you'd have to remove those as well.

    • @bloodgain
      @bloodgain 3 года назад

      @@fat_pigeon Well, sure, but I assumed we were talking about removing it temporarily for whatever reason (e.g. debugging, in-house experimental testing, etc.), in which case, broken unit tests are a non-issue. But if we're talking about it being a more common thing, we should be making it configurable, for which there are multiple good approaches.

  • @gauravpurohit11
    @gauravpurohit11 3 года назад

    Awesome. Please keep creating content like this. No1 unfortunately teaches them

    • @ArjanCodes
      @ArjanCodes  3 года назад

      Thank you - that's the plan! :)

  • @Baroquepassion
    @Baroquepassion 3 года назад

    great illustration of decoupling

  • @xappppp
    @xappppp 3 года назад

    very useful to simplify my project, have to come back and reference to this again and again

    • @ArjanCodes
      @ArjanCodes  3 года назад

      Thank you - happy the content is useful to you!

    • @xappppp
      @xappppp 3 года назад

      one question actually, is subscrber dict object only generated once? I see it is imported a few times.

  • @sh0ot3r12
    @sh0ot3r12 3 года назад

    This example is really practical! Thank Yout for this!

  • @scottmiller2591
    @scottmiller2591 3 года назад

    Good pythonic introduction, much better than some authors where it is clear that they would really rather be programming in SmallTalk or Java (spits).

    • @ArjanCodes
      @ArjanCodes  3 года назад +1

      Thank you Scott, glad you enjoyed it!

  • @odnanref
    @odnanref 3 года назад

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

    • @ArjanCodes
      @ArjanCodes  3 года назад

      Thanks, glad you're enjoying it :).

  • @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 3 года назад

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

    • @ArjanCodes
      @ArjanCodes  3 года назад

      Awesome, thank you and welcome!

  • @jonathanheadley2729
    @jonathanheadley2729 3 года назад

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

  • @jotunros
    @jotunros 9 месяцев назад

    Great explanation of the pattern. I think It would be also good to mention a few of the most popular technologies that are used in event driven systems f.eg: Apache Kafka. I'm not sure what is the common solution for use with python based microservices outside of platforms like AWS.

  • @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...

  • @MrWorshipMe
    @MrWorshipMe 3 года назад +10

    This pattern can be made even more powerful if it works asynchronously. Especially if it's being used in UI. You don't want your UI to freeze while costly functions are running, but you want some progress indication.

    • @ArjanCodes
      @ArjanCodes  3 года назад +3

      Absolutely! I’m also using async events in our backend to start processes like sending emails and then the request handling code doesn’t have to wait for it.

    • @astronemir
      @astronemir 3 года назад +8

      @@ArjanCodes if you ever update this video, a python async version would be awesome!

  • @meh.7539
    @meh.7539 3 года назад

    Thank you, Prof. Arjan!

  • @astolfo4848
    @astolfo4848 3 года назад

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

  • @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.

  • @ddctechinstitute6861
    @ddctechinstitute6861 Год назад

    You are great Arjan. Much love 🤟

  • @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!

  • @bckzilla
    @bckzilla 3 года назад

    Quite well done. Absolutely worth watching.

    • @ArjanCodes
      @ArjanCodes  3 года назад

      Thank you very much - glad you liked it!

  • @MrSongism
    @MrSongism 3 года назад

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

  • @unvergebeneid
    @unvergebeneid 3 года назад

    6:00 this is a really nice use case for a defaultdict. It will automatically create a new list if the key is new.

  • @re.liable
    @re.liable 2 года назад

    Thanks. Dabbled a bit in JS and I really like the subscriber pattern

    • @ArjanCodes
      @ArjanCodes  2 года назад

      Thanks so much, glad you liked it!

  • @talibuddeenabdulhakeem
    @talibuddeenabdulhakeem 3 года назад

    These tutorials are straight 🔥 👌 💯

  • @itsmemouha2811
    @itsmemouha2811 3 года назад

    Whenever I think I know the full story of coding, I find a new think that shows how much Im ignorant.
    Thank you for the vid.

    • @ArjanCodes
      @ArjanCodes  3 года назад

      Thank you - happy you are enjoying it!

  • @fazzah777
    @fazzah777 3 года назад

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

  • @josephtucker9612
    @josephtucker9612 2 года назад

    Years ago I had to work on legacy code that had been modified by newbies and experienced developers for more than 10 years. Making any changes to the code would break other code.
    To add new features or fix some bugs I came up with something similar to the observer pattern but for data, a DataSubscription class. If a procedure was called from another procedure high up in the call stack and I needed to send or receive data between procedures I would use that class instead of using global variables. Passing the data as args was not possible because there was so many paths it could take and it may have been called by another procedure high up in the stack that does not need to send or receive the data. I also used it as a flag to change the behavior of a procedure depending on if a subscription exists or not.
    I got really good at adding new features and fixing bugs without adding new bugs. The down side was since I was so successful with legacy code I was not put on new projects that used more modern programming languages like C#.

  • @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 ;).

  • @rafaeldelgado7860
    @rafaeldelgado7860 3 года назад

    Awesome explanation! Thanks for sharing!

    • @ArjanCodes
      @ArjanCodes  3 года назад

      Glad it was helpful, Rafael!

  • @sillytechy
    @sillytechy 3 года назад

    Hi, I really liked the way you have shown the pattern applied in a real-world scenario. I was stuck in implementing this design pattern. Thank you. Please If you can make a playlist of all the Design patterns and implementation of that using python for a real-world scenario.

    • @ArjanCodes
      @ArjanCodes  3 года назад

      Thank you! I will definitely cover more design patterns on the channel in the future!

  • @grzegorzryznar5101
    @grzegorzryznar5101 3 года назад

    Very useful video. Thanks for posting it!