Quantcast
Channel: User Filip Milovanović - Software Engineering Stack Exchange
Viewing all articles
Browse latest Browse all 167

Comment by Filip Milovanović on In "disadvantages of global states", what is the relationship between "starting state is changed" and "unpredictable"?

$
0
0
The behavior is not literally unpredictable - if you keep track of all the relevant information. But, that means you'd have to find all the hidden dependencies, and keep track of a myriad of ways these could be changed between calls to your function, making everything evermore complex. And any future code could change global state in a way you haven't accounted for. You want to avoid that - the goal is to be able to think about any function in isolation, without looking outside (if you're changing it), and to trust it'll do what it says it'll do without looking inside (if you're calling it).

Viewing all articles
Browse latest Browse all 167

Trending Articles