View Full Version : Desktop2.0 / extend Module - why?

23 Nov 2007, 12:55 PM
Why do objects in the desktop2.0 sample extend Module?

In preferences.js for example:

MyDesktop.Preferences = Ext.extend(Ext.app.Module, {...

And Module.js is just:

Ext.app.Module = function(config){
Ext.apply(this, config);

Ext.extend(Ext.app.Module, Ext.util.Observable, {
init : Ext.emptyFn

So, is this simple a way design a class and inherit observable? I am trying to figure out WHY this is done in this manner.

Thanks for the insight.

Long live EXT..

23 Nov 2007, 1:19 PM
It's done so that you have a place to put logic that's common to all modules. While you could directly inherit Prefs from Observable, once you did that for 5 different modules and then realized you wanted some common functionality between them, you'd have to modify Observable or extend it to add functionality that your 5 modules could access. Neither of these choices is desirable from a design/maintenance perspective.