Hello android/Java developers,
When a function call a function and that function call another one and so on, how many calls (stack length) would get me into stack over flow? Is there a general rule of thumb?
The reason i am asking is because I am now which is more efficient(design wise) for my 5 players cards game
Solution 1:
for(int i=0;i<100;i++){
p1.play();
p2.play();
p3.play();
p4.play();
}
Solution 2:
p1.play(); //where p1.play() calls p2.play() and so on until p4 calls p1 again.
// this will go on for 100 times
I prefer solution 2 so if there is a crash I can see all the function calls from p1 at i=0 till p4 at i=100
but with solution 1, the stack is much shorter but when there is a crash I will see on the beginning of the loops a the called function play() where crash happened
What do you suggest? I know it is kinda 2 questions in 1 but they are very related
Thank you all