This should be easy,
I am trying to come up with the name for a command class that is a collection of other commands. All the sub commands will be run, when the master command is run.
Any ideals?
This should be easy,
I am trying to come up with the name for a command class that is a collection of other commands. All the sub commands will be run, when the master command is run.
Any ideals?
Could use "Script" as another alternative suffix (but I'd probably go with CompositeCommand)
If you are simply creating a base class that will automatically execute a list of commands, and is meant to be used as is (i.e. just create a generic Command and pass in a list of sub commands) then I'd use something like CompositeCommand or BatchCommand. If this is not meant to be a generic class but rather a hard-coded specific implementation I'd name it after what the overall operation is. For example:
BatchCommand registerCmd = new BatchCommand();
registerCmd.add(new CreateProfileCmd());
registerCmd.add(new CreatePreferences());
registerCmd.add(new SendWelcomeEmailCmd());
vs
class RegisterCmd extends Command {
execute() {
new CreateProfileCmd().execute();
new CreatePreferences().execute();
new SendWelcomeEmailCmd().execute();
}
}
In the second case I wouldn't create a new name for the RegisterCmd class. It's just a command that happens to call other commands to do its job.
For what it's worth, the Head First book from O'Reilly about design patterns calls it a MacroCommand.
I liked BatchCommand, it represents what it is. I think that CompositeCommand is very "pattern", just as prefixing with "Singleton" a class that is supposed to have only one instance.