views:

122

answers:

7

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?

+5  A: 

CompositeCommand, maybe?

Anton Gogolev
thanks, that what I thought of, but I wished to check if other people use the name in the same way.
Ian Ringrose
+2  A: 

Composite Command?

gkrogers
+1  A: 

"Batch Command" would be my choice.

GWLlosa
Not a bad choice actually; however, I personally would associate a "batch command" with a specific use case, namely _applying_ a fixed sequence of commands _to a set of input items_. I find "composite command" more neutral in its meaning.
stakx
For us this would not work, as our software tracks "batches" in pipelines. However I like this name as Composite is harder for poeple that don't have English has a first language.
Ian Ringrose
A: 

Could use "Script" as another alternative suffix (but I'd probably go with CompositeCommand)

Paolo
+1  A: 

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.

Mr. Shiny and New
+2  A: 

For what it's worth, the Head First book from O'Reilly about design patterns calls it a MacroCommand.

Jérémie Koenig
A: 

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.

bloparod