PDA

View Full Version : Class extension pattern



zeruyo
18 Dec 2010, 12:18 AM
Hi, I don't know if this has been already discussed in the forum or is something obvious, but I would like to put under your judgement this type of pattern to create extension of base classes to promote encapsulation and use of private methods:



Ext.ux.MyFormPanel = Ext.extend
(
Ext.form.FormPanel,
(function()
{
var _myVariable = "";

var _doSomethingPrivate = function()
{
};

return {

initComponent:function()
{
_doSomethingPrivate.apply(this);
Ext.ux.MyFormPanel.superclass.initComponent.apply(this, arguments);
},

getMyVariable:function()
{
return _myVariable;
},

setMyVariable:function(s)
{
_myVariable = s;
},

myOtherPublicMethod:function()
{
}
}
}());
);


Thanks.