What's the coding standard for naming a private method in a language which does not have the private modifier? Specifically, I am talking about Javascript. Below I've placed an underscore at the end of my private method's name, but a colleague told me that underscore is usually for class fields.
var MyClass = Class.create({
initialize: function() {
alert('constructor');
},
publicMethod: function() {
alert('i am public');
},
privateMethod_: function() {
alert('i am private');
}
});
_
for private and__
for Python internal names. You can use_
names, which are simply concealed in a few ways. You should not use__
names because the mangling makes debugging remarkably hard, and it exposes you to the possibility that a future release will interfere with your name. Use_
in Python for "more-or-less private".