Please explain in a few words what the meaning of this template is and what it does. I read the wiki, I did not understand a damn thing. I read it here: http://articles.javatalks.ru/articles/3 It seems I understood a little, but I did not understand the meaning of this template, what it does. The article says about the classes "light" and "TV" (you can turn it on and off) and says that using the template does not need to change the old class. But in fact, in the end, separate on-off methods are created for TV and everything else, just like with Light ..

  • 2
    > using a template, you don’t need to change the old class. You don’t need to change the Switcher class, if it is written once for working with commands. We simply create the "turn on / off the fridge", "turn on / off the radio" commands, and Switcher will work with them without changes. - Nofate
  • 2
    The main features of this pattern are: - isolation of the executor of a call from the place of a call - "call as an object" - you can stack commands into collections to store history, "play" these collections of teams, even wrap several commands into another team (receiving a macro command). : when you do Undo / Redo in Word, this is exactly the work with a collection of such command objects. - Nofate
  • one
    Still did not understand. Why some intermediary switcher. If it is possible to work directly with methods of different classes - user17711
  • 2
    > Why some kind of intermediary switcher to enforce the principle of sole responsibility . For example, the toolbar button should not know anything about the document or the files. All that is part of her duties is to catch clicks with a mouse and trigger an action. And she knows only about the action that he has a method execute() . - Nofate
  • 3
    In general, I advise you to be curious about the principles of SOLID and the law of Demeter , perhaps many questions will disappear. - Nofate

0