Design Patterns Session 4 (Command, Undo/Redo)

แชร์
ฝัง
  • เผยแพร่เมื่อ 13 ต.ค. 2024

ความคิดเห็น • 17

  • @grandevalpha
    @grandevalpha 9 หลายเดือนก่อน +1

    great work, thank you for the video

    • @ScottStanchfield
      @ScottStanchfield  9 หลายเดือนก่อน

      Glad you liked it! Happy to do it!

  • @aleksandarstojanovic6248
    @aleksandarstojanovic6248 5 ปีที่แล้ว +1

    Thanks for the great video, its people like you that make complex things easy to understand.

    • @ScottStanchfield
      @ScottStanchfield  5 ปีที่แล้ว

      My pleasure, and thanks for the compliment!

  • @ruixue6955
    @ruixue6955 6 ปีที่แล้ว +1

    2:20 source code - *Account (receiver)*
    4:27 the source code of the UI
    9:14 introduction of command pattern
    9:19 standard single API for macro
    9:46 action
    10:12 create action
    10:20 an *action allows you to create an instance of the command and then run them*
    12:12 the actions are really the interpretation of what the user is doing
    14:45 DepositAction source code
    15:41 source code - DepositeCommand (concrete command)
    15:54 source code - TransferCommand
    16:29 *another benifit of command pattern - **16:35** Undo/Redo*
    17:27 introduction of UndoManager
    35:53 question: for doing the command compression with decorator pattern help, it depends on how you implemented it
    36:33 compound command

    • @ScottStanchfield
      @ScottStanchfield  2 ปีที่แล้ว

      Thanks so much!

    • @ruixue6955
      @ruixue6955 2 ปีที่แล้ว +1

      @@ScottStanchfield We should thank you :D this tutorial taught already details of the command pattern. Before watching this video, I came across the command patterns through reading the gof book, but really had difficulty in understanding what's that hell was about

  • @omarch7925
    @omarch7925 5 ปีที่แล้ว +1

    great work, Thank you so much

  • @Rachoszsky
    @Rachoszsky 5 ปีที่แล้ว

    Excellent! Thanks a lot Scott, this was very helpful!
    I was just wondering: Where would you add the "batching" of similar commands? In the UndoManager?

    • @ScottStanchfield
      @ScottStanchfield  5 ปีที่แล้ว

      Thanks! To batch commands, I usually have something like a "collapse" method in the command that takes another command as an argument and returns true if the state from the other command could be combined, false otherwise. (The default would be false). The UndoManager peeks at the top of the unto stack and passes that command to the new command's collapse(). If true returned, the UndoManager pops the stack before pushing the new Command. Classic example is changing the value of a property many times in a row, such as changing a name as the user is typing it in a field - you really don't want undo() to undo each letter typed; you want undo() to revert all changes to that field that happened in a row. For that type of case, a ChangeValueCommand would look at the previous command (passed into collapse()) and grab its "old value", and store that as the "old value" in the new command.

    • @Rachoszsky
      @Rachoszsky 5 ปีที่แล้ว

      @@ScottStanchfield nice solution, thanks!

  • @olimilo1402
    @olimilo1402 6 ปีที่แล้ว

    Hi Scott, a thousand thanks for the very good and understandable tutorial, I am a VB-Developer. I found a serious error. If the user deposits to account #1 and then deposits to account #2, the collapsible will not distinguish between different accounts, so please spend an extra property account to the DepositCommand and only return collapsible=true if the account is the same.

    • @ScottStanchfield
      @ScottStanchfield  6 ปีที่แล้ว

      Hehehe ... Good thing I'm not actually writing banking software ;) Thanks for the catch!

  • @wizzyx09
    @wizzyx09 5 ปีที่แล้ว

    great work

  • @mateusmesquita7062
    @mateusmesquita7062 6 ปีที่แล้ว

    I don't like java at all, but the presenter code and explanation are **really** nice!

    • @ScottStanchfield
      @ScottStanchfield  6 ปีที่แล้ว +1

      Mateus Mesquita Thanks! Glad you liked it. The pattern concepts will play in most languages of course. I may have to start doing these in kotlin...