Search code examples
extjsextjs4extjs4.2

Handling misstyped file references in ExtJS 4


I am using "Mastering Ext JS 4" book to learn Ext JS 4. All in all it is going well and I found solutions to most of the problems. My question is, how to prevent errors with using mistyped names of models/view/controllers.

For example here is my controller

Ext.define('MyAppName.controller.MyController', {
     extend: 'Ext.app.Controller',

     requires:[
        'Packt.util.MD5',
        'Packt.util.Util',
        'Packt.util.SessionMonitor'
     ],

     init: function(){
         // controller stuff here
     }
});

It uses file called MD5.js which is located in my application "app" folder and in subfolder called util.

While building my test application I managed to mistype name of views, models stores and then I had to search for the error in files.

For example what if I missed to write one letter like this:

 requires:[
    'Pack.util.MD5',
    'Packt.util.Util',
    'Packt.util.SessionMonitor'
],

Firebug will notify my about missing file located in application folder called 'Pack' which doesn't exist.

Should I create a separate js file where I will give short names to the strings 'Packt.util.MD5', 'Packt.util.Util', 'Packt.util.SessionMonitor' for easier access?

Or is there some more neat ExtJS 4 method to solve this issue and prevent mistype errors?


Solution

  • Well, no automation would save you from all typos, unfortunately. But for shorter names you can give your classes alternateClassName. For example, Packt.util.MD5 can have alternate class name Packt.MD5.