Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #1
    Sencha - Community Support Team mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    2,711
    Vote Rating
    104
    mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all

      1  

    Default Dealing with Ext JS overrides

    Dealing with Ext JS overrides


    As we're finalizing a major refactoring of the Scheduler component to support Ext JS 4.2, I wrote down some of my thoughts about overrides in a blog post.

    http://www.bryntum.com/blog/road-to-...2-2-overrides/

  2. #2
    Ext JS Premium Member westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    835
    Vote Rating
    38
    westy is a jewel in the rough westy is a jewel in the rough westy is a jewel in the rough

      0  

    Default


    Posted this in the blog, but didn't come out especially well...
    ------------------------------------------------------------------------------

    Hey Mats,

    It's a pain yeah, and especially when you upgrade your Ext version as you point out...

    Currently I'm using the callback from Ext.define to log a warning if it's not been checked since a particular version, so can quickly be spotted when the Ext version changes.
    I also use the same function where we have methods in our versions of components that duplicates parts of the Ext framework, but not necessarily to fix bugs, but to add or change behaviour...

    An example:
    Code:
    Ext.define('Altus.overrides.LoadMask', {
        override: 'Ext.LoadMask',
    
        /**
         * Fix for issue reported here: http://www.sencha.com/forum/showthread.php?252789-4.1.3-LoadMask.setZIndex-can-exception-in-IE8
         */
        setZIndex: function(index) {
            var me = this,
                owner = me.activeOwner,
                ownerZIndex;
    
            if (owner) {
                // it seems silly to add 1 to have it subtracted in the call below,
                // but this allows the x-mask el to have the correct z-index (same as the component)
                // so instead of directly changing the zIndexStack just get the z-index of the owner comp
                // <Westyfix>
                ownerZIndex = parseInt(owner.el.getStyle('zIndex'), 10);
                if (!isNaN(ownerZIndex)) {
                    index = ownerZIndex + 1;
                }
                // </Westyfix>
            }
    
            me.getMaskEl().setStyle('zIndex', index - 1);
            return me.mixins.floating.setZIndex.apply(me, arguments);
        }
    },
    function() {
        // <debug>
        Altus.warnIfExtVersionUpdated('4.1.3');
        // </debug>
    });
    Where:
    Code:
        /**
         * Function that logs a warning in the console if the lastCheckedVersion of a function
         * is less than the current Extx version.
         * Should be wrapped in &lt;debug&gt; tags.
         * @param  {String|Number} lastCheckedVersion The version to check against the current Ext version.
         * @param  {Function} func The function that we are being called from.
         */
        Altus.warnIfExtVersionUpdated = function(lastCheckedVersion) {
            var currentExtVersion = Ext.getVersion('extjs');
            if (!currentExtVersion.match(lastCheckedVersion)) {
                Altus.Logging.warn(arguments.callee.caller,
                                   'Method is an override that duplicates code in the framework, so needs checking.',
                                   'Last checked version: ' + lastCheckedVersion,
                                   'Current version: ' + currentExtVersion);
            }
        };
    Cheers,
    Westy


    Edit: Gah, having issues with formatting here now!!
    Product Architect
    Altus Ltd.

  3. #3
    Sencha - Community Support Team mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    2,711
    Vote Rating
    104
    mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all

      1  

    Default


    Hey, that's a good idea. We used a similar approach when we had global overrides in the Component (we now avoid them completely), and we had tests for each override and have the testing framework warn us.

    Siesta code:

    Code:
    t.knownBugIn('4.1.0', function(t) {
          t.ok(treeStore.getNodeById(4), 'New record appeared')
    });
    So when we update the test suite is later run against 4.1.1, the test will fail and action is required. How do you deal with overriding private methods? That's our current head ache. I was able to plug in the symbols from JsDuck, which tells me what I need to know - if I'm overriding private methods (can happen by accident too if you're unlucky with your method name picking )

    Code:
    StartTest(function (t) {
        t.expectGlobal('Docs'); // JsDuck
    
        // Ignore some symbols that should be ignore + some bugs in the Ext docs
        var ignoreRe = /Ext.dd|DragZone.destroy|DragDrop.destroy|DragSource.destroy|Ext.grid.plugin.Editing.init|afterRender|initComponent|Ext.Base.configClass|Ext.Base.destroy/;
    
        var isPrivate = function(fullName) {
            var priv = false;
    
            Ext.Array.each(Docs.data.search, function(property) {
    
                if (property.fullName === fullName){
                    priv = property.meta.private;
                    return false;
                }
            });
    
            return priv;
        };
    
    
        function findInSuperClasses(sourceCls, property) {
            var cls = sourceCls.superclass.self;
    
            while (cls && cls.prototype) {
                var name = Ext.ClassManager.getName(cls);
                var fullName = name + '.' + property;
    
                if (name.match(/^Ext./) &&
                    !ignoreRe.test(fullName) &&
                    cls.prototype.hasOwnProperty(property))
                {
                    if (isPrivate(fullName)) {
                        return name;
                    } else {
                        return false;
                    }
                }
                cls = cls.superclass && cls.superclass.self;
            }
    
            return false;
        }
    
        var MAX_NBR_OVERRIDES = 10;
        var nbrFound = 0;
    
        Ext.iterate(Ext.ClassManager.classes, function (className, constr) {
            if (!className.match('Sch.')) return;
    
            for (var o in constr.prototype) {
    
                // Check only own properties, and only functions for now
                if (constr.prototype.hasOwnProperty(o) && typeof constr.prototype[o] === 'function') {
                    var result = findInSuperClasses(constr, o);
    
                    if (result) {
                        t.todo(function(t) {
                            t.fail('Class ' + className + ' overrides ' + result + ':' + o);
                        })
                        nbrFound++;
                    }
                }
            }
        });
    
        t.isLessOrEqual(nbrFound, MAX_NBR_OVERRIDES, 'Should not introduce new overrides of private methods');
    })

  4. #4
    Ext JS Premium Member westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    835
    Vote Rating
    38
    westy is a jewel in the rough westy is a jewel in the rough westy is a jewel in the rough

      0  

    Default


    Thanks, seems to work well enough for our needs.

    Whilst we know the value of unit testing we are unlikely to be given the green light for writing them for our JS codebase unfortunately, but have got burnt too many times now to not do something to spot potential issues earlier

    Quote Originally Posted by mankz View Post
    How do you deal with overriding private methods? That's our current head ache.
    It's a tricky issue since often obscure bugs or behaviour in the Ext codebase are in the private "hidden" methods, so overriding them is unavoidable sometimes, unfortunately.
    Saying that, we try and avoid it where possible since it's bound to come back and bite us one day.

    When we do I use the above function either in the override, if purely an Ext bug fix, or at the start of the overriding function, if a change of behaviour in one of our base classes.


    Looking at your code, there may be something more clever we could do at runtime to automatically produce some warnings when we've overridden a private method. I've certainly done so accidently in the past due to a fluke name choice for a handler clashing. Be careful using on[EventName] without checking

    Whether the computation effort would be worth it is another question though; we're still pretty stuck with IE7 here, so try and avoid client-side heavy-lifting where possible.

    Quote Originally Posted by mankz View Post
    I was able to plug in the symbols from JsDuck, which tells me what I need to know - if I'm overriding private methods (can happen by accident too if you're unlucky with your method name picking )
    Yeah, I saw your docs bug and salute you!
    I have a very pressing need for a particular private method to be made more official, onClassExtended, since it enables us to do some useful things promoting more code reuse, and save us some potentially expensive headaches.

    I rolled its use into our base Window class, but can see a few more places I'd like to use it, and am nervous in case it disappears, gets its interface changed, or gets some use elsewhere in the framework that I end up hiding...


    Interesting topic.
    Any thoughts from Sencha I wonder? Not seen many devs for a while I must say...

    Cheers,
    Westy
    Product Architect
    Altus Ltd.

Thread Participants: 1