I have a challenge with implementing the complex business of an enterprise system. actually there are a lot of validations and other processes which should accrue as a unit of work. now I have a function with lots of codes and lots of validations.
I couldn't split it into smaller functions because for example, some codes have a result that is needed for the rest. and the result types are different.
bool MyFunc (DataDTO input) {
DataType1 data1 = _repo1.Get(input.id1);
var valid1 = checkValidation1();
DataType3 data3 = _repo3.FindBy(data1.someProp && valid1 == true);
//...
DataType2 data2 = _repo2.Get(input.id2)
var valid1 = checkValidation2();
//...
if (valid1 && valid2)
saveSomething(data2, data3);
//...
//and the rest of code
}
I check the chain of responsibility pattern but I think it is not suitable for me. I tried to split my code but my request to database increased.
what should I do?
Aucun commentaire:
Enregistrer un commentaire