我在js 中写下自定义 UI 构建器。 它使用工厂的安装来构建元素。 要确定什么功能是图书馆的一部分, 与什么功能是普通旧的 javascript I 的一部分, 我使用了一个命名公约 < code> 函数_ functionName () code > 。 然而, 我发现总是在做 < code> Factory._ FunctionName () 。
我是否应该删除命名公约 ( conference 函数Name ()
) 或坚持它?
在使图书馆成这样方面是否有命名公约的共同/最佳做法?
编辑 :
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?