When we write code we make assumptions on the environment and the correct execution and most importantly obtaining the expecting result strictly depends on it.
I will not touch on software design or testing process, but just focus on an essential foundation that everyone should think to write better code and more efficient. Preventing to revisit code looking for answer the question of why is not working as expected.