Structural Patterns (comparison) - Design Patterns (ep 12)

Поділитися
Вставка
  • Опубліковано 23 вер 2017
  • Video series on Design Patterns for Object Oriented Languages. This time we compare a few structural patterns.
    CORRECTION: At 2:10 I draw a has-a arrow from the concrete decorators to the abstract decorator. This is a mistake. The arrow should be drawn from the abstract decorator to the component. Otherwise the pattern doesn't work. Sorry about that, and thanks Naman Saxena for pointing it out! Later in the video I put letters in the boxes. Expressed in letters the arrow should go from D to C. Mea culpa.
    More specifically:
    Adapter Pattern
    vs
    Proxy Pattern
    vs
    Facade Pattern
    vs
    Decorator Pattern
    vs
    Bridge Pattern
    ...and then we throw in Strategy Pattern in the end :)
    ► The playlist
    • Design Patterns in Obj...
    ► Head First: Design Patterns
    geni.us/nlbA6
    ► Design Patterns: Elements of Reusable Object-Oriented Software
    geni.us/PsXmo
    💪 Patreon Community
    / christopherokhravi
    📚 Products I Recommend
    geni.us/71ZXF

КОМЕНТАРІ • 162

  • @chrisjust7445
    @chrisjust7445 6 років тому +122

    Seeing all 6 of those UML diagrams on one board is a great way to see just how different or similar the various patterns are.

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

      I'm glad you think so :) That's sort of what I was thinking myself :) Thanks for watching!

  • @Artem992
    @Artem992 6 років тому +115

    Here's a silly story I've made up to memorize and fit it all together 😁
    On Fridays one guy likes to finish the day with a shot of plain rum, actually he used to distill it on his own, but that was too complicated process so he started buying bottles in a local shop, which is a great FACADE that removes all the complexity and pain of production process away from him.
    Couple months later he decides that plain rum is good but maybe it might taste better when DECORATED with lemon and other ingredients. But damn he's too lazy so he heads to a local bar. Apparently, that bar is a limited club, so in order to get in, he gotta know a friend who's already a club member (PROXY) who could tell the security he's cool enough to get in.
    The security guy is angry and just mumbles something, but our man happened to recognise some phrases in Spanish so he ADAPTED to the situation and replied in that language. That made the security guy smile so he happily allows this gringo to enter!
    Finally our man reaches out to the bartender who is standing behind the counter, which in fact resembles a BRIDGE between all of the party people and the bottles of various spirits on the shelves.
    And they all SHOUT OUT to Chris and wish him luck with his book :)

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

      Hahahha dude this is tooo good :) :) :)

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

      This "story" should be pinned and referenced in Christopher's book. It happened really you know! :D

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

      Too good a example Dude :)

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

    It really amazes me how much of these discussed patterns really are things that we use often without even noticing. That being said, it is really important to sometimes sit down and define what they really mean and what they are applied for (or when they make the most sense). Great video as always, Christopher!

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

    One of the best video comparing Structural Patterns on youtube today - Thanks mate.

  • @liangzeng5778
    @liangzeng5778 5 років тому +67

    The decorator pattern UML has a small problem. The D has C instead of CD has D.

    • @PoulJulle-wb9iu
      @PoulJulle-wb9iu 4 роки тому

      why are u watching lol

    • @HIOLLJ
      @HIOLLJ 4 роки тому +2

      Yes, spotted the same.

    • @Adam-uu8dc
      @Adam-uu8dc 3 роки тому

      I was just about to write this lol.

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

      qFDGEOFGJerljgopergerjgoernglerjogrg - Yes.

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

      Pro trick: you can watch series on Flixzone. Been using it for watching all kinds of movies recently.

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

    This is a remarkable effort to help anyone getting the concepts right away with such simplicity and ease. Thanks!

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

    I can confirm that the bridge pattern is a natural conclusion, because I did it in my app the other week without knowing it's a pattern, and then watched your bridge pattern video the other day which pleasantly surprised me, since it means my design makes sense. In fact, it was even more or less the same example you used with different media types being used for the same UI components/widgets.

  • @r1konTheAutomator
    @r1konTheAutomator 4 місяці тому

    I gotta say...there are maybe 3 people who teach coding that I get a whole lot from. Jeffrey Way, Caleb Portzio, Luke Downing, and now you. You're a very good teacher my man

  • @Diego-db4uw
    @Diego-db4uw 6 років тому

    With this comparison, I realized that the abstract decorator is a proxy for the concrete component.
    Super series! Thanks. Waiting for the next one.

  • @richardnipples7574
    @richardnipples7574 6 років тому +5

    I enjoy your teaching style; It'd be great if you could expand on these patterns by showing us some use cases in which these patterns can be applied. Again, these series are great.

  • @safvanp567
    @safvanp567 7 місяців тому

    Christopher, your teaching style is exceptional, and I truly appreciate the clarity and depth you bring to these complex concepts. Thank you so much for sharing your knowledge in such an engaging manner.
    The idea of you writing a book is incredibly exciting! It's definitely going to be an amazing contribution to the field. Looking forward to delving even deeper into these fascinating topics through your upcoming book.

  • @safvanp567
    @safvanp567 7 місяців тому +2

    00:03 Comparison of structural patterns: bridge, adapter, decorator, proxy, and facade
    02:02 Structural patterns like decorator and facade provide ways to simplify complex interactions.
    06:15 Proxy pattern is used to control access to a real subject
    08:19 Bridge pattern involves an abstraction and an implementer with multiple concrete implementations
    12:21 The adapter pattern converts the interface of a class into another interface that the client expects.
    14:32 Facade simplifies a complex subsystem, while Adapter adapts from one interface to another.
    18:23 The proxy pattern provides a surrogate or a placeholder for another object to control access to it.
    20:18 Proxy pattern is used to control access to a single thing, while decorator pattern is used to solve the problem of class explosion and treat different combinations of classes as a special case.
    23:36 Structural patterns like Decorator and Proxy solve different problems.
    25:23 The bridge pattern decouples an abstraction from its implementation.
    29:10 Strategy pattern is about dependency injection
    31:00 Bridge pattern is a flexible way of coupling classes using interfaces.
    34:20 Facade pattern simplifies complex subsystems by providing a simpler interface.
    35:50 The video discusses the importance of books in learning and working with object-oriented programming.

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

    Videos like this are really helpful because they also help to do a quick revision of previous concepts.

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

    It's always a pleasure to see youtube notifications saying you have posted new episode. This last one deals well with understanding differences with structural pattern. And as someone has already mentioned you should write a book about this subject. Thanks to your good sense of explanation it will surely be a success.
    +1

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

    Super interesting video for me. I think it's the first time I actually understand many of these patterns. Thank you!

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

    wow -- this video is just great, especially sort of seeing the bridge pattern as a more general form as strategy pattern

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

    Binge watching the series... this was a very needed comparison between things that seemed related but nebulous before this instruction. Thanks for the lesson.

  • @obi-center
    @obi-center 5 років тому

    Wow! You are my favourite teacher, bro :)
    Now I am ready to finish my project.
    Thank you!

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

    excellent teaching......!! i'm still in shock how easily u covered all the points of them

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

    I got a habit of saying 'SUPER' before everything. You are super talented.
    Thanks for this series :)

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

    Hey Chris, Thank you so much for this helpful and great series. Waiting eagerly for the next video.

  • @misterkoko-code5140
    @misterkoko-code5140 6 років тому +1

    Super awesome! I have been waiting for this episode.

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

    This comparison video is very helpful to identify and choose the most suitable pattern for a specific problem.

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

    Wow. You are a phenomenal teacher. Amazing! Thank you.

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

    I don't know how to say that But I Just want to appreciate you for making this playlist, Its awesome

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

    Happy new year Chris .
    Thank you for all the efforts .
    Keep going bro , say my hi to your cat 😉

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

    32:00 "Programming is discovered rather than invented", I really like that and helps a lot with understanding where these design patterns stem from. :)

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

    Thank you very much Christopher, this serie helped me very much in my career

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

    Really awesome videos!, Waiting for rest of the design pattern videos..hope you will cover those soon

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

    Just brilliant, as always, natural mentor and teacher :)

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

    Amazing explanation of bridge pattern, just awesome! thanks)

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

    Boy, that was good! Thanks Chris!

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

    I hope you are one of my teacher in programming, your awesome🔥

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

    Excellent explained! Thank you so much!!!

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

    Great stuff! I would for sure buy your book linking the concepts together.

  • @marceloleoncaceres6826
    @marceloleoncaceres6826 9 місяців тому

    Another Great video, Thanks for sharing, I really appreciate your job

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

    Absolutely great video! Definitely would like to get your book.

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

    I am pleased to hear that strategy pattern looks like half the bridge.. because it also is the conclusion that I came to.
    bridge is to my mind, a more generalized strategy pattern (as I commented in the bridge pattern video).

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

    Love from India. Great explanation. Thank you

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

    wuahhhh, this is what it feels like to be taught by the best professor ~

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

    Thanks for all videos. Here comparison of strategy and bridge was very interesting to me.

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

    awesome comparison!

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

    The way this guy trying to speak the unspeakable(i.e. underlying essence that only be get through experience) is mindblowing.
    only I watch what he want to covey.

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

    Very Good comparing between the strategy pattern and bridge pattern.

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

    Awesome job! Thank you

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

    Great As always, thank you Chris

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

    You did a great job Ostad, keep it up ;)

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

    Excelente video, gracias por la explicacion.

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

    thanks Man your tutorial are very helpful . i statrd to read GOF befor this tutoral and i kind of got lost . after watched your vedios things start to make sence .. Thanks Bro !!

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

    Thanks, This is Amazing!

  • @boblim623
    @boblim623 4 місяці тому

    decorator: add function, multi-function, so that there will not be a lot of classes
    proxy: assess control
    bridge: two hierarchy, injection B into A

  • @habibgamal3696
    @habibgamal3696 10 місяців тому

    how are you ammmmazing like this ,thank you very very very much for this series , it is realy so cool😍😍😍😍

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

    Supernice! Waiting for the others. And for a comparison of the factory and the builder.

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

      Thanks for plus 1:ing more comparison videos. I'm glad the format was useful :)

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

    Comparison videos are always welcomed

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

    These videos are so adictive 😁😁. Thanks for your effort 🤓

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

    Excellently explained....

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

    That's cool. Thanks!

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

    great one!!!!!!!! keep it up!!!!!!

  • @mildlyinteresting1000
    @mildlyinteresting1000 4 роки тому +5

    Q: Dumb Questions
    Is it possible to create your own Design Patterns? Or is that something you have to be a “patterns guru” to do?
    A: First, remember that patterns are discovered, not created. So, anyone can discover a Design Pattern and then author its description; however, it’s not easy and doesn’t happen quickly, nor often. Being a “patterns writer” takes commitment.
    You should first think about why you’d want to - the majority of people don’t author patterns; they just use them. However, you might work in a specialized domain for which you think new patterns would be helpful, or you might have come across a solution to what you think is a recurring problem, or you may just want to get involved in the patterns community and contribute to the growing body of work.
    (c) Head First

  • @user-xw1xz8il1t
    @user-xw1xz8il1t 7 місяців тому

    Thank you! :)

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

    I really appreciate your efforts. Thanks a lot. You mentioned composition when we inject something into a class. But I think it's aggregation, not composition. Because composition is when we create an instance in a class and cannot separate it.

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

    Thanks, you make me a better developer.

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

    A big thank you

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

    Hi! Thanks for the great explanation as always :)
    I already ordered a copy of Head First book via your link, but if you do write a book in the end, I'll probably buy yours as well.
    Question: Would you be covering State Design Pattern any time soon?
    The info I find on the Internet or here on UA-cam is very confusing, and your explanation usually works wonders for me.
    Thanks again.
    Nurit.

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

    Great videos, thanks it's of great help :)

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

    As accessible as ever ... thanks!

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

      Glad to hear! Remember to let me know if I start to get lazy :) Thanks for watching :)

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

    good comparison between bridge and decorator!!!

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

    very helpful, thanks

  • @MohammedAbdulKhaliq
    @MohammedAbdulKhaliq 6 років тому +12

    Fine tuning your moustache , hahaha!! :) Please please please cover the other patterns or atleast create a short video for each one having the basic explanation and an example. Thank you.

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

      :) :) :) :) Thank you very much for your encouragement :)

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

    Hi Chris,
    I found your channel a few days ago. On the GoF patterns, I should say the content is really good. Specially this video that compares all constructional patterns. It would be great if you do the same for creational and behavioral patterns as well.
    Thanks a lot.
    Babak

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

    Chris you can compare decorator and builder as well. for example in your decorator video the example coffee with condiments can be solved with a builder and I feel is more suited to be solved as a builder since it's more like a creational problem

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

    great video!

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

    Thanks a lot for this video. Just one question for the Decorator UML. I think is the Decorator has-a Component. But in this video, you draw the ConcreteDecorator has-a Decorator?

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

    32:00 you probably mean Design Patterns are discovered rather than invented (not programming). Very good news to write a book about Design Patterns. I will be waiting for that book, you have a very special style of explaining the essence of Design Patterns.

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

      I actually did mean "programming was discovered not invented". But then I was trying to say that perhaps the same goes for design patterns. Like if math was discovered, then anything we inductively prove using the axioms ought be considered discovered rather than invented. Similarly, if the axioms of programming was discovered, then anything we build using programming too ought to be discovered rather than invented. Sorry for not being clear. Sometimes even my thinking is sloppy :D Thanks for picking up the quote. It's a super interesting quote :)

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

      Also, thanks for pushing for the book. I'm glad to hear that it would be interesting :)

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

    Awesome.

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

    superb, you are champion.

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

    @
    Christopher thanks again for your magic, any news about your book?

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

    Thank you for your explanation in the video. very easy to understand and comprehensive. I have 1 question about the Bridge design pattern. According to the UML there are 2 independent hierarchy in which let say Interface A has Interface B but indeed there are not any guarantees that A must have B inside (at least we have to ensure ourselves ), because A is an interface so we have not any mechanisms to do so ( please correct me if i am wrong). I am wondering what if i define Interface A and it has Not only B interface but also C,D,E,F .... and when i implement A , the implementation may have either B or C ,D or even 3 of them. so is it stil Bridge Pattern. how if A implementation does not have any B , C , D...

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

    Wonderful

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

    Hi , thx for really helpful videos .
    Does repository pattern exist in your todos ? :)

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

    Hi Crish, really appreciate your efforts for all design patterns, in this comparison you didn't include Composite design pattern. It will be good to see all structural design patterns together.

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

    Hi Chris. Let me start by saying - great job!!! There's a small mistake in the UML of the decorator. A Decorator has a Component, and not as drawn in this video, i.e. a concrete decorator has a decorator, which simply misses the point of being able to decorate the core component.

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

    thanks!

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

    excellent strategy to explain....

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

    Waiting for more videos on design patterns.

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

    thanks

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

    the empty sub set can be implemented as null object pattern🤓
    great videos!

  • @Den-Geist-Befreien
    @Den-Geist-Befreien 6 років тому +2

    Like the videos! If you could, maybe some code examples from the java core libraries that implement these patterns would be cool! For Example: Take Reader object from Files.IO package which can be decorated with a FileReader which can be decorated a BufferedReader; then explain the inner workings of the pattern! That would be cool!

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

      Good point! Actually, exactly this example is the Head First book :) :) :) But about real world examples. I’ll try to make them an important part of the ebook :) A few others have requested more real examples as well. Thank you for your encouragement and feedback! :)

    • @Den-Geist-Befreien
      @Den-Geist-Befreien 6 років тому

      Thank you for your reply! My apologizes... my own mistake on the Reader Class; should be File Class decorated by FileReader... and so forth. All from the java.io package ;P duh

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

    Great news about your upcoming book on design patterns. Nice comparison between the all the structural patterns. And I was just thinking about the relation between Bridge and Strategy pattern when you introduced the UML diagrams of both to show the difference. You do read minds :P . Thank you!

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

      Awesome. I'm happy to accommodate :) Thank you for watching and for the very kind comment :)

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

    great job

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

    Hi Chris, awesome class
    please explain Compisite Pattern
    thanks

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

    I want the topic about how dp solves design patterns

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

    In decorator pattern, it is also important the order of the decorators, not just which

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

    Can you share the same comparisons video for behavioral and Creational Design patterns.

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

    very good series sir , but i have a doubt regarding the decorator pattern , what if the arrangement matter to me like the problem you mentioned about addition and multiplication , what pattern should i use ?

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

    Comparing similarities would be nice too

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

    I'm not sure, but shouldn't be there dashed lines, when implementing an Interface? Like in the Proxy-Pattern? The two implementing classes R and P should have a dashed connection to S because of the dependency and not inheritance, shouldn't they?
    Nevertheless thanks for the comparison! Helped me a lot!

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

    Me: Where will our study of design patterns lead us?
    Christopher: Dependency injection into madness!!!!
    33:00

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

    I think Facade is very useful for libraries that are complex bcs it has more solutions than you actually need.

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

      Tried to use it for my micro-libraries even before i hear about GoF Patterns, so yeah)