Decorator Design Pattern

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

КОМЕНТАРІ • 569

  • @derekbanas
    @derekbanas  5 років тому +12

    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

  • @IronMeDen1
    @IronMeDen1 2 роки тому +14

    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!

    • @derekbanas
      @derekbanas  2 роки тому +5

      Thank you for taking the time to tell me you like them :)

  • @yuxiwan8917
    @yuxiwan8917 7 років тому +88

    Move the "adding dough" to plain pizza class then the video is perfect!

  • @derekbanas
    @derekbanas  11 років тому +18

    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!

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

    I am a Senior Developer, I watched these videos from Derek 6 years ago, and yes I am watching them again :) #lifeOfDeveloper

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

      I'm very happy to hear that I continue to help :)

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

    Bro, trust me, never find such great tutor where I can understand the design pattern so easily. You are the champ dude.

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

      Thank you for the nice compliment :)

  • @dantheman52420
    @dantheman52420 8 років тому +17

    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.

    • @derekbanas
      @derekbanas  8 років тому +1

      I'm very happy that I could help :)

    • @0x28
      @0x28 8 років тому

      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.

    • @dantheman52420
      @dantheman52420 8 років тому +16

      Congrats dude

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

      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.

  • @html2664
    @html2664 10 років тому +7

    Amazing! I'm from Ukraine, but your tutorial in English is easier than any of I could find in native language! Thanks!

    • @derekbanas
      @derekbanas  10 років тому +1

      Thank you for the compliment :)

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

      Why don't you answer some questions on your comments?

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

    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

  • @biman1988
    @biman1988 11 років тому

    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.

  • @MojSoltani
    @MojSoltani 11 років тому

    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.

    • @derekbanas
      @derekbanas  11 років тому

      Thank you :) I'm glad you enjoyed the videos.

  • @SpMeKP
    @SpMeKP 8 років тому

    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...

    • @derekbanas
      @derekbanas  8 років тому

      Thank you :) I'm here for free when ever I can be of help

  • @nikhil2210
    @nikhil2210 10 років тому

    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!

    • @derekbanas
      @derekbanas  10 років тому

      Nikhil Laddha Thank you for the nice compliment :) There is no need to donate. I'm just happy that I can help.

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

    8 Years latter and still useful, thanks for the high quality video!

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

    You have saved my ass. Exam in one week and I was not getting any of this until I discovered your videos. Hero!!!

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

      Thank you :) Best of luck on your exams

  • @tautvydaskersulis7372
    @tautvydaskersulis7372 4 роки тому +22

    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?

    • @MidasButSilver
      @MidasButSilver 2 роки тому +5

      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.

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

    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

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

      I'm happy they were helpful :)

  • @ChaitanyaBhagwatChai
    @ChaitanyaBhagwatChai 9 років тому +18

    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 :)

    • @derekbanas
      @derekbanas  9 років тому +11

      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.

  • @khana.713
    @khana.713 6 років тому

    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!

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

      That is awesome to know :) I'm happy I have been of help

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

    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...

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

      I'm very happy to hear they helped :)

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

    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!

  • @gandhihardikm
    @gandhihardikm 9 років тому +1

    Thanks Derek for explaining decorator design pattern in such simple way... Hats off... cheers!!!

    • @derekbanas
      @derekbanas  9 років тому

      Hardik Gandhi You're very welcome :) I'm glad I could help.

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

    Why? Why do you have a video about anything I look for? I love you bro.

  • @derekbanas
    @derekbanas  12 років тому +2

    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

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

    It's nearly 1 AM and I'm hungry because of you, thanks

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

      That's funny :)

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

      @@derekbanas This very Design Pattern ended up on the test this morning so thanks I guess haha

  • @derekbanas
    @derekbanas  12 років тому +5

    Thank you :) I like covering niche topics that everyone else avoids

  • @derekbanas
    @derekbanas  11 років тому

    It is very nice to be able to clear up a subject when others haven't helped! Thank you :)

  • @derekbanas
    @derekbanas  12 років тому

    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

  • @robertgloverjr
    @robertgloverjr 12 років тому

    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!

  • @derekbanas
    @derekbanas  11 років тому +1

    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/

  • @Vendettaaaa666
    @Vendettaaaa666 9 років тому

    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.

    • @derekbanas
      @derekbanas  9 років тому

      Vendettaaaa666 Absolutely those are the main differences.

  • @malcomclark2261
    @malcomclark2261 9 років тому +23

    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.

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

      Malcom Clark Thank you for the compliment :)

    • @tonyweak3842
      @tonyweak3842 9 років тому +2

      +Malcom Clark That's true! And HF DP is an excellent book for beginners, so this complement is even bigger. :-)

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

      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.

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

      You are right. This exact case is not suitable for Decorator Pattern. But this example shows well how the design works.

  • @kacyraye
    @kacyraye 11 років тому +1

    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.

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

    That was a brilliant example demonstrating the decorator pattern . Thanks a million!

  • @derekbanas
    @derekbanas  11 років тому +3

    Thank you for taking the time to tell me I was able to help :) That is very much appreciated!

  • @PopeSweetJezus
    @PopeSweetJezus 11 років тому

    This video is 1000 times better than how my teacher tried to explain it to us, why thanks ;)

  • @laleen123
    @laleen123 9 років тому +3

    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!

  • @derekbanas
    @derekbanas  12 років тому

    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 :)

  • @sofiabravo9979
    @sofiabravo9979 12 років тому

    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.

  • @derekbanas
    @derekbanas  11 років тому

    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

  • @grandisukruth
    @grandisukruth 12 років тому

    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 :).

  • @nishurangrej08
    @nishurangrej08 12 років тому

    This is the best example to get the idea of decorator design pattern. Thanks Derek. :)

  • @vigneshsoap123
    @vigneshsoap123 8 років тому

    Awesome. Much better explanation than HeadFirstDesignPatterns. Hats off.

  • @MrMalcovic
    @MrMalcovic 7 років тому +12

    The UML association in the diagram is *composition*, not aggregation. Aggregation uses an empty diamond.

    • @carlmoller807
      @carlmoller807 5 років тому +4

      Also, the Mozarella class extends ToppingDecorator. The ToppingDecorator does not extend Mozarella as the UML shows.

  • @Dayan2k7
    @Dayan2k7 8 років тому

    Derek, your tutorials are the best! Highly respected!

    • @derekbanas
      @derekbanas  8 років тому

      +Natnael “Dee” yonnatan Thank you very much :)

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

    Hello Sir,
    the video was very clearly. I fully understood the matter. Thanks for making and sharing this video.

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

    This series is so good, would rather just watch these videos than take the course im doing at uni!

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

      Thank you very much 😁 A free education online for all is the goal

  • @derekbanas
    @derekbanas  11 років тому

    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.

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

    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.

  • @ayoubaid5296
    @ayoubaid5296 11 років тому

    My Best channel to learn OOP and DP Great job guys

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

    I love watching your videos at 1.5 speed. Idk why but it's funny.

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

      That's fast! I think even I'd be confused

  • @alltheway99
    @alltheway99 11 років тому +26

    are you sure you wanna have "Adding dough" in Mozarella class ?
    (10:00)

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

      Rightly pointed out. It should be present in the constructor of the PlainPizza

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

      @@budguesor9222 nope by leaving it in the constructor of plain pizza it would be printed every time the super constructor is called

  • @NZ255
    @NZ255 9 років тому +144

    Man I'm hungry

    • @derekbanas
      @derekbanas  9 років тому +18

      +NZ255 That's funny :)

  • @stevenfox9695
    @stevenfox9695 9 років тому

    Your videos are so great! I always recommend them to my friends taking the Software Design Pattern class at my university. Well done!

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

    man thanks, a year trying to understand this pattern xD it was so easy

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

    Awsome tutorials, I'm preparing for my exam with your videos!! The examples are excellent

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

      Thank you :) I wish you the best on your exams

  • @derekbanas
    @derekbanas  12 років тому

    Thank you :) I do my best to cover complicated topics in easy to understand ways. I'm glad you liked it

  • @constantinebindas5445
    @constantinebindas5445 11 років тому

    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 :)

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

    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

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

      Thank you :) The goal was to make the GOF book easier to understand

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

    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

  • @derekbanas
    @derekbanas  11 років тому

    I have all of the diagrams on my site. There is a link in the description for the video. I hope it helps

  • @derekbanas
    @derekbanas  12 років тому

    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

  • @derekbanas
    @derekbanas  11 років тому

    You're very welcome :) Thank you for checking them out

  • @deekshajuneja5
    @deekshajuneja5 9 років тому

    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.

  • @bestof1506
    @bestof1506 5 років тому +23

    He sounds a little bit like Andy from The Office (Ed Helms)

  • @alltheway99
    @alltheway99 11 років тому

    no wories,
    i just wantes to say something really :-)
    your lectures are very good

  • @jitendrakasaudhan6585
    @jitendrakasaudhan6585 9 років тому

    This is superb place for learning design pattern. Thanks Derek..

    • @derekbanas
      @derekbanas  9 років тому

      jitendra Kasaudhan Thank you :) You're very welcome

  • @LeBadman
    @LeBadman 11 років тому

    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. =)

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

    Thanks Derek just having this topic on my OOP Class.. and it helps a lot. Cheers mate.

  • @derekbanas
    @derekbanas  12 років тому

    Thank you for watching :) I'm glad to help

  • @derekbanas
    @derekbanas  11 років тому +1

    Yes I slipped up a bit. Thanks for pointing that out

  • @derekbanas
    @derekbanas  11 років тому +1

    Thank you very much :) It is very nice of you to say that!

  • @derekbanas
    @derekbanas  12 років тому

    Sorry, but I'm not sure what you are trying to do. Send me a message on youtube, or and email derekbanas@verizon.net

  • @derekbanas
    @derekbanas  12 років тому

    Thank you very much :) I love covering niche topics that others ignore

  • @azizparsa1145
    @azizparsa1145 10 років тому +1

    Perfect. No easier way to explain the Decorator design pattern.

  • @derekbanas
    @derekbanas  12 років тому

    Thank you :) I did my best and I'm glad you liked it

  • @erasmusmphomagoro4485
    @erasmusmphomagoro4485 11 років тому

    Wonderful tuotorial !!! Im all the way in South Africa

    • @derekbanas
      @derekbanas  11 років тому

      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.

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

    one more time,I just have to say!
    you are the best in UA-cam...

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

    You should make a pizza machine advert, your pizza narrative made me hungry

  • @yukimushu
    @yukimushu 12 років тому

    Fantastic tutorial, very well presented and easy to understand. Wish more tutorials were as high quality as this one! :)

  • @derekbanas
    @derekbanas  11 років тому

    That's funny :) Thank you for the compliment. I'm glad you are enjoying them.

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

    +Derek Banas : Filled diamond represents composition not aggregation ! Also, the diamond is positioned near the parent. Kindly correct me if I am wrong.

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

      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

  • @jibinjohn7867
    @jibinjohn7867 11 років тому

    Sir, you are guilty of making me hungry during the video. Awesome video. Thx!!

  • @derekbanas
    @derekbanas  11 років тому

    I'm confused by your question. ToppingDecorator provides those methods to the classes that extend it

  • @urkep79
    @urkep79 11 років тому +1

    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

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

      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.

  • @AsliAmine
    @AsliAmine 11 років тому

    Incredibly easy to learn !!!! THANK YOU !

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

    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?

  • @derekbanas
    @derekbanas  11 років тому

    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

  • @derekbanas
    @derekbanas  12 років тому

    Thank you :) I pay no attention to video count, views, or anything else. You guys seem to inform me on that stuff

  • @oussemus
    @oussemus 8 років тому

    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 !!!

    • @derekbanas
      @derekbanas  8 років тому

      +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

    • @oussemus
      @oussemus 8 років тому

      +Derek Banas I passed my school exams today using your designe patterns tuto :D

    • @derekbanas
      @derekbanas  8 років тому

      +Oussama bargougui That's Awesome!!! I'm glad I helped :)

  • @derekbanas
    @derekbanas  11 років тому

    You're very welcome :) Im glad you enjoyed it

  • @jasonmorris5256
    @jasonmorris5256 11 років тому

    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.

  • @derekbanas
    @derekbanas  12 років тому

    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 :(

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

    Kept it simple and easy to understand. Good Format and Great Job

  • @yuchenzhou6525
    @yuchenzhou6525 9 років тому

    You taught better than my second year prof. xD

    • @derekbanas
      @derekbanas  9 років тому +1

      +Yuchen Zhou Thank you :) I did my best

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

    good demo. Code explains itself clearly.

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

      Happy to be of service :)

  • @glacagnina
    @glacagnina 11 років тому +1

    Absolutely the best I have ever seen in video programming tutorials! You are doing a fantastic job!

  • @derekbanas
    @derekbanas  11 років тому

    Thank you :) Im very happy that you enjoyed it

  • @derekbanas
    @derekbanas  12 років тому

    Thank you :) I'm glad you enjoy them

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

    Very useful. Thank you. Well explained.

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

      Thank you :) Happy I could help