Download presentation
Presentation is loading. Please wait.
Published byLeonard Clarke Modified over 6 years ago
1
Decorator Intent Also known as Wrapper Example: a Text Window
Add additional responsibilities and functionality to objects dynamically Also known as Wrapper Example: a Text Window
2
Decorator: Motivation & Application
Subclassing can only add functionality at runtime Avoid enumerating all possible sub classes Such as adding a border function to text window. Use with optional functionality
3
Decorator: Structure Participants: Component, ConcreteComponent, Decorator, ConcreteDecorator
4
Decorator: Consequences
Positives More flexibility than static inheritance Avoids feature laden classes high in hierarchy Negatives Lots of little objects Interface conformance
5
Flyweight Intent: Use sharing to support large numbers of fine-grained objects efficiently Origin: A boxing class which includes fighters weighing less than 112 lb (50 kg) but above 108 lb. Example: Character in a word processor
6
Flyweight: Motivation & Application
Applications that could benefit from using objects But the objects are very small and numerous
7
Flyweight: Structure Participants: Flyweight, ConcreteFlyweight, UnsharedConcreteFlyweight, FlyweightFactory, Client
8
Flyweight: Consequences
Positives Space saving by using shared objects Adds functionality to the application Negatives Adding processing time of computing extrinsic state Time can be reduced
9
Any Questions?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.