Decorator Structural Pattern - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

Decorator Structural Pattern

Description:

Outline. Structural patterns deals with the composition of classes and objects ... Avoids overwhelming higher level classes with too many features. Liabilities ... – PowerPoint PPT presentation

Number of Views:24
Avg rating:3.0/5.0
Slides: 10
Provided by: BRD82
Category:

less

Transcript and Presenter's Notes

Title: Decorator Structural Pattern


1
Decorator - Structural Pattern
  • Sreeparvathy Pillai

2
Outline
  • Structural patterns deals with the composition of
    classes and objects
  • Decorator (also known as wrapper) is a structural
    pattern that composes objects recursively to add
    responsibilities.
  • It attaches responsibilities dynamically to
    individual objects not to the entire class

3
More on Decorator...
  • The decorator object encloses a component and
    adds additional functionality to that component.
  • Decorator extends an object transparently
  • You can add any number of layers on an object at
    run time.

4
Structure
5
Example
  • Say we have a TextView object and we want to add
    borders and scroll bars to it.
  • 3 Types of Borders Plain, 3D, Fancy
  • 2 Types of Scrollbars Horizontal, Vertical

6
Structure(Example)
7
Example(Contd..)
8
Applicability
  • To add/withdraw responsibilities to individual
    objects dynamically without affecting other
    object.
  • When extension by subclassing is impractical.

9
Consequences
  • Benefits
  • More flexibility than static inheritance
  • Avoids overwhelming higher level classes with too
    many features
  • Liabilities
  • Too many objects
  • A decorator and its component are not identical
Write a Comment
User Comments (0)
About PowerShow.com