Don’t rely on default values

I was creating a mobile app this morning which made heavy use of AJAX calls, heavy enough that caching was necessary to reduce server load.

I use the jQuery $.ajax() method so often that I rarely consider what would happen if one of the default values for a parameter changes in a future release.

For instance, in my current app, I depend on the fact that regular (not jsonp or script) $.ajax() calls will be cached, and providing the cache: true parameter is just adding needless lines lines to my code.

But, what happens if, in a future release, jQuery decides to make cache default to false? Well, my server will certainly see a lot more load! Not to mention the slower response times seen by users.

While it isn't likely that jQuery would make such a change (at least without making it painfully clear in their change logs), this might make you think about other areas of your code which do rely on default values, client or server-side.

Subscribe

  • follow us in feedly


Tagged .

Updated: 2012-10-20

Phil LaNasa