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

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






Although placing those Items within items sure will get a little untidy. Maybe I could implement Ext.Apply .... in the InitComponent and some funcitons that return each part for example, "getForm", "getFormFields", "getButtons" etc -- Good option ?

– Martin
Oct 20 '15 at 6:57






I suppose you mean by new xtype - new class. Create separate classes only for reusable components, if you have form, that will be used only in one view, then it is bad practice to create separate class. Try to use xtypes(of self-created components or extjs-native) where it is possible - it will have positive influence on performance, while component will be actually created only when it will be needed

– yorlin
Oct 20 '15 at 7:53






There's no right or wrong answer. Do whatever "makes sense" for your project. You don't want to have massive configurations objects under a single class, but you probably also don't want to create a new subclass for every component you use. Balance it as you see fit.

– Evan Trimboli
Oct 20 '15 at 8:34




1 Answer
1



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.






Actually you can write classes in separate files and re-use them without any xtype. The main feature of xtype is lazy object creation. So the component added to the view over xtype will be instantiated only when it will be needed. It will help to improve the performance of the application. So the correct answer will be: If you need to re-use some components, place them in separate classes and if you need to create them lazily, then provide xtype.

– yorlin
Oct 20 '15 at 7:46






Thanks for the comments everyone. I will now start using 1 file unless i need to re-use

– Martin
Oct 20 '15 at 9:48



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

How do I collapse sections of code in Visual Studio Code for Windows?

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ