Deep learning ExtJS4.2 (2) class system

Source: Internet
Author: User

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.

    1. Naming rules
    • Class

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;
    • SourceFile source File

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

    • Statement

Before EXT4, if we wanted to create a class, we would:

var Mywindow = Ext.extend (Object, {...});

Deep learning ExtJS4.2 (2) class system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.