mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-03 04:54:39 +00:00
docs: add diagrams for decorator, delegation, dependency injection, dirty flag, domain model, double buffer, double-checked locking, double dispatch, and dynamic proxy
This commit is contained in:
1 parent
203548ec03
commit
30d13083ae
18 files changed
+36
-12
No files matched your search
@@ -35,6 +35,10 @@ Wikipedia says
|
||||
|
||||
> In object-oriented programming, 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. The decorator pattern is often useful for adhering to the Single Responsibility Principle, as it allows functionality to be divided between classes with unique areas of concern as well as to the Open-Closed Principle, by allowing the functionality of a class to be extended without being modified.
|
||||
|
||||
Sequence diagram
|
||||
|
||||

|
||||
|
||||
## Programmatic Example of Decorator Pattern in Java
|
||||
|
||||
There is an angry troll living in the nearby hills. Usually, it goes bare-handed, but sometimes it has a weapon. To arm the troll it's not necessary to create a new troll but to decorate it dynamically with a suitable weapon.
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 60 KiB |
Reference in new issue
Block a user