In "disadvantages of global states", what is the relationship between "starting state is changed" and "unpredictable"?
According to Why is Global State so Evil?, I know there are already many answers about why is "global states" bad. However, I'm not raising new reasons to oppose that. Instead, the currently top answer : https://softwareengineering.stackexchange.com/a/148109/432039, which used a term seems unique to other answer : "starting state", and what I don't know is, what is the relationship between "starting state is changed" and "unpredictable"? Over past years I misunderstood those answer in several ways: The answer says "global state" is bad because it makes the program unpredictable, which I think "unpredictable" means something interact with others is logically to complex to understand and hence unpredictable. Also it doesn't distinguishes "global variables" from "global state", making me wrongly understand the answer as : "Don't write any programs with global states that interact with others", and hence I often want to ask the author of the answers : Should I only write stateless apps? How can I write a shopping app with shopping carts that store the selected items? Or should I write all the codes in a single class so that no other class exists and hence no "global states"? And even if it is the reason, why would passing the "global states" with "dependency injection" solves the problem? After reading https://softwareengineering.stackexchange.com/a/440481/432039, I finally understand the answer is not opposing all global states, but opposing "global variables" only, which suggest accessing global states with a better method : dependency injection. Also after reading https://softwareengineering.stackexchange.com/a/450923/432039, I finally understand "unpredictable" actually means "hidden dependency" : when you use global variables: public float getCost(float price, int quantity){ return UserData.discount*price*quantity; } you may not realize UserData.discount is also affecting the output besides price and quantity, it is called "hidden dependency" and that is so called "unpredictable". So modifying it as public float getCost(UserData userData, float price, int quantity){ return userData.discount*price*quantity; } so that all dependencies appear on the parameters and hence I can find all dependencies in easier way. However, what I don't understand is, why would the answer mentions about "starting state is changed"? Because I think even if "UserData.discount" is never changed, it is still a hidden dependency that affecting the output. Even if "UserData.discount" is never changed after the program starts, it seems wouldn't help me to aware the line of code "UserData.discount*". So I think whether starting states is changed isn't relevant to the drawbacks of global variables. So my question is, why does the answer attribute "unpredictable" to "global state is changed"? Why should I specially care the initial value of the global variable? And even if it is true, why would modifying the initial value through passing parameters (dependency injection) solves the problem? Or am I still misunderstanding the answers (eg: misunderstanding what "starting state" refers to?)?

According to Why is Global State so Evil?, I know there are already many answers about why is "global states" bad. However, I'm not raising new reasons to oppose that. Instead, the currently top answer : https://softwareengineering.stackexchange.com/a/148109/432039, which used a term seems unique to other answer : "starting state", and what I don't know is, what is the relationship between "starting state is changed" and "unpredictable"?
Over past years I misunderstood those answer in several ways: The answer says "global state" is bad because it makes the program unpredictable, which I think "unpredictable" means something interact with others is logically to complex to understand and hence unpredictable. Also it doesn't distinguishes "global variables" from "global state", making me wrongly understand the answer as : "Don't write any programs with global states that interact with others", and hence I often want to ask the author of the answers : Should I only write stateless apps? How can I write a shopping app with shopping carts that store the selected items? Or should I write all the codes in a single class so that no other class exists and hence no "global states"? And even if it is the reason, why would passing the "global states" with "dependency injection" solves the problem?
After reading https://softwareengineering.stackexchange.com/a/440481/432039, I finally understand the answer is not opposing all global states, but opposing "global variables" only, which suggest accessing global states with a better method : dependency injection.
Also after reading https://softwareengineering.stackexchange.com/a/450923/432039, I finally understand "unpredictable" actually means "hidden dependency" : when you use global variables:
public float getCost(float price, int quantity){
return UserData.discount*price*quantity;
}
you may not realize UserData.discount is also affecting the output besides price and quantity, it is called "hidden dependency" and that is so called "unpredictable". So modifying it as
public float getCost(UserData userData, float price, int quantity){
return userData.discount*price*quantity;
}
so that all dependencies appear on the parameters and hence I can find all dependencies in easier way.
However, what I don't understand is, why would the answer mentions about "starting state is changed"? Because I think even if "UserData.discount" is never changed, it is still a hidden dependency that affecting the output. Even if "UserData.discount" is never changed after the program starts, it seems wouldn't help me to aware the line of code "UserData.discount*". So I think whether starting states is changed isn't relevant to the drawbacks of global variables. So my question is, why does the answer attribute "unpredictable" to "global state is changed"? Why should I specially care the initial value of the global variable? And even if it is true, why would modifying the initial value through passing parameters (dependency injection) solves the problem? Or am I still misunderstanding the answers (eg: misunderstanding what "starting state" refers to?)?