Suppose I have a function called do3 (). In order for this function to work, I need the functions do1 () and do2 ().
However, do1 () and do2 () may also be needed for other things (perhaps for do4 ())
All of these features are publicly available (and must be publicly accessible).
Question: how do I implement the code?
Option 1:
function do3() { do2() do whatever is needed for do3 } function do2() { do1() do whatever is needed for do2 } function do1() { do whatever is needed for do1 }
So, if I call do3 (), I am sure that everything will be done, although the connection will be displayed
Option 2
function do3() { do whatever is needed for do3 } function do2() { do whatever is needed for do2 } function do2() { do whatever is needed for do1 }
So when I want to call do3 (), I have to
do1() do2() do3()
I feel that the second option is better, since it has less grip, but I can’t explain why, it is more like a feeling. I think that if I use the option one and one day, I change do2 (), I may have problems.
With option 2, however, I must definitely call do1 and do2 every time I want to use do3.
If anyone has a better idea (option 3?), It would be great.
thanks