Composite Pattern - Design Patterns (ep 14)

Поділитися
Вставка
  • Опубліковано 16 гру 2024

КОМЕНТАРІ • 206

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

    Thumb up for that board-eraser jump 16:03, hahaha

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

      😊😊😊

    • @gerdkah6064
      @gerdkah6064 5 років тому +3

      there ist a composition of 2 Christophers at 16:09 ^^

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

      Chris: Jump at 16:03
      Me: Subscribe (just kidding, ive been subs since ep 1)

  • @amiramohammed1568
    @amiramohammed1568 Рік тому +3

    we are in 2023 and you are the best one out there teaching design patterns ! THANK YOU

  • @pacoraby532
    @pacoraby532 7 місяців тому +3

    I love how he confuses himself with all the open and close tags; man, that was pure gold. It just goes to show it happens to the best of us. This is the best pedagogical series on design patterns, hands down, and it's kind of funny on top of it. Thank you, Christopher.

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

    The best design patterns video tutorial series i've seen until now on youtube!

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

    I wish my university had teachers like you.
    Thank you!

  • @dp-bhatt
    @dp-bhatt 7 років тому +10

    One of the best tutorials I have ever watched on Composite design pattern. Thank you very much.

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

      Thanks :) I’m glad to hear :) Thanks for watching and for commenting.

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

    “Removing this stuff” at 16:10 is the only thing you are better at than being the best OOP patterns teacher on UA-cam! For real, that was fookin epic!

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

      You mean is he not good at explaining patterns.

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

    Hi Christopher, I'm Italian, I'm studying Computer science at university. I'd like to thank you for this amazing playlist (GoF strategy patterns). I successfully passed the "Software engineering subject" with 30/30. Whiteout your video I would have never been able to do this. THANK YOU SO MUCH. I hope you will read this! I wish you the best. Sorry for any English mistakes.

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

    I could have watched a movie or a series for 1 hour 11 minutes; however, i choose composite pattern! Kind of proud of it and happy to see people in the comments who cares about the code they write and appreciate a good design

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

    This video still applicable in 2024. Amazing , it provides a solid exploration of the Composite Pattern, highlighting its usefulness in hierarchical structures and recursive operations. The emphasis on simplifying code through polymorphism and recursion is awesome. The discussion on immutability adds an important perspective, as it aligns well with modern C# practices.

  • @dannievasileva9069
    @dannievasileva9069 6 місяців тому +1

    Thank you so much for this series, it has been immensely helpful. Please never stop teaching!

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

    I must say this channel is my discovery of the week.

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

    This tutorial series is great! Right now I am watching all of them to study for my masters CS degree and I love your way of explaining things in a simple but entertaining way. Just wanted to say it is the best tutorial series on this topic i have found. Thank you so much!

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

    Thank u SO MUCH !
    with 15 minutes of this content I could understand the composite design patter
    Greatings from Brazil !

  • @segafrompk
    @segafrompk 4 роки тому +21

    Hey Chris! Love your videos and I'm learning so much from you! Thank you for making these, I really appreciate it! I'm sad that you are not uploading anymore, but that's life, I know it's hard to make a living on UA-cam. Hope you would make some CS course on udemy or a similar platform, you are a great teacher and you are great at making others pay attention even during these long videos. Cheers!

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

    I was asked during an interview to design code that compute the price of boxes containing items. Assuming that each item inside the box has a price, and that the box itself has a price.
    I responded with a recursive code, including a "if" statement.
    When the interviewer asked about the composite pattern, which would have been another way of doing it, I didn't know... I somehow had the job.
    But now, I could talk about composite pattern (thanks :) ).

  • @martijn2973
    @martijn2973 Рік тому +3

    Holy shit, I've never had someone explain abstract concepts so clearly. Every single time I was thinking "but if he says this, how does this scenario work?", and like 3 seconds later, he would further explain exactly what I was doubting.

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

    PING. All the explanations you are saying make a lot of sense and they really do make us (at least in my case) understand better and question our knowledge as WHY we do a certain thing. You are a good educator.

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

    at around 27:00 min in the video you have mentioned "interface segregation principle" and you said leaves should not be forced to have add() and/remove() methods but what I think is leaves are not permanently leaves in this scenario .We can see leaves as children or teenagers who might become parents at some point of their life-cycle .

  • @МаксимАлексеев-ч4й
    @МаксимАлексеев-ч4й 4 роки тому +4

    The best discussion about this pattern I'd found on youtube. That's what I was looking for after reading the book's chapter. Thank you!

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

    Hi! I am a newbie, I have been watching these videos in the playlist order, starting with the first one. In the beginning, I barely understood the abstract part and had to look up examples of patterns in the language I am studying to at least barely understand how they work. In this video, I finally understood the abstract pattern just from your explanation (and it took only a week and a half). Thank you.

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

    The best design patterns video tutorial series i have seen until now . Superb

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

    This video got demonetized :( Anyone have an idea of why the algorithm flagged the video? Maybe the "correction boxes" that I put over my face when I said the wrong word looked like censoring bad language? I requested a manual review but have to wait for it :/

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

      It was quickly remonetized after a surprisingly quick manual review (thank you UA-cam). Unfortunately I don't know why it originally was demonetized and I guess we won't get to know since (unless I remember incorrectly) the algorithm is neural network based :D But I would really guess it was the text-over mouth-boxes. That "pattern" ought to be common in videos with heavy use of foul language :) Makes sense right? Ps. thank you very much for the concern :) :) :)

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

      Many others are experiencing the same issue for no reason, probably the algorithm still needs to "learn"

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

      Because you satisfied some NoAdvertise Pattern. If some ad shows advertising some other book, it is a fallacy ad principle.

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

    You should go on the stage with such a proficient mimic and wonderful performances in front of the camera :) thank you for these series, I have got addicted to them

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

    Great lessons, very easy-to-understand complex topics, even though the lessons are long.
    The type of aggregation arrows are necessary for UML diagrams sometimes, and they are not vague if you'll think about it.
    The aggregation arrows are of two types in UML, has one and has many, the one, used in this tutorial is - has many.
    So it means, that the particular component has many parent components.

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

    You have a clear voice, you explained well. You're good. Thank you.

  • @JitendraSarswat
    @JitendraSarswat 7 років тому +48

    Yeah... I would love to see a discussion over recursion. Can you do that?

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

      Thanks for the ping :) :) I’m planning an algorithms series and this video will probably go into that series. Need to think a bit about how to approach it. Maybe I should just e.g. do a series where I compare non-recursive solutions to recursive solutions. Or something along those lines :) Thanks again for the ping and for watching :)

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

      @@ChristopherOkhravi What ever approach you prefer, it doesn't matter, just do it. U R great

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

      @@ChristopherOkhravi algorithm series please

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

    It's 2021 and still best explanation on the internet.

  • @swellbot5738
    @swellbot5738 7 років тому +2

    Had an exam 2 weeks ago, used all your videos for study and this one came up - was so gutted you hadn't made it sooner. Either way, here I am watching it because the quality of your videos are great. props. Keep on doing what you're doing.

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

      I'm sorry to hear and terribly sorry I wasn't able to upload sooner :( It takes an outrageous amount of time to edit these videos :D Either way, I hope you do get a chance for a re-exam :) and I hope you nail it :D Thanks for watching and for the encouragement :)

    • @swellbot5738
      @swellbot5738 7 років тому

      Christopher Okhravi oh mate don't worry in the slightest. I just had to look elsewhere for this one, got it in the end, you just articulate and explain it so nicely you became a 'one stop shop'.
      I was hoping the strategy pattern would come up so I could wow them with your quote from sandi metz about inheritance haha :D
      Rock on, keep it up, look forward to your future videos

  • @Tall-Cool-Drink
    @Tall-Cool-Drink 6 років тому +1

    Christopher, you have a way of making everything interesting.......lol....so discuss away, I'll be watching and listening.

  • @ShyamSharma-pg1zu
    @ShyamSharma-pg1zu 3 роки тому

    Awesome . Listening you is like doing meditation . Its not easy to get out of focus

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

    Great video. The ToDoList example nailed the principles of the pattern. Practical examples perfectly highlight the need and use of design patterns.
    The point you were trying to convey with the mutability discussion regarding whether a mutated object is the same object as before or a new one is actually a programmatic case of the famous paradox called Theseus's paradox.

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

    Super thumbs up, Christopher. You explained in a very simplified way.

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

    Thank you so much! You can't imagine how helpful these videos are. At least for me, this seems like the best way to explain design patterns.

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

    he specified so many times about books ... finally, I bought it on kindle ...

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

    That design patterns book is the required text for my Uni class, but I couldn't understand it. Thank you so much, these videos facilitate real learning!

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

    Yes, a video about recursion, in particular about backtracking, would be great!

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

      Absolutely. I would love to have recursion explained by Mr Christopher. Did he post anything like that, does anyone know?

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

    Hey man. I like your videos. I watch your video after I read one chapter of book. It is so helful for me.

  • @sia-yx3wd
    @sia-yx3wd Рік тому

    You're so good at explaining!!! Thank you so much for these videos they're very helpful!!!!!!

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

    You have a tremendous teaching gift bro I visit your videos still to this day. You can dice a complex concept into an understandable form for your listeners. I hope you are doing well bro!

  • @Messier_-82
    @Messier_-82 6 років тому +4

    Great explanation as always! And yes, i'd like to see a video from you about recursion :)

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

    Java Swing is built on this Design Pattern, where you have Container and Component. And really, that's how Composite Pattern should be designed. There is no need for a distinct "Leaf" class. A "Leaf" is simply a "Component" that has no sub-components. At any given point, a "Leaf" should accept new components and become a "Composite". Long story short, it is more effective to remove "Leaf" from the design and deal only with Containers and Components the way Java Swing have done it. Components containing zero sub-components are in essence leaves. However, you can transform this leaf into a composite simply by adding components to it. So, the best UML diagram for Composite Pattern is what is illustrated at 27:36 without the class "Leaf" in it.

  • @ta-cvig
    @ta-cvig 4 роки тому

    Thanks for this series man. I learned a lot just from 2 videos thus far.

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

    I've made some PHP HTMLElement with this D.P.. Works fine !

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

    had to watch 3 times now i understand thanks man

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

    Just to add, you don't necessarily need a heading tag inside li. Headings are for hierarchal structure of a sectioning element of the document like section, header, footer, etc (as opposed to of a flow content ie ul). You might need the first heading to make a new subsection for your list in relation to the section it's in, but not necessarily inside of them

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

    Hey Chris,
    I really love while watching your videos coz you make it so interesting and easy to understand. I am very glad to have your DP series to learn from.
    I was wondering if you could please put a series on DSA as well coz I have been finding it difficult to make a proper decision in what way to start grasping them and what is the right resource for me but after watching your DP series I was wondering if you could please take out your precious time for a DSA series.
    Thanks and a lot of support

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

    One could say that a Composite Pattern is useful when a node (object) could have two distinct roles (i.e. Parent or Child, Component or Container), depending if the point of reference or a given node is root or not.

  • @nesreenmosimi9925
    @nesreenmosimi9925 7 років тому +4

    very useful and clear , thank you alot :)

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

    Love these videos! I would be interested in seeing a further discussion about handling the add()/remove() scenarios with mutability vs. immutability. Did another video ever get made to go over how that would work?

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

      Hi, have you got your answer already? Mind if you share it? I'm currently looking for it too

  • @shayaxelrod7691
    @shayaxelrod7691 4 роки тому +6

    "So what do we need to do, to do a todo list?" 🤯

  • @nijuyonkadesu
    @nijuyonkadesu 8 місяців тому

    the pattern itself is so sophisticated, and now that I think about how to initialize this...
    ahhhh
    breaks my poor head

  • @vinokanthvelu2660
    @vinokanthvelu2660 5 років тому +2

    @Christopher Okhravi Please do the algorithm series if you have time. Will be very useful :)

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

    really enjoying your hard work. Thanks a lot!!!

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

    I think at 24:00 b would be equal to 5 because the value of a is incremented after the operation ( Im only speaking for the few languages I know like C++ and C# , there might be some weird languages where this is not the case ) you'd have to use ++a ;)

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

      oh shoot, didn't see the correction because of the 2X speed, my bad :D :D

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

    The best explanations!

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

    Great video. There are some minor focus issues around 59:00 which had my eyes going googly while trying to read the updated code in the bottom right, but, great video.

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

    You're an amazing teacher!

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

    hi
    Why can't we just omit Leaf class from the picture? Couldn't we simply use Project with empty todos instead?

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

    I 100% agree on your statement regarding immutability, but in case of a tree structure, which could have many different nodes copying is quite expensive. Wondering what you would choose in such a scenario?

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

    my man!! great vids n explaining, much appreciated!!

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

    Great video. Only the thing is leaves do not have to implement Add and Remove methods if you don't define them at the interface, so this is not violating the interface segregation principle. We can need different methods on a composite node than leaves. It's very typical. I only can't entirely agree with that part. Other than that, it's a great explanation. Regards

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

    First of all, I really must congratulate you for this series of videos.
    It is in absolute the best that I've ever seen on the design patterns.
    It's exhaustive and you succeed in explaining the design pattern having a good time.
    What I mostly appreciate, it is not the technical realization of the pattern itself,
    but the explanation of problem that is intended to be resolved, by adopting a specific pattern.
    (the "mind set" of the pattern).
    I have a question about the composite pattern:
    Is there really need of leaf class?
    I'm working on a project started by a very experienced software developer. He adopted the composite pattern but without using the leaf class; he simply uses just one class: the composite class. If a COMPOSITE instance has children, it is "considered" a "Complex-composite", if it has no children it is as a "Simple-composite" (a leaf in the original pattern, but in our case IT'S JUST A COMPOSITE CLASS INSTANCE WITH NO CHILDREN).
    When a component is added to a "Simple-composite", that one "becomes" automatically a "Complex-composite" (it was already an instance of composite class, but now it has children, and this is the only difference from its previous state).
    This involve the discussion about mutation (in our scenario, the mutation is a specific design request, and we cannot create a new tree, every time the data structure changes):
    In our scenario it is requested that the user can add to the system an "object of the real world" that it is, for instance a "car" and,
    at that specific time, the user has no information or doesn't want to insert them, about what a car is (at that point a "car" IS JUST A NAME, or a bunch of properties, and then it is a simple component, "a leaf" in the original pattern).
    In a second time, the user can or wants to specify what a car is: he specify that a car have four wheels (at this point a "wheel" IS just a name, or a bunch of properties, and then it is a simple component, a leaf, always in the original pattern), a shell (idem: a leaf) and an engine (again a leaf).
    In a third time, the user wants to define better what an engine is; so, it adds to the engine four cylinders (just names), a crankshaft (just a name), and so on... but by doing this the COMPOSITE CLASS INSTANCE "engine" becomes a "Complex-composite".
    Each time the user adds a new "real world object" to an existing simple component, the new "real world object" it's a leaf (or better a "Simple-composite") and its parent from a leaf, becomes a "Complex-composite".
    I repeat for clarity: I call them "Simple-composite" and "Complex-composite", but the class is just one: the Component.
    And finally, the question is: it is really needed to have two distinct objects: composite and leaf?
    (A father isn't just a PERSON with one or more children? and a child isn't just a PERSON without any children? (both of them are just a PERSON))
    To me this approach (that is not type checking) has the big advantage to add semplicity to data structure and permits to manage all the objects in the same way.
    What do you think about it?
    Thank you very much

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

      Sorry, i've made a mistake: "I repeat for clarity: I call them "Simple-composite" and "Complex-composite", but the class is just one: the ** COMPOSITE **".

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

      In the video 'leaf' class exists to provide different implementation for 'getHtml()' method. Obviously you can use only one class but if implementation of some method differs depending on being 'simple' or 'complex' then you have to use conditional statement in that method (and that's what in some cases people tries to avoid by using good class structure). In your scenario (with mutation being part of your design) you don't really want to use 'leaf like class' because there is no way to assign further children to it. It sounds OK to me.

  • @matt-g-recovers
    @matt-g-recovers 5 років тому

    I absolutely have loved this series so far Chris.
    I'm in American I'm 40 years old and I don't think that I'm too far out there but I've never heard of Part whole hierarchies... well let me digress I have heard of it, in fact it was another composition design pattern video I was watching in which I heard that term....I just don't know what it means I've never had it to find for me...

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

    26:50 I feel very confused now, `no client should be forced to depend on methods it does not use`, a client = `has a`, not `is a`. In your scenario, it breaks Linskov's Substitution principle, as a Component can't be replaced with a Leaf. Please correct me if I'm wrong.

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

    deam this dude is going crazy :D love it

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

    Please cover the Visitor and Builder pattern if you plan to continue this series 🙏🏼

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

    may I ask you for preparing a new section for "Chain of Responsibility Design Pattern"?

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

    So what's the difference between composite pattern and n-ary tree? For example implementation In Javascript, the Node hold array as reference to all childs down the tree.

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

    Another excellent topic would be dependency injection. Trying to persuade my colleagues about the case for this because of the testability of units.

  • @bsuperbrain
    @bsuperbrain 7 років тому

    Magic jump what removes stuff from the board. Haha! Anyway, nice to see this new one, long ago waited.

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

      Yeeeeah :) My editing skills are sub-par so it was tricky to figure out how to do it :D Thanks for watching and I hope the video was accommodating :)

  • @jessecalato4677
    @jessecalato4677 5 місяців тому

    doesn't matter much for this example, but when you talk about mutation you say @24:27 you say that b will be 6, but that's not true, you used the post decrement opperator, the value of a is returned before it is incremented, so b would actually be set to 5, and then a becomes 6.

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

    In the book it was very confusing, this pattern it mixes my weakest skills in programming. Trees and recursion, I know conceptually what they are, but regarding trees I never used them for a solution and I can't visualize much their ideas and recursion I used it at some point with basic programs like fibonacci algorithm, but its not like I am experienced with it. I hope your video will make more sense.
    Edit: Oh shit, I went checking on trees again and I ended up watching the MIT classes.. quite a rabbithole and I am back.

  • @liorocker1
    @liorocker1 7 років тому +1

    Yes please, hope you can explain recursion as good as you teach design patterns.

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

    regarding the discussion about where to put add/remove(), what if there's no separate classes for leaf vs composite. What if all you got is just "component" concrete class, so logically if it doesn't contain any other component, then it should be treated as leaf, otherwise composite, then there's no need to discuss where to put the add/remove method and yet still have a "composite pattern".

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

    you're a life saver

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

    man, its awesome channel, thank u

  • @cyantulip
    @cyantulip 7 років тому

    Hey Chris! Thank you so much for doing these videos. Your explanations are well thought-out and very comprehensive. I find them very helpful.
    I have a request for you. Could you please do a video about shared libraries, static vs dynamic linkage, implicit vs explicit loading, in a modern OS environment (i.e. how things work now, not how they used to work 20 years ago.)
    Oh, and I’d be interested in that recursion discussion too.
    Thanks again, and keep up the good work! :-)

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

    Thanks for making such awesome videos. I have one doubt. Why you put the logic of wrapping "ToDo" text inside in "Project" class. Shouldn't it be responsibility of "ToDo::GetHTML()" method?

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

    wonderful class

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

    thanks for making this video .

  • @facundorodriguez92
    @facundorodriguez92 7 років тому +4

    Hello Christopher,
    I would like to know if there is a possibility that you dedicate any video to the concept of TDD. I am beginning to immerse myself in that subject and I would like to know your opinion about it.
    Thank you very much.
    Saludos desde Argentina!

    • @facundorodriguez92
      @facundorodriguez92 7 років тому +3

      Sorry I should have done a search before suggesting. For those interested here speaks of similar concepts:
      ua-cam.com/video/zatcvoNqSaI/v-deo.html

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

      Nice! You were pretty quick to find it though :) :) Lemme know if you find anything specific in the videos that you would like me to explore further in future videos. Also, thank you very much for suggesting topics and thank you very much for following the channel 🙂

  • @FaizKTG
    @FaizKTG 13 днів тому

    An hour video for one PATTERN? Yup I'm going to fail my exam.

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

    Great video and the whole series. And since I am here - isn't folders structure an example of composite pattern? It is a mutable tree and any node could be either a folder or a file (leaf) but we don't want to care about it when doing operations on them - add, delete, etc. I can't think of any other way of doing folders structure.

  • @Tall-Cool-Drink
    @Tall-Cool-Drink 6 років тому +1

    lol.....I glad I'm not the only one confused by "part-whole"......I'm confused by many phrases like this throughout software coding methods.....

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

    that is awesome! thank you

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

    Chris, another wonderful example and explanation of the pattern!
    Though I think, the interface name should've been like "TodoItem" instead of "TodoList". Then simple leaf implementation will be SingleItem: TodoItem. and ProjectItem: TodoItem.
    Does it make sense? Name "ToDoList" as an interface is confusing because it's implying a list of items already.
    Thanks, Christopher!

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

    Can composite pattern use to for crafting feature?

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

    God bless you man

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

    I understand it is all about mutability, but wouldn't it be more flexible to create just one class and determine whether it a leaf or a composite based on whether it contains subitems or not at all? Of course, it would force us to use a conditional, but it seems to be more like a composition over inheritance

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

      But yes, I guess it depends on the specific case, whether we need to wrap composites into new ones without altering the first ones, or we will know the entire structure and just use constructor, or we need to extend different nodes dynamically

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

    Hi Christopher, I have seen your video about strategic pattern.In that you discuss about the rubber duck and IFlyBehaviour interface.Similarly Can't I make an interface "IAddBehaviour" for Component and define add() into it and create two more interfaces from IAddBehaviour.Let's say AddNotSupportedBehaviour and AddSupportedBehaviour for leaf and composite respectively.Doesn't that make sense?Shouldn't we be doing that?

  • @AshokKumar-uf5nj
    @AshokKumar-uf5nj 5 років тому

    Hi @Okhravi, Super likes the series. But I don't see the Builder and Chain of responsibility patterns covered in the playlist. Can you point me to these if you have covered ?

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

    @christopher, I am confused. Doesn't decorator pattern code look the same? you add some functionality and pass the request to the successor decorator untill you reach the terminating decorator?

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

      oh there is another video for that :)

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

    Oh man, too detailed example, we understand it :D I had to rewind forward 15 mins xD Anyway, good job man! Keep up!

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

    Why do we need a separate leaf todo. Can’t a leaf todo be replaced with a project todo with an empty todo list?

  • @BangsarRia
    @BangsarRia 6 місяців тому

    GoF intends that the Composite Pattern be used in cases that the Client does not have to distinguish between Nodes and Leaves.
    GoF p167, point 4 expressly addresses the issues of ISP and LSP: "trade-off between safety and transparency".
    GoF's use of "transparency" here makes me uncomfortable, because I don't think they mean that at all, and the word does not appear in the index, so we don't know what they mean by it. In this context I think they mean "uniformity", or even "abstraction".
    While we're talking about terminology, GOF was published before Java was revealed. So we see "operation" for "method" throughout. They might have gone with "function" instead of "method" anyway, as not all languages use "method" and "member" etc as terms.

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

    What about different traversal orders of the tree structure? I see that the video uses preorder (I visit the root node, then the left subtree, then the right one, in the case of a binary tree). I understand how to implement inorder and postorder. These are all depth first traversals. What if I want to traverse the tree structure in level order (breadth first)? Does the recursive nature of the Composite pattern disallow that?

    • @BangsarRia
      @BangsarRia 6 місяців тому

      No. Traverse via a slightly different recursive algorithm. Or iterator.

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

    "I don't wanna talk about recursion if u r not familiar with recursion." 😆

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

    16:07 Didn't see that coming

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

    Great video 👍
    Can u talk more about mutable