From the course: Node.js: Design Patterns

Unlock the full course today

Join today to access over 24,100 courses taught by industry experts.

The Command pattern

The Command pattern

- [Instructor] With the command pattern, commands are objects that contain all of the data necessary to execute a specific action on the client. Think about boxes of furniture that need to be assembled. Each box contains all of the parts necessary along with the instructions on how to assemble that piece of furniture. A professional installer can open a box, follow the instructions and use the materials to assemble the furniture. The installer doesn't need to know how to build each piece of furniture. It doesn't matter to them because the instructions of how to build the furniture come with the box. The installer can open a box, follow the instructions and assemble the furniture; and then they can move on to the next box. In this analogy I like to think of each furniture package as a command. They are all different, they contain different parts and different instructions. The installer can execute a command. They can…

Contents