Loading more classes in one file


It is a bad practice! It is wrong! Do NOT do it like this! It’s evil!

Yet, it is possible.

I’ve recently run into a question: “How would I load more classes in one file?” Of course, my first thought was “Why would you want to? Ext/Touch is not built this way. One class per file is the ideal setup where everything is clean, predictable and understandable.”

But, you know, curious me… First I started to think about technical aspects, “How would I do it if I would want it despite all common sense.” And then, “What could it be useful for?”

Well, the usefulness is really questionable. I might want to load several classes at runtime that I do not want to load initially? Or, I want to check something very fast and I don’t want to generate the whole application? Or, I want to test something and I do not want to pollute the application folder with a number of files that I need to delete afterwards?

So or so, I would definitely not use it as a coding approach. If I ever used it, it would really be only marginally or for testing.

What do you think?

Now technically. How to do it?

I wanted to code model, store and grid all as separate classes with Ext.define() in one file but that file must be accepted when passed to Ext.require() or listed in requires:[] array.

The Solution

If you want to want to see the solution, login or sign-up. Free membership is available.
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)

We will be happy to hear back from you

Please Login to post a comment