lundi 24 octobre 2022

how to organize the code when multi varibales get data form multi sources?

I have an API that return a struct which contains variables: a, b and c. To get the value of a,b,c, I have to get original data from multi services,e.g. , S1,S2. S1 returns a1,b1,and S2 returns b2,c2 Now I have to calculate the value of a using a1 and c using c2 and b using b1 and b2. So in this case, how to organize the code? e.g.:

ReqS1();    // here to calculate a and store b1
ReqS2();    // here to calculate b and c

or

ReqS1();  // here to store a1 and b1
ReqS2();  // here to store b2 and c2
CalculateA();  // here to calculate a
CalculateB();  // here to calculate b
CalculateC();  // here to calculate c

or any other better ways?

Aucun commentaire:

Enregistrer un commentaire