1- ---
1+ ---
22layout: pattern
33title: Command
44folder: command
@@ -19,7 +19,7 @@ Encapsulate a request as an object, thereby letting you parameterize clients wit
1919requests, queue or log requests, and support undoable operations.
2020
2121## Explanation
22- Real world example
22+ Real- world example
2323
2424> There is a wizard casting spells on a goblin. The spells are executed on the goblin one by one.
2525> The first spell shrinks the goblin and the second makes him invisible. Then the wizard reverses
@@ -135,7 +135,7 @@ public class Goblin extends Target {
135135}
136136```
137137
138- Finally we have the wizard in main function who casts spell
138+ Finally, we have the wizard in the main function casting spells.
139139
140140``` java
141141public static void main(String [] args) {
@@ -202,22 +202,22 @@ Use the Command pattern when you want to:
202202* Parameterize objects by an action to perform. You can express such parameterization in a
203203procedural language with a callback function, that is, a function that' s registered somewhere to be
204204called at a later point. Commands are an object-oriented replacement for callbacks.
205- * Specify, queue, and execute requests at different times. A Command object can have a lifetime
205+ * Specify, queue, and execute requests at different times. A Command object can have a life
206206independent of the original request. If the receiver of a request can be represented in an address
207207space-independent way, then you can transfer a command object for the request to a different process
208208and fulfill the request there.
209209* Support undo. The Command' s execute operation can store state for reversing its effects in the
210210command itself. The Command interface must have an added un-execute operation that reverses the
211211effects of a previous call to execute. The executed commands are stored in a history list.
212- Unlimited-level undo and redo is achieved by traversing this list backwards and forwards calling
213- un-execute and execute, respectively.
212+ Unlimited-level undo and redo functionality is achieved by traversing this list backward and forward
213+ calling un-execute and execute, respectively.
214214* Support logging changes so that they can be reapplied in case of a system crash. By augmenting the
215215Command interface with load and store operations, you can keep a persistent log of changes.
216- Recovering from a crash involves reloading logged commands from disk and re-executing them with
216+ Recovering from a crash involves reloading logged commands from the disk and re-executing them with
217217the execute operation.
218218* Structure a system around high-level operations build on primitive operations. Such a structure is
219- common in information systems that support transactions. A transaction encapsulates a set of changes
220- to data . The Command pattern offers a way to model transactions. Commands have a common interface,
219+ common in information systems that support transactions. A transaction encapsulates a set of data
220+ changes . The Command pattern offers a way to model transactions. Commands have a common interface,
221221letting you invoke all transactions the same way. The pattern also makes it easy to extend the
222222system with new transactions.
223223
@@ -227,7 +227,7 @@ system with new transactions.
227227* Implement callback functionality
228228* Implement the undo functionality
229229
230- ## Real world examples
230+ ## Real- world examples
231231
232232* [java.lang.Runnable](http:// docs.oracle.com/javase/8/docs/api/java/lang/Runnable.html)
233233* [org.junit.runners.model.Statement](https:// github.com/junit-team/junit4/blob/master/src/main/java/org/junit/runners/model/Statement.java)
0 commit comments