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:
“I had now formed a clear and settled opinion, that the people of America were well warranted to resist a claim that their fellow-subjects in the mother-country should have the entire command of their fortunes, by taxing them without their consent.”
—James Boswell (17401795)
“It is a very true and expressive phrase, He looked daggers at me, for the first pattern and prototype of all daggers must have been a glance of the eye.... It is wonderful how we get about the streets without being wounded by these delicate and glancing weapons, a man can so nimbly whip out his rapier, or without being noticed carry it unsheathed. Yet it is rare that one gets seriously looked at.”
—Henry David Thoreau (18171862)