Why use the command pattern in GWT (or any web app)?

后端 未结 1 1645
日久生厌
日久生厌 2021-02-08 17:30

According to this video here [@ 7:50] Google is recommending the use of the Command pattern on top of its request handling API. There is also a helpful looking project gwt-disp

相关标签:
1条回答
  • 2021-02-08 18:26
    • One good reason to use the command pattern is, when you want to pass the command object to further delegates - so instead of copying all the arguments, it's easier to just pass the command object around. It's also useful for gwt-dispatch's rollback functionality (or the undo/redo functionality e.g. in Eclipse's UndoableOperations).

    • It helps to provide several variations of commands by using different constructors, and subclasses of commands.

    • I would not suggest to always use the pattern, but you don't save as much as you think, when you don't use it: You will often need result objects anyway - and it's possible to reuse the same return objects. In other cases, you can use the same object for the command and for the result.

    • The module can be used for multiple commands.

    0 讨论(0)
提交回复
热议问题