mercredi 2 septembre 2015

Modify abstract factory design pattern for two-level factory creation

I have been working with C# 4.0 creating a code-base to process N files, at the beginning of the process that was the requirement, now the requirement changed and I need to process group of files, so we can say we have "processes" and every process has his own group of files:

I.E.:

Process1 { 4 files}

Process2 { 10 files}

Process3 { 23 files}

...

I have implemented the abstract factory design pattern for the initial requirement, so my factory receives the name of the file and with that I create the concrete instance of the class that process that specific file, now I need to adapt the pattern to at first create an Instance of the Process and with that instance create instances of the specific objects to process each file, I am trying to get something like this:

var processInstance = processFactory.GetInstance(processId);

processInstance.Method1(params);

var fileProcessor = processInstance.GetFileProcessorInstance(fileId);
fileProcessor.Method1(params);
fileProcessor.Method2(params);

processInstance.Method2(params);

Thanks for your help

Aucun commentaire:

Enregistrer un commentaire