> Instead of $ (dollar) prefix, you could also _ (underscore) prefix private
> methods. That way you don't have to artificially grow your (public) method
> names with php-like ugliness. I personally use the $ prefix for variables
> returned by libraries like jquery or prototype. To easily distinct those
> from regular dom (or other) vars.
>
> I think the underscore is kind of the js-way, but I don't really have
> anything to back that up so somebody might correct me on the issue :)
>
> Whenever I see $ prefixed vars, and they're not clearly used to distinct var
> contents, I usually suspect a php user. Especially if they don't use `var`
> :p
+1 on the php user (being one I think I can smile at that). I think
for readability it is easier to get rid of the $, and I personally
only use _ (underscore) if the method part of a prototype
(constructor) but I "intend" for it to be thought of as private (even
though it isn't). When using a closure pattern for object creation I
typically return all the public methods at the end making all others
understood to be "private".
e.g.
var Module = (function(){
// private stuff
return {
// public stuff
}
});
Grossly simplified I know but the basic gist.
--
Marc (@wavded)
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]