← Back to context

Comment by tdicola

11 years ago

It can happen accidentally quite easily. Someone new to a codebase starts hacking in a feature and mistypes a variable as 'value' instead of 'values'. They fail to realize there's already a 'value' variable in the global namespace (perhaps it's a gigantic spaghetti code mess of a file). They don't have good test cases that exercise this exact line and fail to see the bug. Code ships to production, three months later the line runs and explodes.

Your example is quite good, although there are far more bulletproof ways than exhaustive test cases to make sure this doesn't happen.