There's a specific snippet of code that I often use for recycling objects in a list based on a data provider. I thought of making a class to run through the snippet, using a given class to handle each step. This problem is... I don't know what to name it. Does a design pattern exist that describes this reusing of snippets?
package
{
public class RecycleOperationRunner implements IRecycleOperationRunner
{
public function RecycleOperationRunner()
{
}
public function run(operation:IRecycleOperation):void
{
const m:int = Math.max(numObjects, numDataItems);
for (var i:int = 0; i < m; i++)
{
if (i < numDataItems)
{
if (i < numObjects)
{
operation.reuseItem(i);
}
else
{
operation.createItem(i);
}
operation.setupItem(i);
}
else
{
operation.removeItem(i);
}
}
operation.dispose();
}
}
}