#354 Add maven model for feature toggle design pattern

This commit is contained in:
Joseph McCarthy
2016-01-25 21:14:24 +00:00
parent cf10bd1d05
commit d7526fc7c0
86 changed files with 1165 additions and 270 deletions

View File

@ -10,15 +10,18 @@ tags:
- Difficulty-Intermediate
---
**Also known as:** Action, Transaction
## Also known as
Action, Transaction
**Intent:** Encapsulate a request as an object, thereby letting you
## Intent
Encapsulate a request as an object, thereby letting you
parameterize clients with different requests, queue or log requests, and
support undoable operations.
![alt text](./etc/command.png "Command")
**Applicability:** Use the Command pattern when you want to
## Applicability
Use the Command pattern when you want to
* parameterize objects by an action to perform. You can express such parameterization in a procedural language with a callback function, that is, a function that's registered somewhere to be called at a later point. Commands are an object-oriented replacement for callbacks.
* specify, queue, and execute requests at different times. A Command object can have a lifetime independent of the original request. If the receiver of a request can be represented in an address space-independent way, then you can transfer a command object for the request to a different process and fulfill the request there
@ -26,16 +29,16 @@ support undoable operations.
* support logging changes so that they can be reapplied in case of a system crash. By augmenting the Command interface with load and store operations, you can keep a persistent log of changes. Recovering from a crash involves reloading logged commands from disk and re-executing them with the execute operation
* structure a system around high-level operations build on primitive operations. Such a structure is common in information systems that support transactions. A transaction encapsulates a set of changes to data. The Command pattern offers a way to model transactions. Commands have a common interface, letting you invoke all transactions the same way. The pattern also makes it easy to extend the system with new transactions
**Typical Use Case:**
## Typical Use Case
* to keep a history of requests
* implement callback functionality
* implement the undo functionality
**Real world examples:**
## Real world examples
* [java.lang.Runnable](http://docs.oracle.com/javase/8/docs/api/java/lang/Runnable.html)
**Credits**
## Credits
* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)