mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-13 14:16:02 +00:00
Decorator pattern: Improve the example
This commit is contained in:
1 parent
68ec24c62e
commit
92f8501f7d
10 files changed
+225
-184
No files matched your search
+3
-3
@@ -24,9 +24,9 @@ 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
|
||||
* 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
|
||||
|
||||
## Real world examples
|
||||
* [java.io.InputStream](http://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html), [java.io.OutputStream](http://docs.oracle.com/javase/8/docs/api/java/io/OutputStream.html),
|
||||
|
||||
Reference in new issue
Block a user