Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7965277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:06:23+00:00 2026-06-04T06:06:23+00:00

I am writing a custom UI builder in js. It uses an implementation of

  • 0

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?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T06:06:24+00:00Added an answer on June 4, 2026 at 6:06 am

    There is a question already on SO that links to a good document on Javscript coding conventions (including naming):

    • javascript naming conventions
    • http://javascript.crockford.com/code.html

    The key bits you’ve asked about:

    • Use namespaces (with inital-caps names).

    This is somewhat optional, as PanelFactory won’t collide with plain Javascript. It might collide with other libraries if you are making a public API to be consumed by third parties, though:

    var MyApp = MyApp || {};
    MyApp.__PanelFactory = function () { // ...
    
    • Get rid of the underscores (_) before all function names.

    You don’t need the underscores, as people who have been working with JavaScript for a while know the default instance-scoped functions built into every object (toString etc):

    MyApp.PanelFactory = function () {
      // ...
      function GetPanel(id) {
        //etc
      }
    
    • Name object constructor functions with initial-caps names, but name global or namespace-scoped functions and instance-scoped functions with initial-lower-case names:

    This is just a standard convention. It doesn’t help distinguish built-in functions, but as I said in the previous item, you don’t need to.

    MyApp.PanelFactory = function () {
      // ...
      function getPanel(id) {
        //etc
      }
    
    • Name local variables with initial-lower-case names:

    This will help you tell the difference between a namespace, an object constructor, and an instance of an object (where you would expect custom instance-scoped functions, commonly called “methods”, to exist).

    var factory = new MyApp.PanelFactory();
    var panel = factory.getPanel();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As part of writing custom command (COM-Visible dll with class that implements Interwoven command
I'm writing a custom deserializer that will deserialize a list by deserializing each of
I'm writing a custom Ant task that needs to accept a custom nested type.
I'm considering writing a custom IPermission implementation but am not clear as to how
Aside from writing custom code are there any existing features in .NET which allows
Writing a custom validator for a dropdownlist that is using autopostback. Seems to ignore
i have a TableView with custom cells that i have built with Interface Builder.
I need help writing custom functions for my casio fx-9860g I have done this
I'm aware of writing custom attributes that decorate a method and get evaluated before
I am writing a custom ConfigurationElementCollection for a custom ConfigurationHandler in C#.NET 3.5 and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.