views:

12

answers:

1

Hi,

I'm developing a JavaScript API which would work in a similar way as e.g. Google Analytics (GA) tracking code. Because they already thought of a nice structure, I would hate having to re-invent variable and methods names for the client.

Where GA would use:

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxx-x']);
_gaq.push(['_trackPageview']);

I would do something like:

var _myapp = _myapp || [];
_myapp.push(['_setAccountId', '12345']);
_myapp.push(['_trackPageview']);

I'm guessing push shouldn't be a problem since it's a native javascript method. But should I consider using different variable names? Besides using _setAccountId and _trackPageview, I would use a number of other variable names (_trackEvent, _setDomainName, and so on)

This will only be needed for the client code for the users, the actual javascript file handling the requests will be build without reusing anything from Google.

Should I be concerned?

+1  A: 

No, there's nothing to worry about. It's the code within the GA methods that would fall under intellectual property protection, not the names of the methods themselves.

If method/variable names counted as intellectual property we'd have run out a long time ago and all new API's would have to use random character strings to name their API functions!

Having said that, be careful with global variables (keep them in your own namespace)—it's entirely possible that someone might be using your API and Google Analytics in the same scope.

Mark B
That's what I thought :) The API will be contained with the _myapp variable (renamed of course). So naming collision shouldn't be a problem. I'll leave the question open for a bit, to see if anyone else have any comments.
Mads Jensen