2. What is the software design pattern?
• Introduction
In software engineering, a design pattern is a general
reusable solution to a commonly occurring problem within a given
context in software design. A design pattern is not a finished design
that can be transformed directly into source or machine code.
2
3. Creational
Behavioral Structural
Deal with object
creation
mechanism
Deal with common
communication
between objects
Ease the design
by identifying a
simple way to
realize
relationships
between entities.
• Classification
3
6. What Is Decorator Pattern?
The decorator pattern is a design pattern that
allows behavior to be added to an individual object,
either statically or dynamically, without affecting the
behavior of other objects from the same class.
Before Decorating After Decorating
6
9. Advantages and Disadvantages
• Advantages
• fewer classes than with static inheritance
• dynamic addition/removal of decorators
• keeps root classes simple
• Disadvantages
• proliferation of run-time instances
• abstract Decorator must provide common interface
• Inheritance solution has an explosion of classes
• If another view were added such as Streamed Video View, double
the number of Borders/Scrollbar classes
9
10. Related Patterns
• Adapter: A decorator is different from an adapter
in that a decorator only changes an object‘s
responsibilities, not its interface; an adapter will
give an object a completely new interface.
• Strategy : A decorator lets you change the skin of
an object; a strategy lets you change the guts.
10