Jump to content

Command pattern: Difference between revisions

From LabVIEW Wiki
m Add working links for object and class
Category reorg
 
Line 17: Line 17:
[[Category:Object-Oriented Programming]]
[[Category:Object-Oriented Programming]]
[[Category:Object-Oriented Design Pattern]]
[[Category:Object-Oriented Design Pattern]]
[[Category:Design patterns]]

Latest revision as of 21:01, 2 June 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