title: Java implementation of workflow engine
body: <p>Homegrown workflow framework that I am working on instantiates a class for every task that needs to be called for executing a workflow. More number of tasks = More number of classes to be created. How can this be optimized? I don't want to create a class for every single task.</p>
  
  <p>Eg.</p>
  
  <pre><code>Class MyWorkflow {
   public List &lt; Task &gt; getTasks() {
    return new ArrayList &lt; Task &gt; (
     Arrays.asList(new Task1(),
      new Task2(),
      new Task3(),
     )
    );
   }
  }
  </code></pre>