Today learn about the class in Ext4, it is relative to 3 to do a great degree of refactoring, so accustomed to Ext3 people suddenly write 4 code will feel very uncomfortable it.
Ex4 covers more than 200 classes, with tens of thousands of people developing it, and people from all over the world who have different programming backgrounds. So EXT4 development initially, in order to unify the programming style, faced with these several problems:
- This style to make everyone feel very familiar with, and learn easily
- Quick to develop, easy to debug and easy to deploy
- Organizational, extensibility, maintainability is better
JavaScript is a very special language. It cannot be counted as an object-oriented language, it is a weak type of interpretative language based on prototype. So it's flexible, and it can accomplish a task in a variety of ways. But this loosely typed language also poses a big problem, and if we don't organize the code well, it's hard to write a JS script that will make it harder for others to read. EXT4 has put forward a lot of better solutions.
- Naming rules
The first letter of the class name is capitalized, and the Camel name method is used later. and the package name of the package class should be lowercase, as shown below
Mycompany.useful_util. Debug_toolbar i //class name preferably not underlined ; MyCompany.util.Base64 //isacceptable; MyCompany.data.CoolProxy; Mycompany.application; MyCompany.form.action.AutoLoad;
The names of classes should also correspond to their storage locations, such as
Where path/to is the root directory of your application.
- Methods, variables, and properties
Methods and variables also follow the Hump naming method, the initial letter should be lowercase, and the use of underscores is not recommended (maybe I do that often)
, notice how they are named. As for attributes, follow the same naming conventions as variables, just remember that if it is a static property, all uppercase.
2. Practice
Before EXT4, if we wanted to create a class, we would:
var Mywindow = Ext.extend (Object, {...});
Deep learning ExtJS4.2 (2) class system