Jump to content

Command pattern: Difference between revisions

From LabVIEW Wiki
Add new page
 
m Add working links for object and class
Line 1: Line 1:
'''Command pattern''' is a basic [[design pattern]] in [[object-oriented programming]] in which an [[object]] is used to [[encapsulation|encapsulate]] data and behavior in order to perform an action or trigger an [[event]] at a later time. The client then executes a command through a common interface that is provided by the parent [[class]].
'''Command pattern''' is a basic [[design pattern]] in [[object-oriented programming]] in which an [[object (object-oriented programming)|object]] is used to [[encapsulation|encapsulate]] data and behavior in order to perform an action or trigger an [[event]] at a later time. The client then executes a command through a common interface that is provided by the parent [[class (object-oriented programming)|class]].


This pattern is typically used in message handlers to avoid the need to convert data to/from [[variant]] or [[string]]. It requires the definition of a generic parent class, which defines the interface that must be implemented by its child classes. For every command a new child class is required. Each child class then overrides the execution method of the parent class to implement the specific functionality.
This pattern is typically used in message handlers to avoid the need to convert data to/from [[variant]] or [[string]]. It requires the definition of a generic parent class, which defines the interface that must be implemented by its child classes. For every command a new child class is required. Each child class then overrides the execution method of the parent class to implement the specific functionality.

Revision as of 10:20, 6 April 2020

Command pattern is a basic design pattern in object-oriented programming in which an object is used to encapsulate data and behavior in order to perform an action or trigger an event at a later time. The client then executes a command through a common interface that is provided by the parent class.

This pattern is typically used in message handlers to avoid the need to convert data to/from variant or string. It requires the definition of a generic parent class, which defines the interface that must be implemented by its child classes. For every command a new child class is required. Each child class then overrides the execution method of the parent class to implement the specific functionality.

The command pattern is sometimes combined with the channeling pattern for pre-processing/post-processing around the execution method of child classes.

See also

External links