Command pattern

From LabVIEW Wiki
Jump to: navigation, search

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.

Command Pattern.png

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