Sencha Touch – Best Practice


Sencha Touch – Best Practice


”;


Basic JavaScript best practice

It is a good practice to keep all JavaScript-related code in a separate js (external JS) file, instead of writing it in the <script> tag under the head section or inline JavaScript in the document body.

Always perform a null check before the element is being used in further logic.

Always follow the naming convention, as it makes the code easy to understand by any other programmer.

To make the code easily understandable, it is always preferred to write comments for JS methods with clear logic behind what a function does.

Best practice specific to Sencha Touch

Use Sencha Touch recommended folder structure, which will be helpful during JS compression or minification.

It is highly recommended to use the listener (onclick/onblur, etc.) in the controller instead of writing it in the html page itself.

Do not create the store instance, when the store is being called from the view.

When we create an instance of a store, we should always destroy it, as it impacts the performance.

While using Sencha Touch, do not specify any other simple JavaScript file. Use all the functions from Ext classes (mentioned in controller or utils).

When the model mapping and the name are same, then do not specify mapping. Only name will solve the purpose.

Do not use unnecessary properties in view. Use only the property which is required and it value which is different from the default value.

Advertisements

”;

Leave a Reply

Your email address will not be published. Required fields are marked *