/
Decorator Design Pattern Decorator Design Pattern

Decorator Design Pattern - PowerPoint Presentation

tatiana-dople
tatiana-dople . @tatiana-dople
Follow
469 views
Uploaded On 2016-10-08

Decorator Design Pattern - PPT Presentation

Phillip Shin Overview Problem Solution Example Key points Problem Want to add responsibilities to individual objects not entire class Inheritance is inflexible Would have to create class for every different combination of functionality ID: 473005

decorator component functionality window component decorator window functionality adds object class decorators simple concrete interface including scrollbars vertical time

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "Decorator Design Pattern" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

Decorator Design Pattern

Phillip ShinSlide2

Overview

Problem

Solution

Example

Key pointsSlide3

Problem

Want to add responsibilities to individual objects, not entire class

Inheritance is inflexible

Would have to create class for every different combination of functionalitySlide4

Solution

Wrap the component in another object that adds functionality on a per need basis

Wrapper called a DecoratorSlide5

Participants

Component (window)

Defines interface for “

decoratable

” objects

Concrete Component (simple window)

Object which can be decorated

Decorator (window decorator)

Maintains reference to component and conforms interface to component

Concrete Decorators (horizontal and vertical scroll bar decorators)

Adds responsibilities to componentSlide6

ExampleSlide7
Slide8
Slide9

Example

The output of this program is "simple window, including vertical scrollbars, including horizontal scrollbars"Slide10

Key Points

Alternative to sub classing, which adds behavior at compile time, changing all subclasses

Allows dynamic decoration of different instances of an object at run time

Used when there are several independent ways of extending functionality