Slava Shchaurouski 0c56d800c5 Override annotation added
I think this is a typo
2016-03-26 15:22:33 +03:00
..
2016-03-26 15:22:33 +03:00
2016-02-02 22:14:20 +02:00

layout, title, folder, permalink, categories, tags
layout title folder permalink categories tags
pattern Decorator decorator /patterns/decorator/ Structural
Java
Gang Of Four
Difficulty-Beginner

Also known as

Wrapper

Intent

Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.

alt text

Applicability

Use Decorator

  • to add responsibilities to individual objects dynamically and transparently, that is, without affecting other objects
  • for responsibilities that can be withdrawn
  • when extension by subclassing is impractical. Sometimes a large number of independent extensions are possible and would produce an explosion of subclasses to support every combination. Or a class definition may be hidden or otherwise unavailable for subclassing

Credits