93
edits
Changes
Command
,→Practical Example
= Practical Example =
Another practical example which made me understand the Command pattern well was the classic remote control example.
Think of a fancy home theatre remote control as an implementation of the Command pattern. Each button on the remote triggers concrete commands. One button may turn on the television, another to turn on the sound system, and another to adjust the volume etc. There are many different buttons on the remote, and it would be easy to add a new command to the remote... just program a new button to do something. You may also have buttons that evoke more than one command, for example turn the tv on and then go to your favourite channel. The reviever would be the VCR or TV on the other end.
= Code Examples =