ExtJS How to implement code reuse in development (Getting Started tutorial)
What kind of code would you choose if you were to implement the following interface?
Code Listing 1:
Code Listing 2:
Create the object according to the above:
Would you choose that?? It is recommended that you choose the Code 2 method (or refer to one of my other articles for an Ext inheritance example (base class for the components such as dropdown tree, grid, panel, form, etc.)!
Because this can implement code reuse, for example, if you want to make a new, modified form, you may want to copy two copies of the code, which is not conducive to maintenance, if you write in code 2, then just create a new, modified form as follows:
New form:
JS Code
- var addform = new Register.micwin ({
- Title: "New" ,
- buttons: [{text:' save '},{text:' Cancel '}]
- }). Show ();
var addform = new Register.micwin ({ title: "New", buttons: [{text: "Save"},{text: "Cancel"}]}). Show ();
Modify the form:
Java code
- var editform = new Register.micwin ({
- Title: "Modify" ,
- buttons: [{text:' save '},{text:' Cancel '}]
- }). Show ();
var editform = new Register.micwin ({ title: "Modified", buttons: [{text: "Save"},{text: "Cancel"}]}). Show ();
Run: