Proxy Pattern - Design Patterns (ep 10)

Поділитися
Вставка
  • Опубліковано 31 тра 2024
  • Video series on Design Patterns for Object Oriented Languages. This time we look at the Proxy Pattern.
    ► The playlist
    • Design Patterns in Obj...
    ► Head First: Design Patterns
    geni.us/nlbA6
    ► Design Patterns: Elements of Reusable Object-Oriented Software
    geni.us/PsXmo
    ► Premature optimization
    en.wikipedia.org/wiki/Program...
    citeseerx.ist.psu.edu/viewdoc/...
    💪 Patreon Community
    / christopherokhravi
    📚 Products I Recommend
    geni.us/71ZXF

КОМЕНТАРІ • 261

  • @eahmedshendy
    @eahmedshendy 10 місяців тому +16

    The community is missing someone like you.
    2023 and we still enjoy such 37 min in a row.

  • @Gotinox
    @Gotinox 5 років тому +241

    Dude I really like how you repeat every one of your definitons at least twice... The first time to hear it and the second time to rethink it! You are a great teacher!

  • @vipram91
    @vipram91 6 років тому +160

    "Instead of calling the THING you want to call
    you call the THING which call the THING you want !!" Nice definition, liked it!

  • @safvanp567
    @safvanp567 6 місяців тому +12

    00:01 The proxy pattern provides a surrogate or placeholder for another object to control access to it.
    01:56 Proxy pattern is used to control access to resources and solve access-related problems.
    06:01 Proxy pattern adds additional behavior to control access to the underlying object.
    07:58 Using a virtual proxy allows for additional behavior before making calls to an object.
    12:12 Using methods is a flexible approach that allows for future changes.
    14:13 Premature optimization can lead to inefficient code
    17:59 Proxy pattern allows deferring the instantiation of the underlying book parser
    19:42 Proxy pattern is used to create expensive objects on demand rather than immediately.
    23:23 Proxy pattern is used to control access to an expensive operation.
    25:11 The proxy pattern controls access to the real subject and follows the same interface.
    28:44 The proxy pattern involves a proxy class that acts as a placeholder for another class, known as the real subject.
    30:17 Create an instance variable that defaults to null for Lazy Book Parser Proxy.
    33:58 The proxy pattern delays the instantiation of a concrete book parser until it is needed.
    35:44 The proxy pattern allows instantiation of the book parser only when required, improving performance.

  • @VictorQianYT
    @VictorQianYT 5 років тому +74

    Great video, but can you move ur camera slightly to the right next time so i can see the cat better? :P

  • @SGTR32
    @SGTR32 6 років тому +10

    Bruh!!, I watched this before my final and you made it super easy to understand. Hours of reading on this pattern were pointless. Crystal clear explanation. Keep it up and two thumbs up!

  • @kiwalok8982
    @kiwalok8982 3 роки тому

    I was completely lost, and i had to understand and learn design patterns.
    i found this channel, and now i get it all.
    thanks for your time and effort Chris.

  • @diego99799
    @diego99799 6 років тому +48

    My mood rises when I see new episode. Thanks a lot MAN!

    • @ChristopherOkhravi
      @ChristopherOkhravi  6 років тому +9

      Thank you very much. That makes me happy to hear. I wish I could deliver more and faster. Gotta keep the balance with my day job :) But as I get the flow up I will hopefully be able to. Thank you very much for watching :)

  • @AmitSharma-vh7qv
    @AmitSharma-vh7qv 4 роки тому +3

    I really like the effort you give while explaining the concept. you are very good teacher. Hard to find teacher like you

  • @HarithAldabbagh
    @HarithAldabbagh 3 роки тому

    This is by far the best explanation of the proxy pattern I've watched on youtube! Thank you!

  • @frogspawn8
    @frogspawn8 6 років тому +44

    You are an effective and succinct communicator. You make learning infectious. Are you a professor or desiring to be?
    As online learning continues to become an educational alternative, and given the increasing university tuitions, online instructors like you are becoming a threat to the educational status quo.
    You have a gift and I believe it will take you very far in your career.
    EXCELSIOR!

    • @ewelinap491
      @ewelinap491 3 роки тому +6

      i've seen he is a proffessor for 8 years now ;)

  • @mikhailbisserov8017
    @mikhailbisserov8017 6 років тому

    I love your explanation that patterns have different intent even if implementation strategies match sometimes.

  • @emmanuelasunomeh9949
    @emmanuelasunomeh9949 2 роки тому

    Great Job!! I have never seen any video that explains design patterns so clearly. Thank You for making my life easier to understand Design Patterns.

  • @emersontavera9362
    @emersontavera9362 3 місяці тому

    I'm reading the Head first design patterns book, I used to think that I already had a good understanding of OOP, but that book changed everything, I realized I just knew the name of the tools and maybe how they were written in java, but I had no idea how to use them, after learning about design patterns marked a new start for me.
    I came here to have some help with the Proxy pattern and you were awesome, thank you, now I'll go ahead and start reading the chapter about the proxy pattern in the book, keep it up man, you are a great teacher.

  • @sarenodev
    @sarenodev 2 роки тому

    Bringing up the "Premature optimization" is brilliant 💡. Thanks!

  • @crashedbboy
    @crashedbboy 3 роки тому

    Hey
    Christopher, thanks for sharing these knowledge so generously, hope everything's well with you.

  • @shaunsmith8762
    @shaunsmith8762 4 роки тому

    Hey Christopher, Thank you very much for making these videos. I know they’re a lot of work. You teach the way I think. If that makes sense. Brilliant job!!!

  • @97Patok
    @97Patok 5 років тому

    maan, I've been watching these videos and writing notes all day long. Thanks.

  • @davidegiancane4159
    @davidegiancane4159 5 років тому +14

    The best Design Pattern playlist on UA-cam! Your explanation skills are very powerful...listening to you is funny and not boring! Thanks to you I'm gonna pass my exam on Design Pattern!

  • @arpitamandal1472
    @arpitamandal1472 5 років тому +1

    I just don't understand how do you manage to make it so simple... Thanks alot for this wonderful explanation... 😀

  • @Elenthiriel
    @Elenthiriel Рік тому

    Man, your examples, just make it so easy, it was a nightmares before i know this playlist, thank you

  • @KenZhi-lk9qw
    @KenZhi-lk9qw 6 років тому +2

    Hi, I am a student from Taiwan, I really like your explanation, really help me a lot! Thanks!

  • @glebcherkashyn2357
    @glebcherkashyn2357 4 роки тому +3

    open, smash 'like' button, watch - my algorithm for your videos. I call this pattern "gratitude". Thanks a lot for your great job!

  • @ratulmahjabin9765
    @ratulmahjabin9765 2 роки тому

    The one reason I keep coming here is that he keeps repeating what he is teaching. That really helps to understand the topic better. Great contents!

  • @somunix
    @somunix 6 років тому

    Thanks Christopher for you detailed view on patterns.. I really find them very informative and like the simple way you have explained these topics. Keep the good work .. Way to go.. :)

  • @hazemgharib
    @hazemgharib 6 років тому

    Man I love your videos. You make things that were unclear to me looks like really super easy.

  • @Rappomon
    @Rappomon 5 років тому

    We need more people like you! Everything I search on UA-cam for Object-oriented programming is either trival or just not helpful. Thanks to you I understood the patterns I needed to understand for my exam. Thanks!

    • @Rappomon
      @Rappomon 5 років тому

      They could be a little shorter tho :D

  • @pradeepsanju
    @pradeepsanju 6 років тому +3

    As usual amazing explanation Chris. Keep up the good work. Thanks a lot.

    • @ChristopherOkhravi
      @ChristopherOkhravi  6 років тому

      +pradeepsanju Glad to hear! I will. Thank you for the encouragement and thank you for watching :)

  • @rajsekharmahapatro
    @rajsekharmahapatro 3 роки тому

    I am really upset i did not find your tutorials all these years on UA-cam when ever i searched for "design patterns with Java". But better late than never. Thanks dude.

  • @SaurabhGuptaicecool
    @SaurabhGuptaicecool 4 роки тому

    Learnt first 10 design patterns and done for now. Will come back later, maybe during the 2nd half of 2020.

  • @startrek3779
    @startrek3779 2 роки тому +1

    Excellent explanation! Thank you so much!

  • @dhananjaypal8498
    @dhananjaypal8498 5 років тому

    I love your work. Thanks a lot. Please continue this series

  • @onurodabas8207
    @onurodabas8207 4 роки тому +4

    I had astigmatism and I started wearing new glasses. I was happy to see everything clear. Until I watched this video: D.Even so thanks for your informative video :)

  • @mil3761
    @mil3761 11 місяців тому

    These videos are amazing. You should create a design pattern playlist for easier consumption

  • @michor10
    @michor10 5 років тому

    It would have been pretty cool if you had talked a little bit about how virtual proxies can also override a client's method or property. This, in my opinion, makes virtual proxies super powerful (assuming, of course, that the language allows for it and that the client class has been defined appropriately) Thanks a lot for the great video!

  • @david44707
    @david44707 2 роки тому

    Chris, you're an awesome pedagogue !!! Thanks a lot !

  • @zahidkhankhan
    @zahidkhankhan 5 років тому

    quite interesting and explain in an abstract way. which make it more interesting. appreciated your efforts keep it up buddy..

  • @DailyStoicStepsOfficial
    @DailyStoicStepsOfficial 5 років тому +10

    I completely lost track after that cute student walked into the class. :D

  • @christianlevesque9017
    @christianlevesque9017 6 років тому

    114 likes, 0 dislike ... I'm really NOT surprise .. your explanations are perfect

  • @Cheagong
    @Cheagong 5 років тому

    Perfectly explained, thank you!

  • @ankitavyas7996
    @ankitavyas7996 5 років тому +1

    Thank you Chris, for amazing tutorials. Isn't this pattern very similar to singleton pattern, except that we create object on-demand through some method instead of constructor in singleton, or am I understanding this wrong?

  • @aneeshjain3395
    @aneeshjain3395 3 роки тому +5

    Instead of book I prefer to watch this playlist again xD

  • @arvindeya
    @arvindeya Рік тому

    Thanks for such a brilliant series on the design patterns.
    Would like to know more about improving application performance from developer's perspective, but in "Christopher Okhravian" style.

  • @domidodongo
    @domidodongo 5 років тому

    I really like your videos. Thanks a lot !!! They are really helpful!

  • @melbinthomas2199
    @melbinthomas2199 6 років тому

    You are a great teacher .....Love from India .

  • @VishnuRadhakrishnaPillai
    @VishnuRadhakrishnaPillai 6 років тому

    Thanks Christopher Great Explanation

  • @jordanshuriken
    @jordanshuriken 4 роки тому

    Your videos are fantastic and informative!

  • @sailakshmimanthena4244
    @sailakshmimanthena4244 4 роки тому

    you really helped me during my exams. thanks bro

  • @nadnerb2178
    @nadnerb2178 3 роки тому +5

    Great video. Content and explanation were really useful, thanks! I know you mentioned the autofocus and are aware of it but just a suggestion: Perhaps avoid using autofocus all together? Use a deeper depth of field and set your focal point to 2/3rds of the distance from the whiteboard. After this is set, leave the focus for the entire video. There's no need for the camera to be constantly re-adjusting focus as you move your arm back and forth because that data is irrelevant to what the viewers need to see.

  • @Levendo
    @Levendo 4 роки тому

    Thank you, these videos are super informative!

  • @Ti4g00liveira
    @Ti4g00liveira 6 років тому

    Your content is really good tho.
    I can't wait to see what more interesting things you're going to bring to the channel!

  • @davidegiancane4159
    @davidegiancane4159 6 років тому +2

    Awesome as always, you are a very good teacher! Just a question: what about the GoF patterns which the book "Head first" doesn't explain? Are you going to make some videos about them? I hope so, it would be great :D

  • @dnyaneshbarkade538
    @dnyaneshbarkade538 6 років тому +1

    Very well explained. we love your lectures and your cat.

    • @ChristopherOkhravi
      @ChristopherOkhravi  6 років тому

      Haha thanks! I'm glad to hear :) Actually there are two cats but one of them seems to always be around when the camera is out :D Thanks for watching :)

  •  6 років тому

    Again nice explanation. Thank you for share your knowledge :)

  • @djwave28
    @djwave28 4 роки тому

    A huge thanks to what your doing here. Bought the book and watching all your videos..
    I get the proxy stuff and see the benefits. I am wondering about the caching. Do you have material/reference as to generically choose a caching methods? Being mostly PHP oriented I wonder about the duration of the url request cycle and I am fighting with this concept.

  • @TheGao1978
    @TheGao1978 6 років тому

    Really like this playlist. A bit late to the convo but in the example in the vid, in the case we're doing this because we're using an external lib, then how can we inject a proxy after the fact? Surely if it wasn't designed with the interface, we can't make the concrete subject, i.e. BP in the example, implement a new interface later. Correct?

  • @utkarshgupta2909
    @utkarshgupta2909 2 роки тому

    Christopher Okhravi, create more content. You explain very well and in depth !!

  • @lpatrasco
    @lpatrasco 5 років тому +1

    Question: is it still appropriate to use proxy pattern when you own the original object implementation? It makes sense to proxy another library object to enhance or change it’s behavior. But does it make sense to proxy your own object that you could just modify instead of proxying? I know of the open-close principals. So proxying already existing object that I own the implementation of would obey the open-close principle but also would possibly create layers upon layers upon layers. Also, I’d like to hear more on dangers and gotchas of each pattern.

  • @stanislavmachel5361
    @stanislavmachel5361 5 років тому

    Thanks a lot! Christopher, it is the greate explanation, which I ever heart!

  • @mahmoudashraf117
    @mahmoudashraf117 2 роки тому

    awesome example . thanks alot!

  • @alirezajazayerei2881
    @alirezajazayerei2881 3 роки тому

    you are AWSOME keep up the good work, it helped me so much. thank you

  • @swapnilkhole
    @swapnilkhole 3 роки тому

    great video. Guess, who uses the proxy pattern heavily as you've said for the lazy initialization? of course, hibernate. When you declare explicitly that I'd like to have an object lazily initialized, hibernate obliges it by using proxy around it. So that ORM class is instantiated only when we 'really' want to do something on it, until then it is just hanging around there as a simple proxy class . Again, great video!

  • @leonarddacosta7710
    @leonarddacosta7710 4 роки тому

    Hi Christopher,
    I must firstly say that you’re a great teacher. I’ve been feasting on your presentations on Design Patterns and enjoying every bit of it.
    I’ve looked at this particular tutorial 3 times but I couldn’t seem to grasp the concept properly then I found why: I think your example don’t quite fit the pattern. Here’s why:
    The base interface on the right, ie the Implementor needs to itself be a specialised form of the Abstraction hence the name Implementor. With this understanding the definition makes total sense “Decouple an abstraction from its implementation so that the two can vary independently”.
    In your example IResource would need to be a specialised version of View to fit the Bridge Pattern which makes no sense.
    My comment is not to take away from your work by the way, your work is awesome stuff.
    Let me know what you think.
    This is a really powerful pattern.

  • @yahyadurrani5482
    @yahyadurrani5482 5 років тому

    brilliant mate, keep up the good work

  • @yanavalasatava9465
    @yanavalasatava9465 5 років тому

    Great videos and explanations! Thank you very much. I was looking for an episode on the differences between facade, proxy and decorator patterns but couldn't find it. Maybe you'd be so kind to point to it. Thanks! P.S. Love it when your cat participates :)

  • @mathiasyeremiaaryadi9097
    @mathiasyeremiaaryadi9097 3 роки тому +2

    I think what you mentioned around 11-12 minute is "encapsulation" , where you can access the field through method instead, by using setter and getter method. cmiiw

  • @radoslavangelov7193
    @radoslavangelov7193 5 років тому

    Sorry for my misunderstanding but the `return this.parser.getNumPages();` should happen outside of the `IF` block, right?

  • @oeurnravuth9078
    @oeurnravuth9078 6 років тому +1

    You very good explanation. I like it so much!

  • @martonkaable
    @martonkaable 6 років тому

    Cool! This is the first video I saw from you, but I immediately subscribed.

  • @nemanjastankovic941
    @nemanjastankovic941 3 роки тому

    Thanks a lot for this amazing explanation 🤓

  • @amank2410
    @amank2410 6 років тому +1

    Nice explanation Christopher !

    • @ChristopherOkhravi
      @ChristopherOkhravi  6 років тому

      +Amann Thank you. I'm glad to hear it's useful. And thank you for watching :)

  • @JATR1X
    @JATR1X 2 роки тому

    Great video as always! small criticism: I think a better example would be to introduce a "setBookString" method instead of working with constructors. Since the constructor is not part of the IBookParser interface, we can not really rely on it when Proxying the BookParser class.

  • @Yaya-ni3ie
    @Yaya-ni3ie 5 років тому

    Can't you give the String book (as an argument) directly to the method instead of making it a field variable of the BookParser? or is this part of the pattern?

  • @ryanrichard4805
    @ryanrichard4805 6 років тому

    Great video. Very informative.

  • @gouthamrg8584
    @gouthamrg8584 2 роки тому

    Group of Devs said design patterns are difficult till Christopher enters the room.

  • @shankar7435
    @shankar7435 3 місяці тому

    Thanks for the easy-to-understand explanation & cat though 😀

  • @saurabhjangir
    @saurabhjangir 4 роки тому

    great work. Thanks for the video.
    One question, At 24:10 proxy Object has-a concrete real subject. What difference would it make if we use ISubject interface in place real subject inside the proxy Object ?

  • @KratosKaiBia
    @KratosKaiBia Рік тому

    Thanks very much for these videos and I love your cat! :)

  • @crankitsourav8686
    @crankitsourav8686 4 роки тому +1

    Hey Christopher ,
    Thank you very much for this great video series .
    According to the code that you have mentioned at last it seems same to singleton pattern.(one time creation object) Can you please brief me how this proxy pattern is difference from singleton pattern ??

  • @petschi3473
    @petschi3473 2 роки тому +1

    great! Thank you!

  • @igorlopatchin904
    @igorlopatchin904 4 роки тому

    Amazing video, thank you very much

  • @tonydunne1965
    @tonydunne1965 4 роки тому

    A Very very good explainer

  • @bryanshi3774
    @bryanshi3774 2 роки тому +1

    Great Video!!

  • @RockandSolo
    @RockandSolo 3 роки тому

    Can we use a singleton for this example since we are only instantiating the Book Parser once, upon the request of a method?

  • @imedboufares2422
    @imedboufares2422 6 років тому

    Good explanation MAN , thank you

  • @PA-vf5st
    @PA-vf5st 4 роки тому +1

    Hello Christopher, I like your videos and the way you explain it...I have been following your videos for my better understanding abt DP....Can I request you about including real business scenario where we can implement these DP's...Please have a 10 min of slot in your video abt telling us real scenarios where we can implement this DP....

  • @ArjonJasonCastro
    @ArjonJasonCastro 5 років тому

    Best examples of Proxy pattern are Mockery(mocked objects or services) as used in unit testing.

  • @heisenburger311
    @heisenburger311 6 років тому +2

    Your explanation of concepts and examples are easy to understand! I even treat it as a kind of relaxation!
    Though I fell asleep for times in this episode (maybe just because I watched it after dinner...), I found I was still keeping up with the pace of the video :)
    Thank you so much!

  • @Blaskillo
    @Blaskillo 2 місяці тому

    Awesome content, thanks

  • @konzinovmaverick4539
    @konzinovmaverick4539 6 років тому +1

    Someone would say ANOTHER ONE! Great Job Dude!

    • @ChristopherOkhravi
      @ChristopherOkhravi  6 років тому

      +konzinov maverick Yeeeeeeea they don't wanna see us win!

  • @harikachowdary5380
    @harikachowdary5380 4 роки тому

    Hi, I can not be able to find a video where you have captured about the differences between proxy, adapter, facade and decorator patterns ?
    can you please point me to that video? so that i can continue with that.

  • @blackprincess4603
    @blackprincess4603 5 років тому

    Amazing explanation 😍 i love you

  • @oleksandr.pastukhov
    @oleksandr.pastukhov 6 років тому +1

    Christopher, thanks a lot, very nice explanation :)

  • @EminoMeneko
    @EminoMeneko 3 роки тому +1

    8:04 NOOOOOOOOOOOOOOOOOOOOOOOOOO ! I did not have time to take notes !!!! 😱😱😱😱😱😱😱
    No seriously this is good and I have OneNote opened to keep the important bits.
    About autofocus I'd say in the context in which you shoot, you'd probably better find a manual setting that works. Autofocus is dynamic and can misinterpret the subject at times. With a long enough depth of field you could not need to change anything at all and be sure the image is neat for the desired scene setup.
    The smaller the aperture the longer the depth of field but also the less light = greater likelihood to need external light.

  • @amirrazaahad4576
    @amirrazaahad4576 Рік тому

    thanks a ton for this amazing video.................

  • @spyrex3988
    @spyrex3988 4 роки тому

    When should I start learning design patterns? Pls tell me I'm in 1st year of college and I've learned till template class

  • @henryjoe7853
    @henryjoe7853 6 років тому

    Is there a video about the difference between the proxy and the adaptor as you said? I mean their nuances?

  • @swapniljamdade6641
    @swapniljamdade6641 6 років тому

    Nice Explanation Christopher, thank you for the Video. Just got a thought here instead of making book name as member variable can we pass it to the method getNumberOfPages(String bookName)? As the real object BookParser is independent of the book and tying it to a book name in proxy at instance level we have to set the new name always in the proxy book parser?
    For eg something like below:
    public class LazyBookParserProxy {
    private BookParser bookParser = null;
    public getNumberOfPages(String bookName){
    if(bookParser == null){
    bookParser = new BookParser();
    }
    return bookParser.getNumberOfPages(bookName);
    }
    }
    What say? and does the proxy object LazyBookParserProxy somewhat ring bells of singleton pattern in this scenario? :-)
    Again another great video thanks.

  • @pradipnitw
    @pradipnitw 6 років тому

    Is it a good idea to combine a Proxy and Singleton pattern then? A single accessor to our resources ?

  • @Cezinha0Gusto
    @Cezinha0Gusto 3 роки тому

    Congratulations and thaks to share!