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 8138985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:40:55+00:00 2026-06-06T11:40:55+00:00

Disclaimer: I am using ExtJS 3, but I don’t think it’s very relevant to

  • 0

Disclaimer: I am using ExtJS 3, but I don’t think it’s very relevant to the question, outside of the common use of it’s namespacing function.

I have a singleton that’s declared in a really long namespace like this:

Ext.ns("REALLY.REALLY.LONG.NAMESPACE");

var Singleton = (function() {   
    var foo = {
        bar: "baz"
    }; 

    var privateFunction = function(param){
        // ...
        return foo;
    };

    var single = Ext.extend(Object, {
        constructor: function(config) {
            Ext.apply(this, config);
        },
        otherFunction: privateFunction,     
        publicFunction: function (someObject){
            // do stuff with someObject
        }
    });

    return single;

})();
// Make it a singleton
REALLY.REALLY.LONG.NAMESPACE.Singleton = new Singleton();

I use it in other modules via calls like REALLY.REALLY.LONG.NAMESPACE.Singleton.otherFunction(); and REALLY.REALLY.LONG.NAMESPACE.Singleton.publicFunction(myObject); . I’m wondering if I can swap out those calls by setting up the client module with an alias to the singleton, i.e. var singleton = REALLY.REALLY.LONG.NAMESPACE.Singleton; , so that I can call singleton.otherFunction();. I’m wondering if this is an anti-pattern , or if there are any pitfalls (memory?) I might run into through this usage.

Thanks StackOverflow!

  • 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-06T11:40:56+00:00Added an answer on June 6, 2026 at 11:40 am

    I’m wondering if I can swap out those calls by setting up the client module with an alias to the singleton

    Yes, you can.

    I’m wondering if this is an anti-pattern , or if there are any pitfalls (memory?) I might run into through this usage.

    No, there aren’t any that I can think of and it is faster than calling the fully-qualified version.

    Local Alias Pattern


    Example:

    function somefunc(){
        var singleton = REALLY.REALLY.LONG.NAMESPACE.Singleton;
    
        singleton.publicFunction();
    };
    

    Or:

    (function somfunc(singleton){
    
    }(REALLY.REALLY.LONG.NAMESPACE.Singleton));
    

    Test Results:

    http://jsfiddle.net/jMg9A/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question: How can I document Ruby code using Doxygen? Disclaimer: I know ruby already
Disclaimer This is not strictly a programming question, but most programmers soon or later
Disclaimer: I am fairly new to using json. I am trying to use php
Disclaimer: I'm a rails n00b. I'm playing around with a simple helper function that
Disclaimer: this question is driven by my personal curiosity more than an actual need
Disclaimer : I'm quite a novice to RoR, but not with Ruby (if that
Disclaimer: completely new to Python from a PHP background Ok I'm using Python on
Disclaimer: super new to rails. I'm using Rails 3.2 Anyways, I'm trying to create
I'm using a button to slideToggle the display of my disclaimer here, and for
Disclaimer : I'm new to web development. Scenario : I've built an application using

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.