This commit is contained in:
Ilkka Seppälä
2019-12-13 21:09:28 +02:00
parent 0335c61512
commit b2b1ba95eb
127 changed files with 282 additions and 450 deletions

View File

@ -5,9 +5,7 @@ folder: role-object
permalink: /patterns/role-object/
categories: Structural
tags:
- Java
- Difficulty-Medium
- Handle Body Pattern
- Extensibility
---
## Also known as
@ -23,12 +21,14 @@ individual objects, different contexts are kept separate and system configuratio
## Applicability
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 context specific interfaces into the same class interface.
- 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 resultingobject 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.
- You want to handle a key abstraction in different contexts and you do not want to put the resulting context specific interfaces into the same class interface.
- 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 resultingobject 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)
- [Fowler - Dealing with roles](https://martinfowler.com/apsupp/roles.pdf)