Design Patterns: Decorator

Ғылым және технология

This is the last of an eight part series where Robert is joined by Phil Japikse to discuss design patterns. A design pattern is a best practice you can use in your code to solve a common problem. In this episode, Phil demonstrates the Decorator pattern. This pattern allows behavior to be added to an individual object, either statically or dynamically, without affecting the behavior of other objects from the same class.
Resources:
- Sample code: github.com/skimedic/presentat...
- Design Patterns: Elements of Reusable Object-Oriented Software book: www.amazon.com/Design-Pattern...
- Head First Design Patterns book: www.amazon.com/Head-First-Des...

Пікірлер: 29

  • @fwd79
    @fwd795 жыл бұрын

    Full list for this series: 0. SOLID Design Patterns (start from here): kzread.info/dash/bejne/k5ufubuJhcayoMo.html 1. Design Patterns: Command/Memento: kzread.info/dash/bejne/rIaWqs59ldLUY6g.html 2. Design Patterns: Strategy: kzread.info/dash/bejne/g4592M6nqZS1ns4.html 3. Design Patterns: Template Method: kzread.info/dash/bejne/f5p12NVpnpzbfdY.html 4. Design Patterns: Observer and Publish-Subscribe: kzread.info/dash/bejne/aWaWxsN9nJexfLA.html 5. Design Patterns: Singleton: kzread.info/dash/bejne/pZaBrpWxdqu4kqw.html 6. Design Patterns: Factories: kzread.info/dash/bejne/fHmfmaSYd7irosY.html 7. Design Patterns: Adapter and Façade: kzread.info/dash/bejne/io2VktSmgrDAYbQ.html 8. Design Patterns: Decorator: kzread.info/dash/bejne/aISEr7Rpd7rYirQ.html

  • @bhagpreetbrar1782
    @bhagpreetbrar17825 жыл бұрын

    Thank you for the simple explanation on the decorator pattern :) that was very helpful

  • @sampsonorson
    @sampsonorson4 жыл бұрын

    The cost for the ExpressoShotDecorator should be Cost = decorator.Cost + .55M;

  • @attilajakab4915
    @attilajakab49153 жыл бұрын

    Hi, nice explanation, thanks for sharing this. In the next videos it would be great to also have an example how the client would use this.

  • @sangramghorpade9021
    @sangramghorpade90217 жыл бұрын

    Very very nice design patterns series ... Very nice real life examples and explanation by Philip .. thanks for posting such informative vedio .. plz post more designs patterns vedio

  • @bohdan-belei
    @bohdan-belei9 ай бұрын

    Clear and excellent explanation. Thanks!

  • @joshualord986
    @joshualord9863 жыл бұрын

    Fantastic video. Thank you!

  • @TheViking2
    @TheViking23 жыл бұрын

    Phil is very precise with words even on a casual statement. Robert has a tough time . Haha I've seen Phil correct Roberts statements at least a dozen times. but this is just friendly corrections. :). Best videos in the internet for Design patterns. 👍😎

  • @coderider3022

    @coderider3022

    2 жыл бұрын

    Yeh total clash but it works

  • @nikkokhresna7080
    @nikkokhresna70806 жыл бұрын

    Why almost all of the videos about decorator pattern talks about coffe shop..of course bcos the book uses coffe shop as the example

  • @jaimeogrady7602
    @jaimeogrady76025 жыл бұрын

    Thanks, very well explained.

  • @zubetto85
    @zubetto855 жыл бұрын

    In the example with espresso, it seems that we duplicate the Ingredients list each time we add a decorator (each decorator maintains its own list of ingredients which contains all previous strings plus a new one). Why we can't add to BaseCoffee class the List private field and public methods that allow us to add elements in and retrieve information from this list. In this manner it could be similar to the event system. In general, if I suppose that my object can be modified then I add the property which stores the list of applied modifiers and some method that iterates over this list to define a final state of the object.

  • @Saranwity
    @Saranwity3 жыл бұрын

    Thank you, very clear.

  • @rohitgalgali5512
    @rohitgalgali55127 жыл бұрын

    It would be really helpful if you guys could make a video on Code to interface and unity framework(ioc) topics

  • @DanielRodriguez-ds2qs
    @DanielRodriguez-ds2qs4 жыл бұрын

    How is the coffe example a decorator example and not a composite?

  • @AntonioValentini88
    @AntonioValentini886 жыл бұрын

    Hello! I've got one question. In the EspressoShotDecorator we stack up all the decorated coffe ingredients plus the espresso. But for the cost we just add .55 to our cost, without considering the decorated coffee cost. This way, the espresso shot is gonna cost 0+.55 I think.... Or am i missing anything? Nice Tutorial by the way! Cheers! Antonio

  • @heathenmonk1249

    @heathenmonk1249

    2 жыл бұрын

    4 years late but whatever. The first instance of the coffee "BaseCoffee" has a price of 1.50, and when you decorate it with the espresso you add .55 to that, totaling 2.05. As far as I know you will always need an instance if ICoffee in order to create a espresso, so you can't just instanciate an espresso by itself.

  • @coderider3022

    @coderider3022

    2 жыл бұрын

    Yes like he said it’s an onion and each layer is changing the previous value.

  • @coderider3022
    @coderider30222 жыл бұрын

    I like these 2 doing videos.

  • @zss123456789
    @zss1234567894 жыл бұрын

    I couldn't find the link to the design pattern playlist, could someone please link? Thank you! Edit: Found it kzread.info/head/PLT2NrqLzZng3YMek58eVZVkBiW3NyVSef

  • @mohammeds6314

    @mohammeds6314

    2 жыл бұрын

    thanks

  • @chrisbubbles9850
    @chrisbubbles98507 жыл бұрын

    nice info guy's but maybe next time get a maybe a diagram , or even some uml schematic .. just the code allone makes it hard to follow Judith Bishop did a nice book on the subject years ago "C# 3.0 Design Patterns" published by O'Reilly

  • @MuletTheGreat

    @MuletTheGreat

    3 жыл бұрын

    Hard disagree. Everybody else puts up Visio slides labelled A and B, while these two have a CONVERSATION and talk with their hands. It's brilliant, and easy to follow, for me at least.

  • @s_rox5042
    @s_rox50423 жыл бұрын

    Subsystem for the particula functionality, in short

  • @sc5shout
    @sc5shout2 жыл бұрын

    Oh, ok, so the decorator pattern is something similar to the ECS

  • @TheAngelOfDeath01
    @TheAngelOfDeath01 Жыл бұрын

    Guys, that's gonna mount to an ungodly amount of classes... @_@ I'm getting dizzy.

  • @ibrahimelkilani8508
    @ibrahimelkilani85087 жыл бұрын

    I didn't understand fully

  • @budoray
    @budoray7 жыл бұрын

    Because everyone decorates an onion. Facepalm.

  • @kenichimori8533
    @kenichimori85336 жыл бұрын

    Console Visualizing Data Transmission Portorate Bypass Polar Design Pattern if 0 else 0 function 0/00 Point Position Power 0^0/00 Omega Clock Signature ‰ Com Theta.

Келесі