上QQ阅读APP看书,第一时间看更新
Use case
A common use of the command pattern is with user interfaces and related frameworks. This can be extended to both hardware and software interfaces. To demonstrate the command pattern, we will model a hardware control box that contains an on/off toggle, a slider that has a range between 0 and 100, and a digital display for the slider value. Key to our example is that the hardware control box is manufactured without knowing what specifically it will be used for. The following diagram depicts this:
Command design pattern —ControlBox example
In the next section, we will review a UML class diagram associated with our control box example.