Chris, I just want to say that your your passion for the subject and kindness in sharing your knowledge has touched me deeply. You bring so much LOVE to the subject. Not only is that inspiring to see, it also makes me feel AT HOME when watching your videos. Your thorough pedagogy and light humor make me feel like I have "big programming brother" looking out for me. I used to regard design patterns as these "scary super-hard things" and after going through most of your videos that view has begun to shift to "fascinating and natural" :). So, a big thank you from the bottom of my heart. Please continue sharing your knowledge, I truly believe that it changes the world for the better. At least, it has made my life a bit better:) Hugs from Israel!!
Please make these videos as extensive as necessary, no need to hurry. The way you do them, makes it really clear what is going on, which is super helpful.
2 hours before the sleep, watch a movie or this episode ? OK I chose the second option and I don't regret it, super super good, I hope one day you finish this series
You are a legend my friend, would love to see you explain WHEN you needed to use the pattern you are explaining in a real life scenario you faced yourself. Makes it easier for us new to Design Pattern to decide on which pattern we need to use
Mr. Abdul Bari's Algorithms and DS + Mr. Povilas Korop about Laravel framework + your videos about Design Patterns are the best what I have seen in programming world
You are awesome. Thank you so much for spending your time in this series :) I don't think you should make these videos shorter. There is so much to learn here.
dude i just discovered him and his passion towards this subject is so good we need more teachers like this i wont miss a single day n my class if he is my teacher. Can someone tell me why did he stop posting???
Your efforts in creating Detailed Videos appreciated.......Some of your videos were better than what i have seen elsewhere like pluralsight,etc....Keep it up! Thanks Once Again!
50:55 That is exactly what I was thinking. Personally I would say it is perfectly fine to have a method which is both a command and query if: A) The method clearly indicates that it changes the object's state B) The return value can also be retrieved by some other method which does not change the object's state ("peek" in the case of a stack) particularly if it is significantly more efficient to both modify the object and return the value in the same call.
Initally, i thought 1 hr 40Min video is too much for iterator pattern. Once i started watching it really made sense. While watching this i felt it is very complicated but by the time i reached the end it became clear and simple.
I like it because that is more or less the solution that we found at work. The language that we work with doesn't support for each instruction so, that is the only way to have this benefits. It's a bit long video but because it's explained over and over the same thing in with different points of view it's easy to understand. Please keep doing. :)
I really like your videos. I have come to such level of understanding that I can guess what your next step will be in explaining the structures and I believe that in that way I am really learning. Eventually, they also helped me a lot in interviews. Thanks a lot! This channel has become my reference channel for Design patterns other than the books. :)
Too long video? Too short? What do you think? Are the side-tracks (e.g. command query separation, single responsibility principle, mutation, etc.) useful or distracting?
First, thank you so much Christopher for your time and effort ! Coming to your question about the video length, I believe that people who are following your channel for a reasonable time, me included, know you well enough to trust you and to get used to your (unique) pedagogic style. But people looking for a quick answer may feel overwhelmed by the quantity of (valuable) explanations. In my humble opinion, your explanations are deep enough to get the whole picture of each DP (I've been struggling with the Command pattern for years untill I watched your (deep but simple) explanation weeks ago), and the fact of talking about related principles (SRP, CQS...) let us feel and touch the concreteness of some abstract/theoritical concepts and how they are connected and share the same purpose. Thanks sir !
Ah! Both was an excellent idea! How come I never thought about that before! Omg. Will try my best to approach it that way in the remaining videos (already recorded the coming 2 videos by after that). Thanks a lot and thanks for watching! 😀😀
Generators in JavaScript seems to implement the iterator pattern by letting you start and stop the function and allow for infinite iterations. One example would be creating infinite amount of ids just by calling next and getting the new, current value. I like thinking about the inventory from Zelda: Ocarina of time, how we have an inventory section, map section, and song section. We can use a section iterator that has previous() and next() methods to get to the previous or next section but also we have the section's items we can iterate through such as the inventory. The inventory items iterator can call left(), right(), up(), and down(). Almost close to finishing up this playlist and feeling accomplished from it. Thanks for this video and hope you make more in the future when you aren't busy with life stuff!
Thank you so much for these videos! I'm reading the Head First Design Patterns book now, and I feel like it helps me understand the concepts better by seeing your explanations in addition to reading the book. Random note: when you switched hasNext() to isDone(), I think we should have changed the inequality to this.index >= 2. (Not sure; I make mistakes every day.)
I think it's a good example - and I enjoyed the length... It covers pretty much everything. I have both books you mention, and a couple of others, and the best way to use the books you mention is dive into head-first design patterns, see where that takes you, then look up the Gof book, and see how they compliment each other. And then probably what I like to do is watch this kind of site to see how they are explained....cover all the bases, dude.
Great video, it was long but it was needed for me to understand more clearly and I do now. Thank you! I have subscribed and look forward to more of your videos sincerely a beginner programmer :)
i love ur entries man!! content and energy in ur videos is fabulous. I got an interview in 2 hrs but i am stuck on your videos and not revising other stuff. Pretty sure does not matter what question interviewer will ask, I am gonna talk about your channel and opinions.
Excelent series Chris! Just a dumb comment regarding the IsDone() method. I think we should change the < 2 condition to something like > 1 (difference from HasNext()) to follow the logic of the naming. Cheers!
Man, your videos are awesome, all of them I have watched them and I’m very happy with your content, the problem is that you just stop, there are hundreds of people like me trying to reach you to tell you, please do more, even if they are paid videos I will give you my money, you can sell them Udemy, patron or UA-cam itself. I will be very grateful, but not only me, a lot of people. Thanks!
Hello! Thanks so much for videos. I am new to programming and so all the tangential notes are very usefull for me so i stark to make sense of whats going in in the world of programming
I find a way to learn design pattern quickly and effectively: memorize the defination first, just read and remember it. And below is my memory: The Iterator pattern provide a way to assess the elements of an aggregate object without exposing its representation.It defines a common interface to iterate different types of collections.To implement this pattern, typically you need two components, an iterator interface and a ConcreteIterator class, the interface defines method like next(), hasNext(), currentItem, and the class implement these to iterate over the elements based on specific type of collection
Awesome explanation. I couldn't stop listening once I started. Just one query. Is the function implementation public bool IsDone() { return this.index < 2 } right? I think it should be - public bool IsDone() { return this.index >= 2 }. (as once index reaches 2 means we have iterated through both inventories and so we are done).
You are right! first he used a hasNext() function but once he changed the name to isDone he forgot to change the logic. But anyway the idea of iterator pattern is clear.
At 01:23:38 the implementation of the "current" method, in this case we only have to options, so it is easy to put them in a switch case, what if we have a flexible number of items, like the items in the back-bag inventory, how can we implement it ? Also I suggest that the default value of the index = -1, I don't know why but I saw it somewhere in c++ I think :D
Thanks again for a great video! You mentioned a playlist at 28:00 about design patterns in different game elements. I can't seem to find the videos you mentioned, any chance you have the link close by? Keep up the good work! Looking forward to possible live streams of you coding :)
Ah! Thanks for the reminder! Here's the video I was talking about: ua-cam.com/video/nuS591k75NY/v-deo.html Example from Assassin's Creed 🙂🙂 And here's the full playlist (actually, channel): ua-cam.com/channels/4O5IoqW_cfRgV_ZNrM6eEA.html Thanks for subscribing on Twitch! 🙂 The format is still super informal but as I get better at streaming I'll start doing some "let's code" style streams that will be saved as videos.
Thanks for the quick response. I've been watching Daniel Shiffman's (super goofy) Coding Train streams on youtube ( ua-cam.com/channels/vjgXvBlbQiydffZU7m1_aw.html ). It's a nice format to see how he thinks through his coding problems and its fun to try and figure it out "together". Great way to learn more! This is quite offtopic, but I was wondering if you could shed some light on the matter. I watched Miško Hevery's Clean Code talks you had linked in a previous video. He was talking about how calling the new keyword inside a class is bad and it's better to give the object through the constructor. I'm guessing this doesn't apply to everything? In cases where I'm using java's built in data structures like Lists, Maps and so on, does it make sense to instantiate these earlier and send them through the constructor to be used or just instantiate them when I have a need to use them?
The Coding Train channel is indeed awesome. Crazy guy 😀 Thanks a lot for the parallel. I'll have a closer look at the format of his live streams. Thanks. 🙂 About the concept of the "new" keyword being "dangerous". The problem, in my understanding, is coupling. So whenever you instantiate something you couple to a concrete class. But if you instead dependency inject, e.g. pass something through the constructor, then you can choose to couple to an interface instead. If the thing that you then at runtime pass happens to be an instance of the concrete class that we talked about first that's all fine and dandy as long as it implements the interface, but now you also have the ability to accept other stuff. Generally I guess I would think that it, as you say, does not apply to basic data structures like lists, maps and so forth. But it might depend so I'm not sure I'm ready to use the world "always" 🙂 Either way, maybe you already found this, but Misko also has a blog and here are some posts on the topic that might be relevant: misko.hevery.com/2008/09/30/to-new-or-not-to-new/ misko.hevery.com/2008/09/10/where-have-all-the-new-operators-gone/ misko.hevery.com/2008/07/08/how-to-think-about-the-new-operator/ I hope this gives some further direction :) Thanks a lot for watching and for the great question 😀
Hi Christopher, thanks for your awesome video. One thing I notice here is that in the isDone() method, it should be (return index > =2), instead of (return index
It is too long video, but the side-tracks were very useful for me. I suggest writing the whole code examples before recording the lesson on your computer and explaining it directly from your computer. thus you will save the writing code time and corrections while explanation and the example code will be more clear. also you could attach it with the video.
Hi Chris, I think(maybe) there is a typo... in the class HandHeldInventoryIterator, the method isDone() should return this.index > 1, not this.index < 2, because of the naming.
@Christopher Regarding the discussion at 52:30 , Why cant the arrows be something like in the observer pattern? An iterable has an iterator (iterable get iterator duing concrete class definition), while a concrete iterator has a iterable (it gets it as dependency injection while initializing / instanciating a concrete iterator, which happens in the getIterator () method of the iterable). Am i wrong? please clarify
This looks very similar to bridge pattern , just that there is "hasA" relationship between the concretion in Iterator pattern whereas , the Bridge pattern has a "hasA" relation between the abstractions. Ofcourse the intent are very different.
Let me start by thanking you for the time you took to realize these series which are really enjoyable to watch. Your videos has helped me a lot to understand the design patterns but also has motivated to dig deeper revisit my knowledge of object oriented programming. I am considering buying the two books you have recommended about design patterns. I have a question regarding the HandHeldInvetoryIterator class : What does the HandHeldInventoryIterator instance does when the HandHeldInventory instance is empty, that is contains no Item instances in the Right and Left ? How can the index of the HandHeldInventoryIterator instance points to the first instance in the case it is empty ? Wouldn't be easy if HandHeldInventory had a Count property for the number of Items contaitned in it ? Then wouldn't it be simple for IsDone in the HandHeldInventoryIterator to first check if Count == 0 and then return this.index < this.inventory.Count ?
Great video, need not to worry about long videos as long as after watching person is able to think from them-self. But I do have one request would it be great if you add some real life example (i.e. system design) which uses these kind a design pattern; in that way person can co-relate with other application.
I really like your videos, but in general (and this one specifically) they are FAR too long for the amount of information you're presenting. IMHO the constant abstract spoken examples are less helpful than one screen cast/ fully written example program.
Personally I love length and the iteration of the idea, some of these concepts are advanced and 10-20 min wouldn't justify them imo, oh btw are you still doing the code walks love them.
These days I eagerly wait for GOT S8 and Your next DP Video... Awesome!!! As I've already requested "FLY Weight".. Please create video on "Repository DP" also.
Can we use iterator design pattern for designing an elevator system to iterate the floors requested, thus keeping it open to have an even complicated lift circuit?
Hi Chris, honestly speaking Super 👌 duper thanks to you , you are putting your more than 100% and providing us with great in depth content. I would want to connect with you on LinkedIn. You are truly amazing 👏 Personally to me I like the way you explain the things going into depth of the concept that makes us capable enough to understand how things would have been implemented internally such as this one. (Iterator Pattern) Hats off to you Chris.
Awesome videos. Wished I had found these videos sooner. Even though the video is long, it's definitely worth watching. Please continue to do video like these as they are really helpful, and thank you for breaking the code down using the whiteboard instead of IDE. Do you have videos on Java head first from O'Reilly? Thanks for the referencing the books as I purchased head first design patterns a few months back.
Thank you for the kind words. I’m glad to hear that the content is appreciated. And thanks for the detailed feedback. I’m not planning a series specifically on Java but there will be lots of more stuff coming on everything from OOP to FP and between 😀 Also, glad to hear that the videos complement the book 😀 Thanks!
If possible, you can get more hits if videos are separated short and long like Bridge pattern. :-) short video acts like a reference the essence. the long video covers the concepts around it and comparisons.
O que eu entendi: você tem uma lista e quer um elemento desta lista, ao invés de pedir a lista toda, você pede a um iterator para percorrer a lista e entregar o elemento desejado, ou seja, não precisa carregar toda lista para obter um elemento.
Do the GetIterator method breaks the Single Responsibility Principle of the Iterable concrete object? For example: the HandHeldInventory has two reasons to change. The first is a change in a requirement for the Inventory logic, may be now you can have a third weapon in your mouth (like Zoro from One Piece). The second is that, being GetIterator a factory method, it can contain the logics to instantiate different ConcreteIterators, may be in some cases you want to get the right hand item first, in other cases you want to get it last. It seems to me that the Iterable has two responsibilities, or may be i'm just confused :P
Thank you very much for your kind words! :) :) :) And sorry about forgetting the link! ua-cam.com/channels/4O5IoqW_cfRgV_ZNrM6eEA.html It's now also in the description. Thanks for the reminder!
People with short attention spans can pause the video when they feel they are not paying attention any more and do something else for a few minutes. That's actually a good skill to train.
I don't think that a design pattern, that on the book is like 15-20 pages, can be compressed in a 20 min video. I mean, someone are really self explanatory (in fact there are some 30 min videos) BUT not all of them. I would suggest, instead, to do more jokes like the one at 20:35 P.S. I'm one of those who really struggle to pay attention for too long :)
Awesome video and playlist, thanks a lot Chris. I might be mistaken, but after refactoring hasNext to isDone the method should return true if the index is >= 2 By the way, hope you have plans to create new videos to cover more design patterns. :)
I have a doubt, what do you mean by " i am not going to give you the whole list" in 14:06. I am sort of confused here who is giving to whom in the context of programming. Please can you explain or any one who knows here ! And thanks for these wonderful design pattern tutorials. Cheers !!
Thanks for the great question and thanks for watching :) What I mean is that with iterator pattern we are not simply exposing the internal collection (e.g. a list), i.e. we are not passing it out "by reference" since that would compromise the collection in the sense that other pieces of the code could change the contents of the list. Instead we simply supply (actually: "yield") one item at a time. And if you happen to want all of the items then we will have in effect duplicated the list by passing every single item in the list one by one. Not sure if I'm actually helping or if I'm just making it more confusing. Does it make sense? Ask again if not.
The conclusion in the last minute is wrong. Although you can while()-loop over any of the iterators, they both contain completely different items (e.g. the handheld- and the house-inventory-iterators). The items returned from the iterators are not interchangeable. A handheld or a house-item have completely different and specific properties and methods. Won't you still end up having to switch or conditional for the returned type and act accordingly?
could we say that getIterator is a factory method? andm aybe in a concrete iterator could we implement a composite pattern for traversing smth like a tree?
I'm 1/3 rd thru and yes it's too long. BTW you mentioned that an advantage is being able to iterate part way thru, stop, then carry on to the next iteration. The .NET Igetenumerator doesn't allow this, the next 'for each' reinitialises the pointer/index/something; just saying.
I am a big fan of the design pattern series and have learned quite a lot from this web series . However one must add this one you missed the mark .Too Long and too many times we are circling around discussion rather than make a point . It would help if content was shorter and more to the point .
Bit lengthy,,,,I would suggest a short tutorial 20min with core concepts and then rest of video with example discussion....???? However ever, So far , best series i have watched.....Thanks christopher....You gave something to world ,,,Good karma ...
Chris, I just want to say that your your passion for the subject and kindness in sharing your knowledge has touched me deeply. You bring so much LOVE to the subject. Not only is that inspiring to see, it also makes me feel AT HOME when watching your videos. Your thorough pedagogy and light humor make me feel like I have "big programming brother" looking out for me. I used to regard design patterns as these "scary super-hard things" and after going through most of your videos that view has begun to shift to "fascinating and natural" :). So, a big thank you from the bottom of my heart. Please continue sharing your knowledge, I truly believe that it changes the world for the better. At least, it has made my life a bit better:)
Hugs from Israel!!
+1 for that :)
What is Israel?
the comment was wholesome until i saw ISRAEL
Please make these videos as extensive as necessary, no need to hurry. The way you do them, makes it really clear what is going on, which is super helpful.
Thank you for the feedback. This information is very appreciated. ⭐️⭐️
I can see what you mean. Thanks for watching 🙂
Everyone is commenting that his videos are too long, but I love how many examples he gives.
2 hours before the sleep, watch a movie or this episode ? OK I chose the second option and I don't regret it, super super good, I hope one day you finish this series
You are a legend my friend, would love to see you explain WHEN you needed to use the pattern you are explaining in a real life scenario you faced yourself. Makes it easier for us new to Design Pattern to decide on which pattern we need to use
Mr. Abdul Bari's Algorithms and DS + Mr. Povilas Korop about Laravel framework + your videos about Design Patterns are the best what I have seen in programming world
You are awesome. Thank you so much for spending your time in this series :)
I don't think you should make these videos shorter. There is so much to learn here.
Thank you very much for the encouragement and the feedback! Super valuable. And thanks for sticking with the channel 😄
Your passion rubs off, I will say that much. Keep it up.
dude i just discovered him and his passion towards this subject is so good we need more teachers like this i wont miss a single day n my class if he is my teacher. Can someone tell me why did he stop posting???
Some technical difficulties earlier. Ping me if you can't see the video!
Definitely not to be viewed in one sitting at lunchtime :)
I do see that you have provided direct links to sections which is great.
Thank you
Your videos are incredible. Your presentation is perfect. Please continue your way, because I like to binge watch your videos. Thanks a billion
Putting the important sections of the video in the description is an excellent idea, thanks a lot !
Your efforts in creating Detailed Videos appreciated.......Some of your videos were better than what i have seen elsewhere like pluralsight,etc....Keep it up! Thanks Once Again!
50:55
That is exactly what I was thinking. Personally I would say it is perfectly fine to have a method which is both a command and query if:
A) The method clearly indicates that it changes the object's state
B) The return value can also be retrieved by some other method which does not change the object's state ("peek" in the case of a stack)
particularly if it is significantly more efficient to both modify the object and return the value in the same call.
Not only do I enjoy watching your videos, I actually learn from them.
Initally, i thought 1 hr 40Min video is too much for iterator pattern. Once i started watching it really made sense.
While watching this i felt it is very complicated but by the time i reached the end it became clear and simple.
I’m very glad to hear that! And I apologize for the length of the video 😊😊
I like it because that is more or less the solution that we found at work. The language that we work with doesn't support for each instruction so, that is the only way to have this benefits.
It's a bit long video but because it's explained over and over the same thing in with different points of view it's easy to understand.
Please keep doing. :)
I really like your videos. I have come to such level of understanding that I can guess what your next step will be in explaining the structures and I believe that in that way I am really learning. Eventually, they also helped me a lot in interviews. Thanks a lot! This channel has become my reference channel for Design patterns other than the books. :)
These vidoes are fire. Rewatching again as a refresher, forgot how good they are.
Too long video? Too short? What do you think? Are the side-tracks (e.g. command query separation, single responsibility principle, mutation, etc.) useful or distracting?
I like how long it is. Really gives all the ideas a lot of time to peculate when I listen.
All videos are really good... If I can GOT All sessions why cannot this video ... hahaha
Why not both? You can concentrate on important bits in the beginning and then delve deeper.
First, thank you so much Christopher for your time and effort !
Coming to your question about the video length, I believe that people who are following your channel for a reasonable time, me included, know you well enough to trust you and to get used to your (unique) pedagogic style.
But people looking for a quick answer may feel overwhelmed by the quantity of (valuable) explanations.
In my humble opinion, your explanations are deep enough to get the whole picture of each DP (I've been struggling with the Command pattern for years untill I watched your (deep but simple) explanation weeks ago), and the fact of talking about related principles (SRP, CQS...) let us feel and touch the concreteness of some abstract/theoritical concepts and how they are connected and share the same purpose.
Thanks sir !
Ah! Both was an excellent idea! How come I never thought about that before! Omg. Will try my best to approach it that way in the remaining videos (already recorded the coming 2 videos by after that). Thanks a lot and thanks for watching! 😀😀
Great videos! Thank you for describing subjects so detailed. It simply leaves you with no chance to not understand the patterns
Generators in JavaScript seems to implement the iterator pattern by letting you start and stop the function and allow for infinite iterations. One example would be creating infinite amount of ids just by calling next and getting the new, current value.
I like thinking about the inventory from Zelda: Ocarina of time, how we have an inventory section, map section, and song section. We can use a section iterator that has previous() and next() methods to get to the previous or next section but also we have the section's items we can iterate through such as the inventory. The inventory items iterator can call left(), right(), up(), and down(). Almost close to finishing up this playlist and feeling accomplished from it. Thanks for this video and hope you make more in the future when you aren't busy with life stuff!
Thank you so much for these videos! I'm reading the Head First Design Patterns book now, and I feel like it helps me understand the concepts better by seeing your explanations in addition to reading the book.
Random note: when you switched hasNext() to isDone(), I think we should have changed the inequality to this.index >= 2. (Not sure; I make mistakes every day.)
I think it's a good example - and I enjoyed the length... It covers pretty much everything. I have both books you mention, and a couple of others, and the best way to use the books you mention is dive into head-first design patterns, see where that takes you, then look up the Gof book, and see how they compliment each other. And then probably what I like to do is watch this kind of site to see how they are explained....cover all the bases, dude.
Great video, it was long but it was needed for me to understand more clearly and I do now. Thank you! I have subscribed and look forward to more of your videos
sincerely a beginner programmer :)
Hi Chris , The way you put and explain the pattern with a real time example in the end got the crux of the pattern. thanks
i love ur entries man!! content and energy in ur videos is fabulous. I got an interview in 2 hrs but i am stuck on your videos and not revising other stuff. Pretty sure does not matter what question interviewer will ask, I am gonna talk about your channel and opinions.
1:20:42 Next() comes from the idea that is the method that returns the Item. So you should have another method instead of Current() like Remove()!
Best video man, new brazilian fan here :)
You really got excited explaning everything, surely I'll watch these series more than once.
Incredible series. I wish I’ve found it much earlier.
same!! found it one week before my exams rip
bro u found it 2y later , i found that 7y later :)
Excelent series Chris!
Just a dumb comment regarding the IsDone() method. I think we should change the < 2 condition to something like > 1 (difference from HasNext()) to follow the logic of the naming.
Cheers!
Shared it with my whole class btw (we have to do presentations about design patterns)
Side note, excellent work on your quick refactor at the 1:10:00 mark. We gotta be consistent. :)
Man, your videos are awesome, all of them I have watched them and I’m very happy with your content, the problem is that you just stop, there are hundreds of people like me trying to reach you to tell you, please do more, even if they are paid videos I will give you my money, you can sell them Udemy, patron or UA-cam itself. I will be very grateful, but not only me, a lot of people.
Thanks!
Hello! Thanks so much for videos. I am new to programming and so all the tangential notes are very usefull for me so i stark to make sense of whats going in in the world of programming
Thank you Christopher. Very useful.
Thanks Chris ! this is brilliant!. I've been following all these videos, and it was so easy to learn!
I'm here in 2021 and Daaaaaaamn are your videos awesome, thanks so much man!
I find a way to learn design pattern quickly and effectively: memorize the defination first, just read and remember it. And below is my memory: The Iterator pattern provide a way to assess the elements of an aggregate object without exposing its representation.It defines a common interface to iterate different types of collections.To implement this pattern, typically you need two components, an iterator interface and a ConcreteIterator class, the interface defines method like next(), hasNext(), currentItem, and the class implement these to iterate over the elements based on specific type of collection
and I find the more you learn, you better and faster learn, so go ahead, just do it
Amazing! You just earned another subscriber.
15:56 Great, now i have a image of a magician throwing apples in me for the rest of my life
I Like Your Teaching Technique. Thank You for Your Dedication.
Helpful! Helped me to understand this pattern and clear things up.
Thank you so much for sharing your time and knowledge.
The timestamps were a life saver
Thanks for letting me know 😊😊 Much appreciated 😊 But I assume you mean a “time saver” rather than a “life saver” 😊🤪
@@ChristopherOkhravi Oh yeah! 😅😅
Awesome explanation. I couldn't stop listening once I started.
Just one query.
Is the function implementation
public bool IsDone() { return this.index < 2 } right?
I think it should be -
public bool IsDone() { return this.index >= 2 }. (as once index reaches 2 means we have iterated through both inventories and so we are done).
I think so too (regarding your IsDone correction).
You are right! first he used a hasNext() function but once he changed the name to isDone he forgot to change the logic. But anyway the idea of iterator pattern is clear.
You forgot to change < with >= when changed method name to isDone
Christopher thank you super super super much for this video!
At 01:23:38 the implementation of the "current" method, in this case we only have to options, so it is easy to put them in a switch case, what if we have a flexible number of items, like the items in the back-bag inventory, how can we implement it ?
Also I suggest that the default value of the index = -1, I don't know why but I saw it somewhere in c++ I think :D
Thanks again for a great video!
You mentioned a playlist at 28:00 about design patterns in different game elements. I can't seem to find the videos you mentioned, any chance you have the link close by?
Keep up the good work! Looking forward to possible live streams of you coding :)
Ah! Thanks for the reminder! Here's the video I was talking about:
ua-cam.com/video/nuS591k75NY/v-deo.html
Example from Assassin's Creed 🙂🙂
And here's the full playlist (actually, channel):
ua-cam.com/channels/4O5IoqW_cfRgV_ZNrM6eEA.html
Thanks for subscribing on Twitch! 🙂 The format is still super informal but as I get better at streaming I'll start doing some "let's code" style streams that will be saved as videos.
Thanks for the quick response.
I've been watching Daniel Shiffman's (super goofy) Coding Train streams on youtube ( ua-cam.com/channels/vjgXvBlbQiydffZU7m1_aw.html ). It's a nice format to see how he thinks through his coding problems and its fun to try and figure it out "together". Great way to learn more!
This is quite offtopic, but I was wondering if you could shed some light on the matter. I watched Miško Hevery's Clean Code talks you had linked in a previous video. He was talking about how calling the new keyword inside a class is bad and it's better to give the object through the constructor. I'm guessing this doesn't apply to everything? In cases where I'm using java's built in data structures like Lists, Maps and so on, does it make sense to instantiate these earlier and send them through the constructor to be used or just instantiate them when I have a need to use them?
The Coding Train channel is indeed awesome. Crazy guy 😀 Thanks a lot for the parallel. I'll have a closer look at the format of his live streams. Thanks. 🙂
About the concept of the "new" keyword being "dangerous". The problem, in my understanding, is coupling. So whenever you instantiate something you couple to a concrete class. But if you instead dependency inject, e.g. pass something through the constructor, then you can choose to couple to an interface instead. If the thing that you then at runtime pass happens to be an instance of the concrete class that we talked about first that's all fine and dandy as long as it implements the interface, but now you also have the ability to accept other stuff. Generally I guess I would think that it, as you say, does not apply to basic data structures like lists, maps and so forth. But it might depend so I'm not sure I'm ready to use the world "always" 🙂
Either way, maybe you already found this, but Misko also has a blog and here are some posts on the topic that might be relevant:
misko.hevery.com/2008/09/30/to-new-or-not-to-new/
misko.hevery.com/2008/09/10/where-have-all-the-new-operators-gone/
misko.hevery.com/2008/07/08/how-to-think-about-the-new-operator/
I hope this gives some further direction :)
Thanks a lot for watching and for the great question 😀
Hi Christopher, thanks for your awesome video. One thing I notice here is that in the isDone() method, it should be (return index > =2), instead of (return index
You are right
I was about to write the same comment
It is too long video, but the side-tracks were very useful for me.
I suggest writing the whole code examples before recording the lesson on your computer and explaining it directly from your computer.
thus you will save the writing code time and corrections while explanation and the example code will be more clear. also you could attach it with the video.
The example explains everything!
All of your lectures were amazing. I love the way you explain. I learned a lot. but this lecture little bit,,,,,,,,, may be tough :)
I think isDone should be {index >=2}
Hi Chris, I think(maybe) there is a typo... in the class HandHeldInventoryIterator, the method isDone() should return this.index > 1, not this.index < 2, because of the naming.
@Christopher Regarding the discussion at 52:30 , Why cant the arrows be something like in the observer pattern? An iterable has an iterator (iterable get iterator duing concrete class definition), while a concrete iterator has a iterable (it gets it as dependency injection while initializing / instanciating a concrete iterator, which happens in the getIterator () method of the iterable). Am i wrong? please clarify
wow!!!!you are amazing bro. super useful content , super presentation. thanks a lot .
UML starts @35:00
thank you for your passionate explanation! I snapped some part of the video, cuz it was long time, but it was very understandable to me! bbb
This looks very similar to bridge pattern , just that there is "hasA" relationship between the concretion in Iterator pattern whereas , the Bridge pattern has a "hasA" relation between the abstractions. Ofcourse the intent are very different.
Let me start by thanking you for the time you took to realize these series which are really enjoyable to watch. Your videos has helped me a lot to understand the design patterns but also has motivated to dig deeper revisit my knowledge of object oriented programming. I am considering buying the two books you have recommended about design patterns.
I have a question regarding the HandHeldInvetoryIterator class :
What does the HandHeldInventoryIterator instance does when the HandHeldInventory instance is empty, that is contains no Item instances in the Right and Left ?
How can the index of the HandHeldInventoryIterator instance points to the first instance in the case it is empty ?
Wouldn't be easy if HandHeldInventory had a Count property for the number of Items contaitned in it ?
Then wouldn't it be simple for IsDone in the HandHeldInventoryIterator to first check if Count == 0 and then return this.index < this.inventory.Count ?
Great video, need not to worry about long videos as long as after watching person is able to think from them-self. But I do have one request would it be great if you add some real life example (i.e. system design) which uses these kind a design pattern; in that way person can co-relate with other application.
Great videos, keep up the exelent work. They are really easy to follow! Just as many on the comments I'll have to say it's a bit lengthy.
Thank you very much for the encouragement! 🙂 And also, thanks for the feedback on video length. Much appreciated ⭐️⭐️
I really like your videos, but in general (and this one specifically) they are FAR too long for the amount of information you're presenting. IMHO the constant abstract spoken examples are less helpful than one screen cast/ fully written example program.
I agree
dude, fantastic explanation!! thanks for sharing
hi chris, can you please cover left over design patterns mentioned in head first design patterns book
I would love to see a video on how you generalize the iterator pattern :)
Personally I love length and the iteration of the idea, some of these concepts are advanced and 10-20 min wouldn't justify them imo, oh btw are you still doing the code walks love them.
Damn, i needed this video a week ago ;-; Definitely still going to watch though thank you so much
Sorry to hear 😔 Hopefully whatever you had to do went well regardless 🙂 Do ask if you have any questions. Thank you for watching and for commenting! 😀
Hi Christopher, thanks for this video. I only have one questions: In minute 20:30 what are you dinking? ;-)
These days I eagerly wait for GOT S8 and Your next DP Video... Awesome!!!
As I've already requested "FLY Weight".. Please create video on "Repository DP" also.
Blooming awesome! :-)
Can we use iterator design pattern for designing an elevator system to iterate the floors requested, thus keeping it open to have an even complicated lift circuit?
Exactly! Videos are sooo long, and i have to set playback speed x2 :)
Same here. It cuts the time in half
Learning takes time, instead of 5 episodes of Friends on netflix learn about the iterator pattern.
Best Explanation Thanks you...
Hi Chris, honestly speaking Super 👌 duper thanks to you , you are putting your more than 100% and providing us with great in depth content.
I would want to connect with you on LinkedIn. You are truly amazing 👏
Personally to me I like the way you explain the things going into depth of the concept that makes us capable enough to understand how things would have been implemented internally such as this one. (Iterator Pattern)
Hats off to you Chris.
Awesome videos. Wished I had found these videos sooner. Even though the video is long, it's definitely worth watching. Please continue to do video like these as they are really helpful, and thank you for breaking the code down using the whiteboard instead of IDE. Do you have videos on Java head first from O'Reilly? Thanks for the referencing the books as I purchased head first design patterns a few months back.
Thank you for the kind words. I’m glad to hear that the content is appreciated. And thanks for the detailed feedback. I’m not planning a series specifically on Java but there will be lots of more stuff coming on everything from OOP to FP and between 😀 Also, glad to hear that the videos complement the book 😀 Thanks!
If possible, you can get more hits if videos are separated short and long like Bridge pattern. :-) short video acts like a reference the essence. the long video covers the concepts around it and comparisons.
Great Lesson!
i love your energy
O que eu entendi: você tem uma lista e quer um elemento desta lista, ao invés de pedir a lista toda, você pede a um iterator para percorrer a lista e entregar o elemento desejado, ou seja, não precisa carregar toda lista para obter um elemento.
Could you point to the part where you talk about a composite iterator? Thanks.
Do the GetIterator method breaks the Single Responsibility Principle of the Iterable concrete object? For example: the HandHeldInventory has two reasons to change. The first is a change in a requirement for the Inventory logic, may be now you can have a third weapon in your mouth (like Zoro from One Piece). The second is that, being GetIterator a factory method, it can contain the logics to instantiate different ConcreteIterators, may be in some cases you want to get the right hand item first, in other cases you want to get it last. It seems to me that the Iterable has two responsibilities, or may be i'm just confused :P
Amazing. Thank You.
I wish I had teachers like you in my graduation...awesome!
Please post the link which you talks about DP in games. Thanks
Thank you very much for your kind words! :) :) :) And sorry about forgetting the link!
ua-cam.com/channels/4O5IoqW_cfRgV_ZNrM6eEA.html
It's now also in the description. Thanks for the reminder!
As informative as it is, it's too long, would be nice to compress these videos to 10-20 minutes, most people don't have that much attention span.
Thanks for the feedback. Makes sense. I guess I need to learn to control my urge to share interesting details :D :D Thanks for watching! :)
People with short attention spans can pause the video when they feel they are not paying attention any more and do something else for a few minutes. That's actually a good skill to train.
I don't think that a design pattern, that on the book is like 15-20 pages, can be compressed in a 20 min video. I mean, someone are really self explanatory (in fact there are some 30 min videos) BUT not all of them.
I would suggest, instead, to do more jokes like the one at 20:35
P.S. I'm one of those who really struggle to pay attention for too long :)
I think Christopher takes his time to explain cool details and examples. I think his videos are totally worth the time investment :)
guess programming in general is about some good amount of attention span
In the inventory example, how does left/right come in the play in this example? why not just use a collection?
Chris this is good,just wanted to know if the values are only for read only purpose(Meaning collection is encapsulated?)
Awesome video and playlist, thanks a lot Chris.
I might be mistaken, but after refactoring hasNext to isDone the method should return true if the index is >= 2
By the way, hope you have plans to create new videos to cover more design patterns. :)
I have a doubt, what do you mean by " i am not going to give you the whole list" in 14:06. I am sort of confused here who is giving to whom in the context of programming. Please can you explain or any one who knows here !
And thanks for these wonderful design pattern tutorials. Cheers !!
Thanks for the great question and thanks for watching :) What I mean is that with iterator pattern we are not simply exposing the internal collection (e.g. a list), i.e. we are not passing it out "by reference" since that would compromise the collection in the sense that other pieces of the code could change the contents of the list. Instead we simply supply (actually: "yield") one item at a time. And if you happen to want all of the items then we will have in effect duplicated the list by passing every single item in the list one by one. Not sure if I'm actually helping or if I'm just making it more confusing. Does it make sense? Ask again if not.
Christopher Okhravi Thanks for replying, it makes sense now.
The conclusion in the last minute is wrong. Although you can while()-loop over any of the iterators, they both contain completely different items (e.g. the handheld- and the house-inventory-iterators). The items returned from the iterators are not interchangeable. A handheld or a house-item have completely different and specific properties and methods. Won't you still end up having to switch or conditional for the returned type and act accordingly?
Amazing video! Without u my school presentation would be fucked hahaha
could we say that getIterator is a factory method? andm aybe in a concrete iterator could we implement a composite pattern for traversing smth like a tree?
I'm 1/3 rd thru and yes it's too long.
BTW you mentioned that an advantage is being able to iterate part way thru, stop, then carry on to the next iteration. The .NET Igetenumerator doesn't allow this, the next 'for each' reinitialises the pointer/index/something; just saying.
I am a big fan of the design pattern series and have learned quite a lot from this web series .
However one must add this one you missed the mark .Too Long and too many times we are circling around discussion rather than make a point . It would help if content was shorter and more to the point .
I'II cancel one the movies I want to watch this week to allow myself some time to watch this video. Haha
Haha :) Sorry about that! But thank you very much for the dedication! 🎉👍🔥🎊
Bit lengthy,,,,I would suggest a short tutorial 20min with core concepts and then rest of video with example discussion....???? However ever, So far , best series i have watched.....Thanks christopher....You gave something to world ,,,Good karma ...
Thank you!