What do you say about the code structure below? This is one of the recommended ways of writing JS code in my education.
What is the pros and cons with writing code this way? Can you recommend any better and maybe more elegant ways of writing code?
var DESKTOP = DESKTOP || {};
DESKTOP.Init = DESKTOP.Init || {};
DESKTOP.Windows = DESKTOP.Windows || {};
DESKTOP.desktop = DESKTOP.desktop || {};
DESKTOP.Windows = function(width, height){
this.width = width;
this.height = height;
};
DESKTOP.Windows.prototype.buildWindow = function(){
// code here...
};
DESKTOP.Windows.prototype.showMenu = function(text){
// code here...
};
DESKTOP.Windows.bgChange = function(width, height){
DESKTOP.Windows.call(this, width, height);
this.content = 'the content';
this.title = 'the title'
};
DESKTOP.Windows.bgChange.prototype = new DESKTOP.Windows();
DESKTOP.Windows.bgChange.prototype.loadImages = function(){
// code here...
};
DESKTOP.Desktop = function(){
// code here...
};
and so on...