I had some concepts problems here.
I had to write a search window for each of my tables. This windows will only vary in a combobox contents(name of fields to search for) and grid columns (result).
What´s the best approach in extjs:
- Write a base window and define the combo and grid columns in the children classes.
- Write a different class for each window?
Particularly I prefer the first option, but I´m stucking configure this properties from the child class.
The answer here will probably depend on the amount of reusable code vs. how much of it you need to customize.
You could structure a base class that all others will extend if you can place 70-80% of the common reusable code there. Then each specific class will extend this base class and customize the rest. You can improve the easy of customization by writing a bunch of functions that are called from initComponent to build out your window. Then each subclass will overwrite just the functions that are necessary to distinguish it from the the base.
If the amount of reusable code is much higher like 90%+ you might be better of writing a single class and then pass in individual config overrides during instantiation, like this:
Also, browse through example code, you might find interesting cases of reuse.