PDA

View Full Version : What is the consequence of Overnesting?



profunctional
20 Jul 2010, 12:33 PM
I've seen the term "overnesting" thrown around on the forum. At a high-level, I know that it means nesting items. But what are the consequences with regard to performance/overhead/efficiency?

I am finding that I'm doing a lot of:

myForm.getComponent('nestedField1').getComponent('nestedField2').

etc.

Is this bad practice?

Animal
20 Jul 2010, 12:44 PM
The main problem is lack of consideration of which layout manager the Container uses to size it child(ren)

Omit the layout config as is often done, and no sizing is performed.

That is what causes problems.

Obviously though, for efficiency's sake, nesting depth should be kept as shallow as possible.

evant
20 Jul 2010, 5:45 PM
Overnesting refers to nesting ~without~ reason. For example:



new Ext.TabPanel({
fullscreen: true,
items: {
title: 'Foo',
items: {
// This panel here is totally redundant and has no layout
items: {
html: 'Foo'
}
}
}
});


Overnesting, without reason is bad practice, for several reasons:

1) You're creating extra markup where it's not necessary (performance)
2) You're creating extra complexity in your code (maintenance)
3) It you do so incorrectly, it can cause your layouts to not display correctly (functionality).