Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have to run certain number of statements (which are executing .exe) in a loop.

 ForEach(object obj in ListOfVersions)
      Step 1: call Exe1 Args=obj.somevalues
      Log Step 1 completed for obj

      Step 2: call Exe2 Args=obj.somevalues
      Log Step 2 completed for obj

      Step 3: call Exe3 Args=obj.somevalues
      Log step 3 completed for obj

Step 4: call Exe4

Is there any specific design pattern available to use for above situation.

share|improve this question
Why are you doing this? is this not what ms dos ".bat" where scripts created for? – Darknight May 2 '12 at 15:19

I agree with @Neil saying that there looks to be no special pattern name for this processing type. The name I would give for it is "Batch Processing Job" with each call representing a step in the batch. This naming is frequently used in some ETL Tools and Mainframes.

Notice the following though:

  • You need to decide whether you keep all the logs in one file or not. If you intend to, you have two options, either to use separate files and concatenate at end of all processes or to use one stream writer and keep it open until all processes finish then flush it and close in all cases (even when one process fails).

  • You need to do error checking after each call.

share|improve this answer

There is no specific pattern in the general sense. If you're referring to asynchronous operations, then the below answer is not what you're looking for:

public void executeForAll() 
    ForEach(object obj in ListOfVersions)
      execute("Exe1", obj);
      execute("Exe2", obj);
      execute("Exe3", obj);

public void execute(String executable) 
    execute(executable, null);

public void execute(String executable, object obj) 
    // Call executable Args=obj == null ? null : obj.somevalues
    log(executable, obj);

public void log(String executable, object obj)
    // Log Step 2 completed for obj
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.