WebSockets: The Current State of the Most Valuable HTML5 API

Last Tuesday I’ve delivered presentation at Princeton JUG «WebSockets: The Current State of the Most Valuable HTML5 API».
HTML5 specification includes WebSockets, a new communication protocol for the Web. It’s becoming the best choice for building real-time Web applications. I did an overview of the servers (including upcoming JavaEE 7 RI – Glassfish 4) and frameworks that support WebSockets and showed some use cases where WebSockets shine. At the end we had short conversation  about various approaches for the server- and client-side implementations of WebSockets that can be used in the Web applications today.

Viktor Gamov

Avoiding Duplicate Suffixes in Ext JS MVC

One of the most appealing features of Ext JS 4 is the fact that it has all you need to develop your application using the MVC architecture. You don’t need to add any third party MVC framework to your Ext JS application. In your controllers, that you attach to the application, you simply declare the class names for your store and a view. In return, Ext JS generates the controller’s getter methods to access the store and view instances and also allows controllers to intercept events that may happen anywhere inside the views. You are not forced to use MVC, but since it is convenient and does not cost much. I just finished preparing a 100% MVC sample for the upcoming release of the Ext JS version of our Clear Data Builder code generator.

Convention over configuration is the only price you pay for implementing MVC in your application. Just follow the strict folder names – controller, view, store, model. It’s not too expensive, is it? In fact, I like it.

That said, dare you to name a store class as MyApp.store.CustomerStore Ext leaves you one on one with eyebrow-raising controller code like this.getCustomerStoreStore(). In other words, Ext is appending the Store suffix for stores, Model for models and so on, softly suggesting that you should stay away from using your own suffixes.

Now, if you are anything like me, you get an instant acid reflux at multiple classes with the same core name like MyApp.model.x.y.z.Customer, MyApp.store.x.y.z.Customer, and, perhaps, MyApp.controller.x.y.z.Customer and others, especially when you jump between them in one editor. Do not worry – all you need to treat the “condition” is to override the createGetters method of the Ext.app.Controller before your application starts, for instance – this way:

    enabled: true

    function () {
            createGetters: function(type, refs) {
                type = Ext.String.capitalize(type);
                Ext.Array.each(refs, function(ref) {
                    var fn = 'get',
                          parts = ref.split('.'),

                    // Handle namespaced class names. E.g. feed.Add becomes getFeedAddView etc.
                    Ext.Array.each(parts, function(part) {
                        fn += Ext.String.capitalize(part);
                    // --- Prevent StoreStore-like suffixes --- 
                    pos = fn.length - type.length;
                    if (pos<=0 || fn.substring(pos)!==type) {          
                        fn += type;
                    if (!this[fn]) {
                        this[fn] = Ext.Function.pass(this['get' + type], [ref], this);
                    // Execute it right away
            // --- Start your application when done 
                name: 'MyApp',
                controllers: [

To learn more about the proper way of architecting enterprise applications attend our 2 day Flex-to-ExtJs workshop on April 19-20, 2012. Enter Victor as a promo code to get $100 off the price.


UPDATE: See our post Why and How to use Ext JS Overrides that illustrates the most elegant Ext JS overriding technique.