Factory Function File Pattern

Code in this post can be obsolete, however, principles and theory may still apply.
You know, I’m not very big fan of factory functions, nevertheless, I’m aware of the fact that they may be necessary in some situations. Here is the file pattern that works (briefly tested).

Keep each factory function in a separate file name of which should be Namespace.Factory.functionName.js

Share on FacebookTweet about this on TwitterShare on LinkedInShare on Google+Pin on PinterestEmail this to someone
Follow me:


I'm a well seasoned developer, consultant and educator of web applications based mainly on Sencha libraries, PHP, MySQL and Node.js. Besides (Apple) computers, I love photography and mountain biking.
Follow me:

Latest posts by Saki (see all)


  1. ckr says

    Saki – a question here.

    Ext.apply({}, config, defaults);

    Does that apply in order? Meaning, if I wanted to override some of my defaults, would I not want to reverse config and defaults?

    Ext.apply({}, defaults, config);

    Thanks for putting this together!!

  2. says

    You can think about it like this:

    – defaults are applied first
    – then config

    So, if property1=”John” in defaults and property1=”Mary” in config the target will result in having property1=”Mary”.

We will be happy to hear back from you

Please Login to post a comment