mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-23 14:25:02 +00:00
fbb12b53ba
I did the job and splitted up the readme, hopefully everything was splitted correctly...
19 lines
772 B
Markdown
19 lines
772 B
Markdown
---
|
|
layout: pattern
|
|
title: Decorator
|
|
folder: decorator
|
|
categories: pattern_cat
|
|
tags: pattern_tag
|
|
---
|
|
|
|
**Intent:** Attach additional responsibilities to an object dynamically.
|
|
Decorators provide a flexible alternative to subclassing for extending
|
|
functionality.
|
|
|
|

|
|
|
|
**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 |