Let Us Fail Silently

Or Screw the Programmer, We Are Google

It’s been too long since I last worked with the google maps API. Today I was working with it again, and I got a bit lost because some things have changed since I last worked with it. Not so much as the api, but the set up for working with it. Google now has an API console, and it was a bit new for me. But that was not a problem. Google always makes it hard to get started, but easy the get used to.

My complain today has to do with the way they fail to let you know what went wrong. I spent 30 minutes trying to find out what was wrong with my code only to realize that I had misspelled the word zoom in the options passed to the maps constructor function.

The fix was quick once I discovered the error, just spell the word right! But I can’t help to feel like something could have been done to save me those 30 minutes. First of all, why does it even fail? And why does it do it silently?

Well, apparently maps needs to know the zoom at which you want it to be displayed. This means, that if no zoom is specified, the map will simply not show. But why not let the programmer know? They do display an ugly alert if you use a non-valid api key, why not in other cases as well?

To be fair, the problem could have been caught earlier, but since I hadn’t worked maps for a while, my initial assumption was that something had changed, and that I didn’t know about it. Maybe I had to call some method of the Map object in order for it to display. Or maybe it was something else.

I paid close attention to the values of the options defined, but not to the option names. I guess you could say I should have, but then again, I could argue that there should be meaningful debug messages in the API. And what about default options?

As developers we ought to make sure we implement meaningful debug messages to out libraries and apis. It is useful for us, and for other who use our code. When something is required, and not provided, your api/library should complain about it. Throw a freaking error/exception or at least log an error to the console, or even do an f-ing alert, but don’t just fail silently without any indication of what went wrong.