Presentation is loading. Please wait.

Presentation is loading. Please wait.

Decorator Intent Also known as Wrapper Example: a Text Window

Similar presentations


Presentation on theme: "Decorator Intent Also known as Wrapper Example: a Text Window"— Presentation transcript:

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?


Download ppt "Decorator Intent Also known as Wrapper Example: a Text Window"

Similar presentations


Ads by Google