- I have functions a, b, and c.
- a calls b in 100 times.
- b calls c 100 times.
- Therefore if a is called once, c is called 10,000 times.
- c requires many variables from a's scope.
Should I:
- Pass the variables through b and c as parameters.
- Define b and c in a's scope so they can access a's variables.
- Define b in a's scope and define c in b's scope.
- Make the variables member variables in the file that a is defined it, and change them from inside a.
- Do some other thing.
I don't want to do 1 because then b and c will have many parameters. I don't want to do 2 or 3 because then b and c will be unnecessarily re-defined every time a is called. I don't want to do 4 because having member variables that are only used in a single place in a lower scope seems bad. Is there another option? Are any of my reasons not to do 1-4 wrong?