No video

Composite Pattern - Design Patterns (ep 14)

  Рет қаралды 144,113

Christopher Okhravi

Christopher Okhravi

Күн бұрын

Пікірлер: 203
@isaaczhu9223
@isaaczhu9223 6 жыл бұрын
Thumb up for that board-eraser jump 16:03, hahaha
@ChristopherOkhravi
@ChristopherOkhravi 6 жыл бұрын
😊😊😊
@gerdkah6064
@gerdkah6064 5 жыл бұрын
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)
@pacoraby532
@pacoraby532 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.
@ChristopherOkhravi
@ChristopherOkhravi 3 ай бұрын
😊😊😊
@jriseup7201
@jriseup7201 6 жыл бұрын
The best design patterns video tutorial series i've seen until now on youtube!
@amiramohammed1568
@amiramohammed1568 Жыл бұрын
we are in 2023 and you are the best one out there teaching design patterns ! THANK YOU
@prateeksharma9321
@prateeksharma9321 6 жыл бұрын
I wish my university had teachers like you. Thank you!
@arthurfedotiew3609
@arthurfedotiew3609 2 жыл бұрын
“Removing this stuff” at 16:10 is the only thing you are better at than being the best OOP patterns teacher on KZfaq! For real, that was fookin epic!
@shankar7435
@shankar7435 6 ай бұрын
You mean is he not good at explaining patterns.
@dp-bhatt
@dp-bhatt 6 жыл бұрын
One of the best tutorials I have ever watched on Composite design pattern. Thank you very much.
@ChristopherOkhravi
@ChristopherOkhravi 6 жыл бұрын
Thanks :) I’m glad to hear :) Thanks for watching and for commenting.
@dannievasileva9069
@dannievasileva9069 2 ай бұрын
Thank you so much for this series, it has been immensely helpful. Please never stop teaching!
@ChristopherOkhravi
@ChristopherOkhravi 6 жыл бұрын
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 6 жыл бұрын
It was quickly remonetized after a surprisingly quick manual review (thank you KZfaq). 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 жыл бұрын
Because you satisfied some NoAdvertise Pattern. If some ad shows advertising some other book, it is a fallacy ad principle.
@lucad4472
@lucad4472 4 жыл бұрын
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.
@Koriyi
@Koriyi 3 жыл бұрын
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!
@segafrompk
@segafrompk 4 жыл бұрын
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 KZfaq. 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 жыл бұрын
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 Жыл бұрын
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.
@machi992
@machi992 3 жыл бұрын
I must say this channel is my discovery of the week.
@henriquedesouza412
@henriquedesouza412 3 жыл бұрын
Thank u SO MUCH ! with 15 minutes of this content I could understand the composite design patter Greatings from Brazil !
@ianauandrei
@ianauandrei 4 жыл бұрын
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.
@user-ss2rj4wz5s
@user-ss2rj4wz5s 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 Жыл бұрын
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.
@JitendraSarswat
@JitendraSarswat 6 жыл бұрын
Yeah... I would love to see a discussion over recursion. Can you do that?
@ChristopherOkhravi
@ChristopherOkhravi 6 жыл бұрын
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 жыл бұрын
@@ChristopherOkhravi algorithm series please
@denispronin2417
@denispronin2417 5 жыл бұрын
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
@nandukishore844
@nandukishore844 5 жыл бұрын
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 .
@swellbot5738
@swellbot5738 6 жыл бұрын
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 6 жыл бұрын
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 6 жыл бұрын
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
@raghuhuchchannavar6184
@raghuhuchchannavar6184 2 жыл бұрын
The best design patterns video tutorial series i have seen until now . Superb
@georgebadza
@georgebadza Жыл бұрын
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.
@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.
@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.
@Tall-Cool-Drink
@Tall-Cool-Drink 6 жыл бұрын
Christopher, you have a way of making everything interesting.......lol....so discuss away, I'll be watching and listening.
@ashishgarwal4103
@ashishgarwal4103 3 жыл бұрын
Super thumbs up, Christopher. You explained in a very simplified way.
@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!
@Messier_-82
@Messier_-82 6 жыл бұрын
Great explanation as always! And yes, i'd like to see a video from you about recursion :)
@anonymousmask4224
@anonymousmask4224 2 жыл бұрын
It's 2021 and still best explanation on the internet.
@DhrumilShahDOTin
@DhrumilShahDOTin 4 жыл бұрын
he specified so many times about books ... finally, I bought it on kindle ...
@ChristopherOkhravi
@ChristopherOkhravi 4 жыл бұрын
😊😊😊
@baja_taco3564
@baja_taco3564 Жыл бұрын
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!
@ShyamSharma-pg1zu
@ShyamSharma-pg1zu 3 жыл бұрын
Awesome . Listening you is like doing meditation . Its not easy to get out of focus
@JohnReloaded
@JohnReloaded 6 жыл бұрын
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?
@sia-yx3wd
@sia-yx3wd Жыл бұрын
You're so good at explaining!!! Thank you so much for these videos they're very helpful!!!!!!
@elisedappollone8643
@elisedappollone8643 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 жыл бұрын
Hi, have you got your answer already? Mind if you share it? I'm currently looking for it too
@kartikmangal3218
@kartikmangal3218 2 жыл бұрын
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
@ta-cvig
@ta-cvig 3 жыл бұрын
Thanks for this series man. I learned a lot just from 2 videos thus far.
@jamalbutt7864
@jamalbutt7864 6 жыл бұрын
Chris! You are going to heaven. I wish I could meet you, and thank you in person! Best wishes from Pakistan!
@ChristopherOkhravi
@ChristopherOkhravi 6 жыл бұрын
Thank you for the blessing 😀 And thanks for watching :)
@shayaxelrod7691
@shayaxelrod7691 3 жыл бұрын
"So what do we need to do, to do a todo list?" 🤯
@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
@suyashpatel2652
@suyashpatel2652 5 жыл бұрын
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?
@vinokanthvelu2660
@vinokanthvelu2660 5 жыл бұрын
@Christopher Okhravi Please do the algorithm series if you have time. Will be very useful :)
@nijuyonkadesu
@nijuyonkadesu 4 ай бұрын
the pattern itself is so sophisticated, and now that I think about how to initialize this... ahhhh breaks my poor head
@ChristopherOkhravi
@ChristopherOkhravi 4 ай бұрын
You got this! Hang in there! 💪
@VoyagerJourneys
@VoyagerJourneys 2 жыл бұрын
Hey man. I like your videos. I watch your video after I read one chapter of book. It is so helful for me.
@hfontanez98
@hfontanez98 5 жыл бұрын
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.
@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?
@nesreenmosimi9925
@nesreenmosimi9925 6 жыл бұрын
very useful and clear , thank you alot :)
@ChristopherOkhravi
@ChristopherOkhravi 6 жыл бұрын
Thank you. And thanks for watching 🙂🙂
@_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.
@linux_lectures226
@linux_lectures226 Жыл бұрын
had to watch 3 times now i understand thanks man
@leszektarnawski9460
@leszektarnawski9460 6 жыл бұрын
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.
@ArtcodEAscetik
@ArtcodEAscetik 2 жыл бұрын
I've made some PHP HTMLElement with this D.P.. Works fine !
@samanehmonemirad3723
@samanehmonemirad3723 3 жыл бұрын
may I ask you for preparing a new section for "Chain of Responsibility Design Pattern"?
@felixjost8206
@felixjost8206 2 жыл бұрын
The best explanations!
@maximkuzminsky
@maximkuzminsky 6 жыл бұрын
hi Why can't we just omit Leaf class from the picture? Couldn't we simply use Project with empty todos instead?
@shanmukhchandrayama8508
@shanmukhchandrayama8508 3 жыл бұрын
we need a base condition right ,so for that we are using leaf class
@jvsnyc
@jvsnyc 2 жыл бұрын
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.
@joannalai7147
@joannalai7147 2 жыл бұрын
Please cover the Visitor and Builder pattern if you plan to continue this series 🙏🏼
@alecc8231
@alecc8231 4 жыл бұрын
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!
@codingwithgraceandtruth2456
@codingwithgraceandtruth2456 2 жыл бұрын
really enjoying your hard work. Thanks a lot!!!
@TubeOutside
@TubeOutside 5 жыл бұрын
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".
@MrEnsiferum77
@MrEnsiferum77 5 жыл бұрын
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.
@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
@facundorodriguez92
@facundorodriguez92 6 жыл бұрын
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 6 жыл бұрын
Sorry I should have done a search before suggesting. For those interested here speaks of similar concepts: kzfaq.info/get/bejne/sMekltmgs9e3kX0.html
@ChristopherOkhravi
@ChristopherOkhravi 6 жыл бұрын
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 🙂
@mattgraves3709
@mattgraves3709 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...
@jessecalato4677
@jessecalato4677 Ай бұрын
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.
@pedromedeiros6907
@pedromedeiros6907 Жыл бұрын
wonderful class
@prolamaamvs6952
@prolamaamvs6952 Жыл бұрын
deam this dude is going crazy :D love it
@radiagulzan
@radiagulzan 4 жыл бұрын
You're an amazing teacher!
@BangsarRia
@BangsarRia 2 ай бұрын
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.
@BrunoOlivera22
@BrunoOlivera22 3 жыл бұрын
my man!! great vids n explaining, much appreciated!!
@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 ?
@cyantulip
@cyantulip 6 жыл бұрын
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! :-)
@liorocker1
@liorocker1 6 жыл бұрын
Yes please, hope you can explain recursion as good as you teach design patterns.
@ChristopherOkhravi
@ChristopherOkhravi 6 жыл бұрын
Thanks for the feedback :)
@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
@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 6 жыл бұрын
Magic jump what removes stuff from the board. Haha! Anyway, nice to see this new one, long ago waited.
@ChristopherOkhravi
@ChristopherOkhravi 6 жыл бұрын
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 :)
@rajsoni7085
@rajsoni7085 Жыл бұрын
thanks for making this video .
@piotrjaga6929
@piotrjaga6929 Жыл бұрын
that is awesome! thank you
@shinemperor8950
@shinemperor8950 5 жыл бұрын
Loving this series. Thank you for this. I during the video you mention something about refactoring, branching logic and polymorphism. Was this video already made? (I haven't gone through all your content yet) Because I find the idea of replacing branching logic with polymorphism absolutely fascinating.
@danielkapitanov1816
@danielkapitanov1816 6 жыл бұрын
you're a life saver
@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.
@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.
@ribaker822
@ribaker822 5 жыл бұрын
Hey Christopher, thanks again for this video. On your point on Interface Segregation Principle, while I agree with you, I thought that Leaf was not a client of Component, but actually is a component. Or maybe it's me not fully understanding the ISP?
@MrZnSstr
@MrZnSstr 2 жыл бұрын
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.
@khoinguyen-ft2ys
@khoinguyen-ft2ys 3 жыл бұрын
Thanks!
@feosys7695
@feosys7695 5 жыл бұрын
man, its awesome channel, thank u
@tarike9808
@tarike9808 2 жыл бұрын
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
@pushpendrapratap3116
@pushpendrapratap3116 3 жыл бұрын
"I don't wanna talk about recursion if u r not familiar with recursion." 😆
@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?
@Tall-Cool-Drink
@Tall-Cool-Drink 6 жыл бұрын
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.....
@moathnaji8505
@moathnaji8505 5 жыл бұрын
thanks for the big effort its really clear, but i need to ask where the TodoList come from ?
@rizwansabir2448
@rizwansabir2448 Жыл бұрын
thanks
@davidspencer3726
@davidspencer3726 4 жыл бұрын
Immutability's an odd idea. That you can't change an object, but must recreate it. Logically therefore, what contains that object also cannot be modified; it too must be recreated. So ultimately you end up having to recreate zillions of gigabytes of stuff just to increment an integer. Could you explain how this isn't the dumbest idea computer science has ever come up with?
@SoferPeOZN
@SoferPeOZN 3 жыл бұрын
16:07 Didn't see that coming
@TheAd021
@TheAd021 4 жыл бұрын
Hi, your videos are really helpful and I absolutely love this series, learning a lot from it. I know, this is an old video, but I'd be happy, if you replied. This example got me confused - I understand how GetHTML() method works, and the relations between classes and interfaces here. But what I don't understand is how would one construct such a structure. I mean, you get rid of conditional expressions for rendering html, but you'd have to use them for construction - somehow you need to know, what instance you want to create (is it going to be "new Todo()" or "new Project()"). Say, you fetch the whole TO DO list from a database, and then you have to populate it to the structure from your example in memory. What would be the right way to approach this task? My thoughts are that you start with one empty root component and use add() methods, adding components one by one. But then you'd have to implement add() for the Todo class.
@meenakshighamande1121
@meenakshighamande1121 3 жыл бұрын
following
@hagergamal2856
@hagergamal2856 2 жыл бұрын
Great video 👍 Can u talk more about mutable
Difference Between Composite and Decorator Pattern - Design Patterns (ep 15)
31:41
Factory Method Pattern - Design Patterns (ep 4)
27:21
Christopher Okhravi
Рет қаралды 542 М.
Schoolboy Runaway в реальной жизни🤣@onLI_gAmeS
00:31
МишАня
Рет қаралды 3,2 МЛН
Doing This Instead Of Studying.. 😳
00:12
Jojo Sim
Рет қаралды 36 МЛН
Pool Bed Prank By My Grandpa 😂 #funny
00:47
SKITS
Рет қаралды 19 МЛН
Why Use Design Patterns When Python Has Functions?
23:23
ArjanCodes
Рет қаралды 103 М.
Command Pattern - Design Patterns (ep 7)
39:12
Christopher Okhravi
Рет қаралды 268 М.
Abstract Factory Pattern - Design Patterns (ep 5)
25:54
Christopher Okhravi
Рет қаралды 311 М.
GORUCO 2009 - SOLID Object-Oriented Design by Sandi Metz
47:12
Iterator Pattern - Design Patterns (ep 16)
1:37:25
Christopher Okhravi
Рет қаралды 94 М.
Strategy Pattern - Design Patterns (ep 1)
35:11
Christopher Okhravi
Рет қаралды 1,4 МЛН
10 Design Patterns Explained in 10 Minutes
11:04
Fireship
Рет қаралды 2,2 МЛН
The Simplest Design Pattern: Facade
8:43
Bran van der Meer
Рет қаралды 3,4 М.
Simple Code, High Performance
2:50:14
Molly Rocket
Рет қаралды 245 М.