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:
“Under bare Ben Bulbens head
In Drumcliff churchyard Yeats is laid.
An ancestor was rector there
Long years ago, a church stands near,
By the road an ancient cross.
No marble, no conventional phrase;
On limestone quarried near the spot
By his command these words are cut:
Cast a cold eye
On life, on death.
Horseman pass by!”
—William Butler Yeats (18651939)
“With only one life to live we cant afford to live it only for itself. Somehow we must each for himself, find the way in which we can make our individual lives fit into the pattern of all the lives which surround it. We must establish our own relationships to the whole. And each must do it in his own way, using his own talents, relying on his own integrity and strength, climbing his own road to his own summit.”
—Hortense Odlum (1892?)