Developers are slaves of deadlines. In the pressure of doing things on time we make mistakes. Sometimes mistakes made to save few moments cause us loss of hours. Below are two of my such experiences.
First Case Study
Originally the code was like this
if(condition) callFunction(A); else callFunction(B);
Due to some requirements I changed it and in haste forgot to change if on all function usages. Some days later it took me hours to figure out the problem.
if(condition) callFunction(A,newArgument); else callFunction(B);// Forgot to add newArgument
Second Case Study
Originally it was coded in haste like this.
foreach(items as item) item->setValue(complexFunc(0));
The function complexFunc is iterating over the rows from a table. Initially when the data set was small the delay was not significant.
Months later the client started to complain about the delay in script execution. At this point of time the developer who originally wrote the code was unavailable so another developer was assigned the task to optimize the script. Again this developer took hours to understand the requirements, find the bottle neck in the code and fix it.
val = complexFunc(0); // complexFunc is now called once rather can calling it for each time foreach(items as item) item->setValue(val);
I have made such mistakes as well due to pressure of deadlines. However I suppose such types of mistakes can be caught by code reviews. Both by self and by peers. Some time should be alloted before every commit to the repository to do a careful reading of the changes.