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
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
Thank you for the simple explanation on the decorator pattern :) that was very helpful
The cost for the ExpressoShotDecorator should be Cost = decorator.Cost + .55M;
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.
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
Clear and excellent explanation. Thanks!
Fantastic video. Thank you!
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
2 жыл бұрын
Yeh total clash but it works
Why almost all of the videos about decorator pattern talks about coffe shop..of course bcos the book uses coffe shop as the example
Thanks, very well explained.
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.
Thank you, very clear.
It would be really helpful if you guys could make a video on Code to interface and unity framework(ioc) topics
How is the coffe example a decorator example and not a composite?
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
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
2 жыл бұрын
Yes like he said it’s an onion and each layer is changing the previous value.
I like these 2 doing videos.
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
2 жыл бұрын
thanks
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
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.
Subsystem for the particula functionality, in short
Oh, ok, so the decorator pattern is something similar to the ECS
Guys, that's gonna mount to an ungodly amount of classes... @_@ I'm getting dizzy.
I didn't understand fully
Because everyone decorates an onion. Facepalm.
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.