lundi 17 février 2020

Suggest design pattern

I have the following logic to be implemented: There are two data sources, 1 and 2

Common methods to be executed for both data sources: functionOne, functionTwo, functionThree, functionFour

functionFive, functionSix, functionSeven are just run for data source 2

I am thinking of putting all the common functions in a helper class in the same package, and just call them using "helper.functionOne" for instance.

Is there any better design pattern to go ahead with this problem?

functionOne();
functionTwo();

if(dataSource == "1"){

     // Perform relevant logic specific to this dataSource
     functionThree();
     functionFour();

     return;
}

//If data source is not "1"
functionFive();
functionSix();
functionSeven();

functionThree();
functionFour();

return;

}

Aucun commentaire:

Enregistrer un commentaire