
The Antiviral Effect	 - kyro
http://bemmu.posterous.com/the-antiviral-effect
======
sgrove
Speaks to the danger of building your business on an API that can change at
someone else's whim. Also, the importance of being very thorough in your
testing.

Still, I'm glad you were able to catch it in time and reverse the trend.

~~~
bemmu
It was a mistake on my part, the API itself didn't change in any unreasonable
way (I shouldn't assume that array prototypes have no extra members). A lot of
revenue was lost, but my feeling about it now is mostly relief, as I wasn't
sure if I'd ever find the cause.

~~~
10ren
I think you're showing your true hacker colours because you also seem excited
about understanding the bug for its own sake. :-) I would be too.

BTW: I actually think an array changing its behaviour _is_ an unreasonable
change - for languages like C and Java - but a reasonable one for dynamic
languages. It reminds me of a comment someone made about the "C# and Java
Weekday Languages, Python and Ruby For Weekends?", that C#/Java are less fun
to code in, but more fun to maintain, and the same features are responsible
for both effects.

[http://tech.slashdot.org/comments.pl?sid=1337483&cid=290...](http://tech.slashdot.org/comments.pl?sid=1337483&cid=29077809)

------
snprbob86
Ouch. That really sucks. I'm glad you figured it out.

I wonder what you could have done to find the bug before it was a serious
problem? Most server side errors are easy because you can configure alert
emails. Subtle data corruption or client side bugs are much harder to pin
point as they manifest much further down the pipe in unintuitive ways.

Subtle data corruption bugs aside, is there someway to handle client side
bugs? I'm no Javascript expert, but I'd imagine there has got to be a way to
register a global on-error handler and post bug reports to the server? Any
expert insight here?

~~~
warfangle
He could have run it through JSLint. It catches not wrapping the body of a
for-in block in a hasOwnProperty conditional.

Example:

var arr = [0,1,2,3,4,5]; for(var p in arr) { console.log(arr[p]); }
Array.prototype.foo = "bar"; for(var p in arr) { if(arr.hasOwnProperty(p)) {
console.log(arr[p]); } } for(var p in arr) { console.log(arr[p]); }

If you run this in firebug's console, you'll notice that the first two loops
work as expected, even after changing the prototype of the Array object. The
third one, however, will spit out "bar" as well.

JSLint can be mean to your code, but it helps catch an enormous amount of
small bugs like this caused by JS's warts.

