I am writing a custom UI builder in js. It uses an implementation of a factory to build elements. To make sure that it was obvious which functions were part of the library versus which were part of plain old javascript I used a naming convention of function _FunctionName()
. However, I find it tedious to always be doing Factory._FunctionName()
.
Should I just remove the naming convention (function FunctionName()
)or stick to it?
Are there naming convention common / best practices with regards to making libraries like this?
edit:
var __PanelFactory = function () {
//"private"
var Panels = [];
//exposed
function _GetPanel(id) {
//etc
}
return {
_GetPanel: _GetPanel,
};
};
var Factory = new __PanelFactory();
Factory. //this will show certain plain javascript functions
//like toString, constructor, hasOwnProperty, isPrototypeOf, etc...
//note that even jQuery can have the previous list used with something like
$(selector).
//So to differentiate I made sure my functions start with _
Factory._GetPanel(1);
//Should I just make it easy on myself and allow
Factory.GetPanel(1);
//Or is there value in leaving the naming convention in?