I'm happy they have been able to help you :) I decided a long time ago that I wanted to make long videos, but I also wanted them to be interesting and keep the viewers attention. I'm starting to really like the final results as of late. It has been very fulfilling to work at improving my teaching style. Thanks for giving the videos a look!
I read this pattern in Gang of Four today, was trying to figure out what the main method would end up looking like, very glad I found this video. None of my classes for my B.S. CompSci covered this stuff and I'm finding it very important for my job now.
That is quite bizarre. Every B.S. in C.S. should cover at least 15 of the 23 patterns like in my degree. We had the GOF book and the companion book Design Patterns Explained, with an additional syllabus or 3.
Thank you :) I'm working from 6 different books to make this tutorial. I'll cover everything in the GOF book, but probably in completely different ways. I'm glad you are enjoying the tutorial
I always first see the running time of ur tutorials before playing. Then I feel like "ohh... so after 13 minutes the "future-me" would have learnt decorator pattern! Cool!!" Its better than counting the pages on a book n thinking "well... need to read 30 more pages to learn decorator pattern.. ahh forget it. will do later" I recently switched organization for almost double the salary (+ better work). And I owe u a big thanks since your videos were a very big help to me.
You should be hired as a tutor at my college. You just saved me 5 hours to say the least, while providing me with information in the most appropriate way. And this is not the first time...
Derek, You're the best man! The range of topics you have on your channel makes me wonder if there were a team of 4-5 different experts, but its just you, unbelievable. I would love to donate on your site once i have my paycheck. For this video, like others i do have some issues with code or the way it could've been done, but i understand the focus here is understanding the pattern and not the code that is written, Thumbs UP!!, You're awesome!
Thanks, it's a great video explaining the concept very well. One thing that bothers me about commonly used patterns in Java is that they are often un-intuitive and do not reflect the real world as well as they could. I think the Decorator pattern is one of these. For example at 12:00 you have this line: ``` Pizza basicPizza = new TomatoSauce(new Mozzarella(new PlainPizza())); ``` I would intuitively interpret as making Mozzarella from PlainPizza and then making TomatoSauce from Mozzarella. The example below achieves the same results without decomposition and with a lot less boiler plate code, just by changing the mental model to something more intuitive and representative of real life. Are there any advantages to using the Decorator Pattern in situations like this? ``` List toppings = ArrayList(); toppings.add(new Topping("TomatoSauce", 0.35)); toppings.add(new Topping("Mozzarella", 0.5)); ToppedPizza ready = new ToppedPizza(new PlainPizza(), toppings); ``` I'm sure there are cases where Decorators are needed but I often see programmers using certain patterns to fit the solution into the their mental model when they should be reframing their mental model to match real life. What are your thoughts / experiences regarding this?
Late for a reply here, but in this case, yes, you are absolutely right. For such a simple example, a list would have done the job just fine. Its about always using the correct tool for the job and if the code was something more complicated you cannot simply rely on something like a list or array anymore. Say for example you are designing more complicated behaviour, for example enemies in a video game. Now each enemy could be different in some way: some are ranged fighters, others melee and the last group can do both, depending on the situation. You could change behaviour of each of them dynamically just with the corresponding decorator. Also in that situation a simple list just wouldn't quite do and probably fail miserably.
learning for my software engineering course for university right now and have to learn all of these by heart and these videos are very helpfull thank you
Hey Derek, i'm just going to reaffirm what others have been saying on your videos all along: thank you so much for this incredible resource for learning about design patterns. Your videos are of such incredible help while studying, both because of your excellent explanations, as well as the nature of the medium (we can replay a segment we don't understand however many times we want) and the commented code that you provide. I am a big believer of a future for internet with micro-transactions, so i just went and donated you 5 bucks. It is not much, i am a student after all, but the content you provide warrants a gesture from me :)
Chaitanya Bhagwat Showing your appreciation is more then enough for me. I'm very happy to be able to help like others have helped me in the past. Thank you for the compliment :) You're very welcome.
Hey man, i just gotta tell you that I love your videos and I love you. 3rd year of uni, and you still manage to help me through all the questions I have. Last semester you helped me out with Data Structures now you're helping me out with design patterns. Thank you once again, please keep this up!
I keep rewatching these series of design patterns in java. So far it helped me make my apps less violent and less complicated. Also, I love pizza! My thanks for your effort Derek. Kind Regards...
Very Helpful tutorial, my first project in my Object Oriented Programming course just so happens to be creating a pizza ordering system where toppings are added using a decorator design pattern so this video was exactly what I needed! Thanks so much!
Excellent. Thank you so much!!!!! I have read the Gang of Four book, but it is so long that the trees get lost in the forest. Your Decorator is so clear and logical. Bravo!
You're very welcome :) Think of those classes that extend ToppingDecorator as if they are layering on functionality to the Pizza composite field in the ToppingDecorator object. So, first you create the Pizza object and then add additional functionality to getDescription and getCost using the toppings. Here is another tutorial on decorator that may help further newthinktank. com/2013/02/code-refactoring-16/
Hey Derek, correct me if I'm wrong. So the basic difference between Abstract Factory design pattern and Decorator design pattern is: 1. When you can create an object many different "definite" ways, use "Abstract factory design pattern". Also disadvantage is, you have to create a factory for every possible combination. More of a static factory. 2.When you can create an object many different "indefinite" ways, use "Decorator design pattern". Here you can dynamically combine any possible combinations. More of a dynamic factory.
Headfirst design patterns explains things similarly but using drinks instead of pizza. You did a much better job of explaining it than the book did though.
Hey Derek, why don't u just use List instead and just loop through stuff. I think the pizza example, as well as drinks one are not suitable for this pattern, cause they do not add any new behaviour, u can't do new things with pizza. even if you decorated it. Please correct me if I'm wrong.
Thanks a lot for providing the code. Sometimes I don't quite get things through verbal explanations, but seeing you implement it and then thoroughly going through the code afterward really helped it click. Also, I think at the end of your tutorials that involve coding, you should do one final overview of what just happened when you run the program. In this video for example, I think you could've taken us through how the objects were being wrapped.
Thank you, but you don't have to do that. I'm not one of the guys that asks people to like and favorite everything. The fact that you find them useful is enough for me :)
I love this, thank you so much! It really helps to hear this concepts from someone rather that read boring books a thousand times for each pattern. It's really cool that you do this without expecting money or any type of retribution what so ever.
I probably could have come up with a more specific optimized way to present this pattern. The ToppingDecorator could have been more simplified and then the ingredients could have done most anything. In videos I have to find an example that both demonstrates the pattern while keeping everything as simple as possible. Sometimes I get a great example and other times not so much. Sorry about that
When I start thinking about using a design pattern I normally first ask if I can accomplish making the code more readable in some other way. If I can't think of another way I use the pattern. You'll find with experience that more often then not you'll use patterns rarely. The positives in knowing them are that you'll start to find other unique ways of solving problems while writing easier to understand code.
For those who don't know about SOLID principles, I recommend reading up on it. "Clean Architecture" by Robert Martin is a really good resource for this but you can just Wiki it. This design pattern is very powerful in that it directly tries to comply with the S(single responsibility) and O(open/close) of SOLID.
Every video from this course helps me to obtain clear understanding of dedicated pattern. Nice work! One remark about Decorator Pattern. You've forgot to implement decorators for meat stuff and olives to obtain perfect pizza :)
Shouldn't the arrow in mozzarella be pointing the other way around since Mozzarella extends ToppingDecorator? (in the UML) Regardless, kudos on your videos Derek! I'm learning more here than in lecture lol
You can always override the PlainPizza class, add a topping of medium, large, Xtra large, etc. You could have all toppings have the same price and then just override the description. The rule extend what differs between toppings will steer you in the right direction
The pizza example used in this video is very effective in understanding Decorator Pattern. The method of inheritance as described in the video is static and will not allow for changes in the code. Hence, it is important to use design patterns because good code is easily manageable and changeable. Using design patterns will allow the client to easily add new toppings to pizza, change the cost of each topping without having to make major changes in the code. An advantage of using decorator pattern particularly is that it uses the code already written and just extends it for additional functionality. The detailed coding example is very helpful in understanding how the decorator pattern functions. Though thespeaker makes an error while coding where he refers to methods as classes which might confuse new programmers.
You are a most excellent teacher. I usually have problems learning new (especially programming) concepts, but you made it very easy for me to understand. Your explanation is crystal clear. =)
+Derek Banas : Filled diamond represents composition not aggregation ! Also, the diamond is positioned near the parent. Kindly correct me if I am wrong.
yes filled diamond represents composition, however as far as i know the diamond should be on ToppingDecorator because there is defined a Pizza variable in it
Hello Derek, thank you for the videos you post ! I find them to be very helpful. I have some questions about this particular video. 1. Why don’t you put “adding Dough” from the Mozzarella constructor into the PlainPizza constructor? 2. Why do you implement getDescription() and getCost() methods in ToppingDecorator class ? Can you just make them abstract and then implement them in Mozzarella and TomatoSauce class ? Best regards
1. I agree 2. You might want to do some completing additional logic inside the Abstract: like prepending "Ingredients: " to the Description, or applying a discount on the total Price.
Great video! When I think about creating a pizza class with many different kinds of toppings, I might choose the builder pattern instead, so that my code for adding toppings can be linearly written instead of in the form of nested constructors. Are there any advantages of the decorator pattern over the builder pattern here?
You're very welcome :) Yes you could do what you described. It is really my fault because I didn't make an example that required the added flexibility this pattern provides. I tried to come up with a simple example of the pattern and in doing so I didn't get the best example. Sorry about that
man your design pattern tutos are really awesome they are the best !!! Could you please create tutos of webservices such as REST and SOAP ? and why not also cloud computing or advanced php programming again thank you very much for this tutorial !!!
+Oussama bargougui Thank you very much :) I covered web services here ua-cam.com/video/iqNiINZ4Sxg/v-deo.html I plan on covering PHP frameworks after I finish up with JS. You're very welcome
Nice tutorial! Here's a little lemon twist: what if the class that you want to decorate is constructed only from a Builder pattern. The constructors get tricky.
Sadly anyone can sue you for anything and win whether they are right or wrong. It all depends on if they can wait you out with lawyers. I constantly fight against record labels that make false copyright claims on music I am licensed to use. I've received cease and desist letters for articles I wrote about false claims by web gurus. You can either fight them or lawyer up :(
Learn in One Videos for Every Programming Language
Subscribe to Bookmark them: bit.ly/2FWQZTx
C++ : ua-cam.com/video/Rub-JsjMhWY/v-deo.html
Python : ua-cam.com/video/N4mEzFDjqtA/v-deo.html
Java : ua-cam.com/video/n-xAqcBCws4/v-deo.html
PHP : ua-cam.com/video/7TF00hJI78Y/v-deo.html
MySQL : ua-cam.com/video/yPu6qV5byu4/v-deo.html
JavaScript : ua-cam.com/video/fju9ii8YsGs/v-deo.html
C# : ua-cam.com/video/lisiwUZJXqQ/v-deo.html
HTML5 : ua-cam.com/video/kDyJN7qQETA/v-deo.html
CSS3 : ua-cam.com/video/CUxH_rWSI1k/v-deo.html
JQuery : ua-cam.com/video/BWXggB-T1jQ/v-deo.html
TypeScript : ua-cam.com/video/-PR_XqW9JJU/v-deo.html
ECMAScript : ua-cam.com/video/Jakoi0G8lBg/v-deo.html
Swift : ua-cam.com/video/dKaojOZ-az8/v-deo.html
R : ua-cam.com/video/s3FozVfd7q4/v-deo.html
Haskell : ua-cam.com/video/02_H3LjqMr8/v-deo.html
Handlebars : ua-cam.com/video/4HuAnM6b2d8/v-deo.html
Bootstrap : ua-cam.com/video/gqOEoUR5RHg/v-deo.html
Rust : ua-cam.com/video/U1EFgCNLDB8/v-deo.html
Matlab : ua-cam.com/video/NSSTkkKRabI/v-deo.html
Arduino : ua-cam.com/video/QO_Jlz1qpDw/v-deo.html
Crystal : ua-cam.com/video/DxFP-Wjqtsc/v-deo.html
Emacs : ua-cam.com/video/Iagbv974GlQ/v-deo.html
Clojure : ua-cam.com/video/ciGyHkDuPAE/v-deo.html
Shell : ua-cam.com/video/hwrnmQumtPw/v-deo.html
Perl : ua-cam.com/video/WEghIXs8F6c/v-deo.html
Perl6 : ua-cam.com/video/l0zPwhgWTgM/v-deo.html
Elixir : ua-cam.com/video/pBNOavRoNL0/v-deo.html
D : ua-cam.com/video/rwZFTnf9bDU/v-deo.html
Fortran : ua-cam.com/video/__2UgFNYgf8/v-deo.html
LaTeX : ua-cam.com/video/VhmkLrOjLsw/v-deo.html
F# : ua-cam.com/video/c7eNDJN758U/v-deo.html
Kotlin : ua-cam.com/video/H_oGi8uuDpA/v-deo.html
Erlang : ua-cam.com/video/IEhwc2q1zG4/v-deo.html
Groovy : ua-cam.com/video/B98jc8hdu9g/v-deo.html
Scala : ua-cam.com/video/DzFt0YkZo8M/v-deo.html
Lua : ua-cam.com/video/iMacxZQMPXs/v-deo.html
Ruby : ua-cam.com/video/Dji9ALCgfpM/v-deo.html
Go : ua-cam.com/video/CF9S4QZuV30/v-deo.html
Objective C : ua-cam.com/video/5esQqZIJ83g/v-deo.html
Prolog : ua-cam.com/video/SykxWpFwMGs/v-deo.html
LISP : ua-cam.com/video/ymSq4wHrqyU/v-deo.html
Express : ua-cam.com/video/xDCKcNBFsuI/v-deo.html
Jade : ua-cam.com/video/l5AXcXAP4r8/v-deo.html
Sass : ua-cam.com/video/wz3kElLbEHE/v-deo.html
10 years later and this video is still one of the easiest to follow and best videos on a design pattern I've seen so far! Thank you!
Thank you for taking the time to tell me you like them :)
Move the "adding dough" to plain pizza class then the video is perfect!
I'm happy they have been able to help you :) I decided a long time ago that I wanted to make long videos, but I also wanted them to be interesting and keep the viewers attention. I'm starting to really like the final results as of late. It has been very fulfilling to work at improving my teaching style. Thanks for giving the videos a look!
You've been a huge help!
I am a Senior Developer, I watched these videos from Derek 6 years ago, and yes I am watching them again :) #lifeOfDeveloper
I'm very happy to hear that I continue to help :)
Bro, trust me, never find such great tutor where I can understand the design pattern so easily. You are the champ dude.
Thank you for the nice compliment :)
I read this pattern in Gang of Four today, was trying to figure out what the main method would end up looking like, very glad I found this video. None of my classes for my B.S. CompSci covered this stuff and I'm finding it very important for my job now.
I'm very happy that I could help :)
That is quite bizarre. Every B.S. in C.S. should cover at least 15 of the 23 patterns like in my degree. We had the GOF book and the companion book Design Patterns Explained, with an additional syllabus or 3.
Congrats dude
haha, MDX london here.2nd year we did Java. We didn't cover these. Just basic code and UML with related things like OOP thinking.
Amazing! I'm from Ukraine, but your tutorial in English is easier than any of I could find in native language! Thanks!
Thank you for the compliment :)
Why don't you answer some questions on your comments?
Thank you :) I'm working from 6 different books to make this tutorial. I'll cover everything in the GOF book, but probably in completely different ways. I'm glad you are enjoying the tutorial
I always first see the running time of ur tutorials before playing.
Then I feel like "ohh... so after 13 minutes the "future-me" would have learnt decorator pattern! Cool!!"
Its better than counting the pages on a book n thinking "well... need to read 30 more pages to learn decorator pattern.. ahh forget it. will do later"
I recently switched organization for almost double the salary (+ better work). And I owe u a big thanks since your videos were a very big help to me.
you're the master; never has anyone or any article or tutorial hit home design patterns to the point in such short and concise manner.
Thank you :) I'm glad you enjoyed the videos.
You should be hired as a tutor at my college. You just saved me 5 hours to say the least, while providing me with information in the most appropriate way. And this is not the first time...
Thank you :) I'm here for free when ever I can be of help
Derek, You're the best man! The range of topics you have on your channel makes me wonder if there were a team of 4-5 different experts, but its just you, unbelievable. I would love to donate on your site once i have my paycheck. For this video, like others i do have some issues with code or the way it could've been done, but i understand the focus here is understanding the pattern and not the code that is written, Thumbs UP!!, You're awesome!
Nikhil Laddha Thank you for the nice compliment :) There is no need to donate. I'm just happy that I can help.
8 Years latter and still useful, thanks for the high quality video!
Thank you very much :)
You have saved my ass. Exam in one week and I was not getting any of this until I discovered your videos. Hero!!!
Thank you :) Best of luck on your exams
Thanks, it's a great video explaining the concept very well. One thing that bothers me about commonly used patterns in Java is that they are often un-intuitive and do not reflect the real world as well as they could. I think the Decorator pattern is one of these. For example at 12:00 you have this line:
```
Pizza basicPizza = new TomatoSauce(new Mozzarella(new PlainPizza()));
```
I would intuitively interpret as making Mozzarella from PlainPizza and then making TomatoSauce from Mozzarella.
The example below achieves the same results without decomposition and with a lot less boiler plate code, just by changing the mental model to something more intuitive and representative of real life. Are there any advantages to using the Decorator Pattern in situations like this?
```
List toppings = ArrayList();
toppings.add(new Topping("TomatoSauce", 0.35));
toppings.add(new Topping("Mozzarella", 0.5));
ToppedPizza ready = new ToppedPizza(new PlainPizza(), toppings);
```
I'm sure there are cases where Decorators are needed but I often see programmers using certain patterns to fit the solution into the
their mental model when they should be reframing their mental model to match real life. What are your thoughts / experiences regarding this?
Late for a reply here, but in this case, yes, you are absolutely right. For such a simple example, a list would have done the job just fine.
Its about always using the correct tool for the job and if the code was something more complicated you cannot simply rely on something like a list or array anymore. Say for example you are designing more complicated behaviour, for example enemies in a video game. Now each enemy could be different in some way: some are ranged fighters, others melee and the last group can do both, depending on the situation. You could change behaviour of each of them dynamically just with the corresponding decorator. Also in that situation a simple list just wouldn't quite do and probably fail miserably.
learning for my software engineering course for university right now and have to learn all of these by heart and these videos are very helpfull thank you
I'm happy they were helpful :)
Hey Derek, i'm just going to reaffirm what others have been saying on your videos all along: thank you so much for this incredible resource for learning about design patterns.
Your videos are of such incredible help while studying, both because of your excellent explanations, as well as the nature of the medium (we can replay a segment we don't understand however many times we want) and the commented code that you provide.
I am a big believer of a future for internet with micro-transactions, so i just went and donated you 5 bucks. It is not much, i am a student after all, but the content you provide warrants a gesture from me :)
Chaitanya Bhagwat Showing your appreciation is more then enough for me. I'm very happy to be able to help like others have helped me in the past. Thank you for the compliment :) You're very welcome.
Hey man, i just gotta tell you that I love your videos and I love you. 3rd year of uni, and you still manage to help me through all the questions I have. Last semester you helped me out with Data Structures now you're helping me out with design patterns. Thank you once again, please keep this up!
That is awesome to know :) I'm happy I have been of help
I keep rewatching these series of design patterns in java. So far it helped me make my apps less violent and less complicated.
Also, I love pizza! My thanks for your effort Derek.
Kind Regards...
I'm very happy to hear they helped :)
Very Helpful tutorial, my first project in my Object Oriented Programming course just so happens to be creating a pizza ordering system where toppings are added using a decorator design pattern so this video was exactly what I needed! Thanks so much!
Happy I could help :)
Thanks Derek for explaining decorator design pattern in such simple way... Hats off... cheers!!!
Hardik Gandhi You're very welcome :) I'm glad I could help.
Why? Why do you have a video about anything I look for? I love you bro.
You're very welcome :) I'm doing my best to cover the more complicated topics in programming. I'm glad people are finding them useful
It's nearly 1 AM and I'm hungry because of you, thanks
That's funny :)
@@derekbanas This very Design Pattern ended up on the test this morning so thanks I guess haha
Thank you :) I like covering niche topics that everyone else avoids
It is very nice to be able to clear up a subject when others haven't helped! Thank you :)
I'm just happy that you find it useful :) Thanks for the kind words. It is just a fun hobby of mine and I expect nothing in return
Excellent. Thank you so much!!!!! I have read the Gang of Four book, but it is so long that the trees get lost in the forest. Your Decorator is so clear and logical. Bravo!
You're very welcome :) Think of those classes that extend ToppingDecorator as if they are layering on functionality to the Pizza composite field in the ToppingDecorator object. So, first you create the Pizza object and then add additional functionality to getDescription and getCost using the toppings. Here is another tutorial on decorator that may help further newthinktank. com/2013/02/code-refactoring-16/
Hey Derek, correct me if I'm wrong. So the basic difference between Abstract Factory design pattern and Decorator design pattern is:
1. When you can create an object many different "definite" ways, use "Abstract factory design pattern". Also disadvantage is, you have to create a factory for every possible combination. More of a static factory.
2.When you can create an object many different "indefinite" ways, use "Decorator design pattern". Here you can dynamically combine any possible combinations. More of a dynamic factory.
Vendettaaaa666 Absolutely those are the main differences.
Headfirst design patterns explains things similarly but using drinks instead of pizza.
You did a much better job of explaining it than the book did though.
Malcom Clark Thank you for the compliment :)
+Malcom Clark That's true! And HF DP is an excellent book for beginners, so this complement is even bigger. :-)
Hey Derek, why don't u just use List instead and just loop through stuff.
I think the pizza example, as well as drinks one are not suitable for this pattern, cause they do not add any new behaviour, u can't do new things with pizza. even if you decorated it.
Please correct me if I'm wrong.
You are right. This exact case is not suitable for Decorator Pattern. But this example shows well how the design works.
Thanks a lot for providing the code. Sometimes I don't quite get things through verbal explanations, but seeing you implement it and then thoroughly going through the code afterward really helped it click. Also, I think at the end of your tutorials that involve coding, you should do one final overview of what just happened when you run the program. In this video for example, I think you could've taken us through how the objects were being wrapped.
That was a brilliant example demonstrating the decorator pattern . Thanks a million!
Thank you for taking the time to tell me I was able to help :) That is very much appreciated!
This video is 1000 times better than how my teacher tried to explain it to us, why thanks ;)
Thank you so much for the excellent videos Derek, This is helping me a great deal in prepping for my CS exam! You are my hero!
Thank you, but you don't have to do that. I'm not one of the guys that asks people to like and favorite everything. The fact that you find them useful is enough for me :)
I love this, thank you so much! It really helps to hear this concepts from someone rather that read boring books a thousand times for each pattern. It's really cool that you do this without expecting money or any type of retribution what so ever.
I probably could have come up with a more specific optimized way to present this pattern. The ToppingDecorator could have been more simplified and then the ingredients could have done most anything. In videos I have to find an example that both demonstrates the pattern while keeping everything as simple as possible. Sometimes I get a great example and other times not so much. Sorry about that
First of all thank you very much. This is the best design pattern tutorials i have ever seen. We demand some more stuff from you in future :).
This is the best example to get the idea of decorator design pattern. Thanks Derek. :)
Awesome. Much better explanation than HeadFirstDesignPatterns. Hats off.
The UML association in the diagram is *composition*, not aggregation. Aggregation uses an empty diamond.
Also, the Mozarella class extends ToppingDecorator. The ToppingDecorator does not extend Mozarella as the UML shows.
Derek, your tutorials are the best! Highly respected!
+Natnael “Dee” yonnatan Thank you very much :)
Hello Sir,
the video was very clearly. I fully understood the matter. Thanks for making and sharing this video.
Thank you very much :)
This series is so good, would rather just watch these videos than take the course im doing at uni!
Thank you very much 😁 A free education online for all is the goal
When I start thinking about using a design pattern I normally first ask if I can accomplish making the code more readable in some other way. If I can't think of another way I use the pattern. You'll find with experience that more often then not you'll use patterns rarely. The positives in knowing them are that you'll start to find other unique ways of solving problems while writing easier to understand code.
For those who don't know about SOLID principles, I recommend reading up on it. "Clean Architecture" by Robert Martin is a really good resource for this but you can just Wiki it. This design pattern is very powerful in that it directly tries to comply with the S(single responsibility) and O(open/close) of SOLID.
My Best channel to learn OOP and DP Great job guys
Thank you :)
I love watching your videos at 1.5 speed. Idk why but it's funny.
That's fast! I think even I'd be confused
are you sure you wanna have "Adding dough" in Mozarella class ?
(10:00)
Rightly pointed out. It should be present in the constructor of the PlainPizza
@@budguesor9222 nope by leaving it in the constructor of plain pizza it would be printed every time the super constructor is called
Man I'm hungry
+NZ255 That's funny :)
Your videos are so great! I always recommend them to my friends taking the Software Design Pattern class at my university. Well done!
man thanks, a year trying to understand this pattern xD it was so easy
Awsome tutorials, I'm preparing for my exam with your videos!! The examples are excellent
Thank you :) I wish you the best on your exams
Thank you :) I do my best to cover complicated topics in easy to understand ways. I'm glad you liked it
Every video from this course helps me to obtain clear understanding of dedicated pattern. Nice work! One remark about Decorator Pattern. You've forgot to implement decorators for meat stuff and olives to obtain perfect pizza :)
Thanks for the video .. They are really helpful .. Rather than reading the GangOfFour book this is much precise and better to be done over a weekend
Thank you :) The goal was to make the GOF book easier to understand
Shouldn't the arrow in mozzarella be pointing the other way around since Mozzarella extends ToppingDecorator? (in the UML)
Regardless, kudos on your videos Derek! I'm learning more here than in lecture lol
I have all of the diagrams on my site. There is a link in the description for the video. I hope it helps
You can always override the PlainPizza class, add a topping of medium, large, Xtra large, etc. You could have all toppings have the same price and then just override the description. The rule extend what differs between toppings will steer you in the right direction
You're very welcome :) Thank you for checking them out
The pizza example used in this video is very effective in understanding Decorator
Pattern. The method of inheritance as described in the video is static and will
not allow for changes in the code. Hence, it is important to use design
patterns because good code is easily manageable and changeable. Using design patterns will allow the client to easily add new toppings to pizza, change the cost of each topping without having to make major changes in the code. An advantage of using decorator pattern particularly is that it uses the code already written and just extends it for additional functionality. The detailed coding example is very helpful in understanding how the decorator pattern functions. Though thespeaker makes an error while coding where he refers to methods as classes which
might confuse new programmers.
He sounds a little bit like Andy from The Office (Ed Helms)
no wories,
i just wantes to say something really :-)
your lectures are very good
This is superb place for learning design pattern. Thanks Derek..
jitendra Kasaudhan Thank you :) You're very welcome
You are a most excellent teacher. I usually have problems learning new (especially programming) concepts, but you made it very easy for me to understand. Your explanation is crystal clear. =)
Thanks Derek just having this topic on my OOP Class.. and it helps a lot. Cheers mate.
Thank you very much :)
Thank you for watching :) I'm glad to help
Yes I slipped up a bit. Thanks for pointing that out
Thank you very much :) It is very nice of you to say that!
Sorry, but I'm not sure what you are trying to do. Send me a message on youtube, or and email derekbanas@verizon.net
Thank you very much :) I love covering niche topics that others ignore
Perfect. No easier way to explain the Decorator design pattern.
Thank you :)
Thank you :) I did my best and I'm glad you liked it
Wonderful tuotorial !!! Im all the way in South Africa
Thank you :) It amazes me that so many people watch my videos in South Africa. It is very cool since I have pretty much never traveled at all.
one more time,I just have to say!
you are the best in UA-cam...
You should make a pizza machine advert, your pizza narrative made me hungry
Fantastic tutorial, very well presented and easy to understand. Wish more tutorials were as high quality as this one! :)
That's funny :) Thank you for the compliment. I'm glad you are enjoying them.
+Derek Banas : Filled diamond represents composition not aggregation ! Also, the diamond is positioned near the parent. Kindly correct me if I am wrong.
yes filled diamond represents composition, however as far as i know the diamond should be on ToppingDecorator because there is defined a Pizza variable in it
Sir, you are guilty of making me hungry during the video. Awesome video. Thx!!
I'm confused by your question. ToppingDecorator provides those methods to the classes that extend it
Hello Derek, thank you for the videos you post ! I find them to be very helpful.
I have some questions about this particular video.
1. Why don’t you put “adding Dough” from the Mozzarella constructor into the PlainPizza constructor?
2. Why do you implement getDescription() and getCost() methods in ToppingDecorator class ? Can you just make them abstract and then implement them in Mozzarella and TomatoSauce class ?
Best regards
1. I agree
2. You might want to do some completing additional logic inside the Abstract: like prepending "Ingredients: " to the Description, or applying a discount on the total Price.
Incredibly easy to learn !!!! THANK YOU !
Great video! When I think about creating a pizza class with many different kinds of toppings, I might choose the builder pattern instead, so that my code for adding toppings can be linearly written instead of in the form of nested constructors. Are there any advantages of the decorator pattern over the builder pattern here?
You're very welcome :) Yes you could do what you described. It is really my fault because I didn't make an example that required the added flexibility this pattern provides. I tried to come up with a simple example of the pattern and in doing so I didn't get the best example. Sorry about that
Thank you :) I pay no attention to video count, views, or anything else. You guys seem to inform me on that stuff
man your design pattern tutos are really awesome they are the best !!!
Could you please create tutos of webservices such as REST and SOAP ?
and why not also cloud computing or advanced php programming
again thank you very much for this tutorial !!!
+Oussama bargougui Thank you very much :) I covered web services here ua-cam.com/video/iqNiINZ4Sxg/v-deo.html
I plan on covering PHP frameworks after I finish up with JS. You're very welcome
+Derek Banas I passed my school exams today using your designe patterns tuto :D
+Oussama bargougui That's Awesome!!! I'm glad I helped :)
You're very welcome :) Im glad you enjoyed it
Nice tutorial! Here's a little lemon twist: what if the class that you want to decorate is constructed only from a Builder pattern. The constructors get tricky.
Sadly anyone can sue you for anything and win whether they are right or wrong. It all depends on if they can wait you out with lawyers. I constantly fight against record labels that make false copyright claims on music I am licensed to use. I've received cease and desist letters for articles I wrote about false claims by web gurus. You can either fight them or lawyer up :(
Kept it simple and easy to understand. Good Format and Great Job
Thank you :)
You taught better than my second year prof. xD
+Yuchen Zhou Thank you :) I did my best
good demo. Code explains itself clearly.
Happy to be of service :)
Absolutely the best I have ever seen in video programming tutorials! You are doing a fantastic job!
Thank you :) Im very happy that you enjoyed it
Thank you :) I'm glad you enjoy them
Very useful. Thank you. Well explained.
Thank you :) Happy I could help