Reputation: 51064
In a project that recently landed on my plate, all client code is enclosed in revealing modules. This is good. All of the module names are prefixed with the '$' character, e.g.
$.acme.global.dataAccess = function () {
var dataAccess = {};
None of these modules seems to be intended as a jQuery plugin, so I can imagine no good reason to do this at all, yet most of this code is well architected and written, so I might be missing something fundamental.
Upvotes: 4
Views: 184
Reputation: 5454
IMO no. It's convenient, sure, because it's easy to type.
For this project, I say continue using it to maintain consistency. But...
The problem I feel is that there is an association between '$' and jquery, so confusion -- such as this -- is bound to arise. And when jquery is in use, you're slapping all of the "acme" stuff onto the "jQuery" object; there's no good reason for this unless it has something to do with jquery. You'd be just fine creating a new namespace. Why not Acme.global.dataAccess
? It's even shorter, and there would be no immediate confusion of whether this module deals with JQuery or not.
TLDR
edit:
CONS
PROS
PLEASE add to list if you've got suggestions, or troll me if you disagree
Upvotes: 2