mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-09-10 04:19:54 +00:00
add first impl
This commit is contained in:
+15
-2
@@ -14,9 +14,22 @@ tags:
|
||||
Post pattern, Extension Object pattern
|
||||
|
||||
## Intent
|
||||
Adapt an object to different client’s needs through transparently attached role objects, each one representing a role
|
||||
the object has to play in that client’s context. The object manages its role set dynamically. By representing roles as
|
||||
individual objects, different contexts are kept separate and system configuration is simplified.
|
||||
|
||||
## Applicability
|
||||
|
||||
## Real world examples
|
||||
Use the Role Object pattern, if:
|
||||
- you want to handle a key abstraction in different contexts and you do not want to put the resulting contextspecific interfaces into the same class interface.
|
||||
Words: 4895 Page 3 of 11
|
||||
- you want to handle the available roles dynamically so that they can be attached and removed on demand, that is
|
||||
at runtime, rather than fixing them statically at compile-time.
|
||||
- you want to treat the extensions transparently and need to preserve the logical object identity of the resulting
|
||||
object conglomerate.
|
||||
- you want to keep role/client pairs independent from each other so that changes to a role do not affect clients
|
||||
that are not interested in that role.
|
||||
|
||||
## Credits
|
||||
- [Hillside - Role object pattern](https://hillside.net/plop/plop97/Proceedings/riehle.pdf)
|
||||
- [Role object](http://wiki.c2.com/?RoleObject)
|
||||
- [Fowler - Dealing with roles](https://martinfowler.com/apsupp/roles.pdf)
|
||||
Reference in New Issue
Block a user