Whether prompt there can be some receivers in command-pattern? I implement a simple client for dropbox's, it turns out several commands (code below) is the above patrn appropriate here? More specifically, there are getAuth (), helper () methods .... will it be correct to create separate classes (receiver) or do one with the corresponding concret-commandam methods?

private void command(String[] args) throws IOException, ParseException, DbxException { while (true) { if (args.length == 0){ args = helper(); } else if (args[0].toLowerCase().equals("auth") && args.length == 3){ getAuth(args); break; } else if (args[0].toLowerCase().equals("info") && args.length > 1 && args.length < 4) { getInfo(args); break; } else if (args[0].toLowerCase().equals("list") && args.length > 2 && args.length < 5){ getList(args); break; } else { args = helper(); } } } 
  • one
    This pattern is usually used when there is a certain order of commands and you need to keep a history of the execution of commands, to roll back 1 to N steps back. And then, if necessary, to go 1-N steps forward. In your case, I don’t understand why this particular pattern was chosen ... are you going to create a history of command execution? (with the possibility of rollback?) You better state the task in more detail, what will be the methods and what functionality to carry, then you can advise something more specific ... - Lesiuk Alexey
  • ATP, it seems to me that this pattern is not needed in this task) - Emptiness

1 answer 1

This pattern is usually used when there is a certain order of commands and you need to keep a history of the execution of commands, to roll back 1 to N steps back. And then, if necessary, to go 1-N steps forward.

In your case, I don’t understand why this particular pattern was chosen ... are you going to create a history of command execution? (with the possibility of rollback?)

You better state the task in more detail, what will be the methods and what functionality to carry, then it will be possible to advise something more specific ...