Command Pattern

In object-oriented programming, the command pattern is a behavioural design pattern in which an object is used to represent and encapsulate all the information needed to call a method at a later time. This information includes the method name, the object that owns the method and values for the method parameters.

Three terms always associated with the command pattern are client, invoker and receiver. The client instantiates the command object and provides the information required to call the method at a later time. The invoker decides when the method should be called. The receiver is an instance of the class that contains the method's code.

Using command objects makes it easier to construct general components that need to delegate, sequence or execute method calls at a time of their choosing without the need to know the owner of the method or the method parameters.

Read more about Command Pattern:  Uses, Structure, Terminology, Example

Famous quotes containing the words command and/or pattern:

    It is manifest therefore that they who have sovereign power, are immediate rulers of the church under Christ, and all others but subordinate to them. If that were not, but kings should command one thing upon pain of death, and priests another upon pain of damnation, it would be impossible that peace and religion should stand together.
    Thomas Hobbes (1579–1688)

    His talent was as natural as the pattern that was made by the dust on a butterfly’s wings. At one time he understood it no more than the butterfly did and he did not know when it was brushed or marred. Later he became conscious of his damaged wings and of their construction and he learned to think and could not fly any more because the love of flight was gone and he could only remember when it had been effortless.
    Ernest Hemingway (1899–1961)