Search code examples
javascriptextjsextjs4extjs4.2extjs5

Creating a separate component for every item that makes up a parent component?


I was hoping to get some insight about creating new xtypes. I have currently been creating a new xtype for each part the makes up the complete UI component I need but I think I might be over engineering it.

For example, if I need to create a window that houses a form which in turn houses a fieldset I have been creating a separate window (new xtype), a form (new xtype), a fieldset (new xtype) and bring these all together using the Items array.

Now of course this allows me to re-use the form inside another window as it's a separate xtype and also the fieldset can be re-used.

So I was thinking of just creating 1 "xtype" - The window and place all my extra bits using Items and not actually creating separate xtypes for these items. Is this recommended ?

Just right now, I seem to have a minimum of two files (window and the component like a form, grid etc)

My new window xtype is very doesn't really do much, it's pretty empty. It's just adding new xtypes that I created.

I think it comes down create 1 xtype and placing all my necessary component directly inside this file hence I would have 1 window "AddCustomerWindow" or taking the other route where I am having a minimum 2 files (sometimes more) where I would have a AddCustomerWindow, AddCustomerForm, AddCustomerFieldset


Solution

  • IF there is need to re-use the inner items many places then it is fine to create new separated xtype for those. IF they are not resealable then this becomes extra codes / extra files, in this case you can write all items directly in you window.