SlideShare a Scribd company logo
Guidelines and Best
Practices for Sencha
Projects
Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd.
• Performance Guidelines
• General Guidelines
• Documentation Guidelines
• View Models and Data Binding
• Lifecycle Guidelines
- New Operator
- Controllers & Views
• Logging and Tracing
• Form Validation and Submission
• Scope
Agenda
2
Performance Guidelines
3
Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd.
Avoid Using doLayout()/updateLayout():
If at all there is a need, use suspendLayout flag.
• / /Turn the suspendLayout flag on
• containerPanel.suspendLayout: true
• // Trigger a layout.
• containerPanel.resumeLayouts();
• containerPanel.updateLayout();
Copyright © 2008 Walking Tree Consultancy Services . All rights reserved.
F 300 F F
500
suspendLayouts()
height
width
zindex
display
resumeLayouts(flushlayouts true/false)
updateLayout()
Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd.
Effective use of event listeners :
Inefficient use slows down the application performance. For example:
listeners: {
load: {
fn: onFirstLoadData,
single: true
}
}
Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd.
Avoid Over nesting :
It unnecessarily increases DOM Size and might lead to layout issues.
Replace Panels with Containers :
Ext JS Panels are more powerful (and expensive!) than basic containers.
Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd.
Initial Page Load :
• <script src="filename.js"> tags should be placed as late in the body as
possible
• Make use of Ext JS “requires”
• Do not use Ext.require()
Event bubbling is a costly operation :
So handle it carefully.
Copyright © 2008 Walking Tree Consultancy Services . All rights reserved.
1
2
3 Handler for handleParent event. return false.
4
5. this.enableBubble(‘handleparent’);
fireEvent(‘handleparent’);
Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd.
Example:
xtype: 'button',
handler: function() {
this.enableBubble('MoreClicked');
this.fireEvent('MoreClicked', this);
}
Copyright © 2008 Walking Tree Consultancy Services . All rights reserved.
Suspend and Resume events :
While manipulating bulk Dom elements of a component or bulk store records
or bulk array objects, suspend events to avoid multiple event execution,
nested layout executions and recursive DOM manipulation.
For example,
INCORRECT CORRECT
Copyright © 2008 Walking Tree Consultancy Services . All rights reserved.
Performance Factors In Loops :
• Declaration of functions (and for that matter, other re-usable things) inside loops
wastes processing time, memory, and garbage collection cycles
INCORRECT CORRECT
• Calculate array length only once upfront and assign its value to a variable
Copyright © 2008 Walking Tree Consultancy Services . All rights reserved.
Regular Expression:
• Store regular expressions in a variable
• Always add comments
INCORRECT CORRECT
• Cache literal Regular Expressions in a more permanent way
INCORRECT CORRECT
General Guidelines
14
Copyright © 2008 Walking Tree Consultancy Services . All rights reserved.
• Do not use Ext.apply () if recursive merging and cloning without referencing
the original objects / arrays is needed. Use Ext.Object.merge instead.
• Avoid hard coding of id property. Alternatively, use “itemId”.
• Avoid hard coding of height and width.
• If using a storeId, use fully qualified store class name as the storeId (e.g.
storeId : ‘MyApp.store.Businesses’).
• Specify font size as "em" or "%".
Localization and Internationalization:
• All static text should be defined in a separate file by keeping localization in
perspective.
Documentation
Guidelines
16
Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd.
Code documentation must be done using JSDuck annotations. Following are
the minimal documentation requirement:
• Every class must be documented
• Every public and protected property of a class must be documented along
with an example value. Document must indicate whether the property is
mandatory or optional. Default value must be specified for the optional
properties.
• Every public and protected method of a class must be documented
• Events fired by a class must be documented along with the parameters that
will be passed to a listener
JSDuck document must be generated from the documented code.
https://github.com/senchalabs/jsduck/wiki
View Models and Data Binding
18
Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd.
• Preferred syntax for configuring a View Model.
viewModel : {
type: ‘app-main’
}
• Prefer using declarations over procedural calls. For example:
stores: {
businesses: {
model : ‘MyApp.model.Business’,
autoLoad : true
}
}
Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd.
• Preferably, bind properties in the view class declaration itself rather than
binding procedurally
• Don’t create child View Models unless they are actually needed.
• For derived variables, use formulas
• Use formulas instead of repeating binds. For example,
one formula with 3 dependencies and 4 users make 3 + 4 = 7 dependencies
to track in the ViewModel. Compared to 4 users with those 3 dependencies
on themselves we would have 3 * 4 = 12 dependencies. Fewer
dependencies to track means less memory used and time to process them.
Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd.
• Use “deep:true” while binding config with an object / property embedded
inside another object. For example, if this is the object
detail : {
name : ‘Rohit’,
address : {
state : ‘Telangana’,
city: ‘Hyderabad’
}
}
To be notified of changes in the address object, use the following syntax:
bind : {
data : {
bindTo : ‘{detail}’,
deep: true
}
Lifecycle Guide Lines
22
Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd.
New Operator :
• Use {} instead of new Object()
• Use [] instead of new Array()
• For Ext JS objects, you should use the create() method
• For dates related objects, you still require to use new
Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd.
Views and View Controllers:
• Views have the following lifecycle methods:
1. constructor
2. initComponent
• View Controllers have the following 3 lifecycle methods :
1. beforeInit
2. init
3. initViewModel
Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd.
When combined, the view and controller lifecycle methods are executed in
following order
1. constructor of View
2. beforeInit of Controller
3. initComponent of View
4. init of Controller
5. initViewModel of Controller
Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd.
Dom Updates In Component LifeCycle:
• Changing elements after DOM elements are rendered causes reflows,
resulting in slowing down of the application. Write code that avoids DOM
read/writes.
• If required, add CSS classes and set styles in beforerender event handler
rather than afterrender.
• For some code, we may need to acquire the element size. If this is the case,
then consider handling the ‘boxready’ event. For example:
if ( height of element > 100px ) {
//do something
}
Logging & Tracing
27
Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd.
Tracing :
• Use Ext.getDisplayName(). For example:
throw new Error('['+ Ext.getDisplayName(arguments.callee) +'] Some message
here');
• Check call stack.
Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd.
Logging :
• Use Ext.log compared to console.log. If console is present, it will be used. In
other cases, the message is logged to an array:
"Ext.log.out“
An attached debugger can watch this array and view the log. The log buffer is
limited to a maximum of "Ext.log.max" entries (defaults to 250).
• Debugging statements like console.log() and debugger should never be shipped
into standard production environments.
INCORRECT CORRECT
Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd.
• Use the <debug> tag.
• Ext JS 5.x provides “debugHooks” config for a class, through which you can
write debugging statements.
Form Validation & Submission
31
Copyright © 2008 Walking Tree Consultancy Services . All rights reserved.
• Use models for validating and submitting the forms and push the field
validation logic (including custom validations) inside models.
• Use loadRecord method of the FormPanel.
• Instead of using explicit logic to enable / disable a submit button, make use of
“formBind: true”.
Scope
33
Copyright © 2008 Walking Tree Consultancy Services . All rights reserved.
Global Variables:
• Variables declared outside a function are considered in global scope –
irrespective of the usage of “var” keyword.
• These variables are in global “window” namespace. For example, the
following are same:
var gCompanyName = “Walking Tree”;
window.companyName = “Walking Tree”; //more explicit
• If you want to define global variables then use them inside application
namespace. For example:
Ext.define( ‘MyApp.util.Constants’,{
singleton : true,
ANIMATION_Time : 100,
// more variables and methods
});
Copyright © 2008 Walking Tree Consultancy Services . All rights reserved.
• Consider saving the “this” scope into a different (and smaller) name (e.g.
me). For example,
Ext.define(‘MyApp.view.MyPanel’,{
initComponent : function () {
var me=this;
me.add () {
xtype : ‘button’,
handler: function () {
this.getHeight();
me.getTitle();
}
me.callParent( arguments );
}
});
Copyright © 2008 Walking Tree Consultancy Services . All rights reserved.
Upcoming Online Training On Best Practices and Coding
Guidelines on:
28th Nov’, 2015
For details contact:
Ratan Agarwal
cel: +91 95 81400033
Thank You
37

More Related Content

PDF
Introduction to ExtJs 5
PPT
CSS Frameworks: Faster Layout, Consistent Results
PPTX
Sencha ExtJs Learning Part 2 - MVC And MVVM Architecture in ExtJs [ENGLISH]
PPTX
Hari kantin
PPTX
Contents page analysis
 
PDF
LLAMADO PARA ARRENDAMIENTO
PDF
Municipal Perspectives for Renewable Energy Adoption_Barnes
ODP
Pablo valbuena
Introduction to ExtJs 5
CSS Frameworks: Faster Layout, Consistent Results
Sencha ExtJs Learning Part 2 - MVC And MVVM Architecture in ExtJs [ENGLISH]
Hari kantin
Contents page analysis
 
LLAMADO PARA ARRENDAMIENTO
Municipal Perspectives for Renewable Energy Adoption_Barnes
Pablo valbuena

Viewers also liked (14)

PDF
Ts 590 s-usb_audio_settings_manual
PPTX
Analisa sinyal kecil
PDF
Pubudu_Silva_Parallel-Universe-Issue-27
PDF
SANJAY_ALAHAM_Resume_01.08.16
PPTX
Chapter 1 - A Historical Overview
PDF
CARA - Coding Dojo TDD & Open Closed Principle
PPTX
Peptic ulcer
PPTX
Google Traffic Tips, Tactics and Strategies
PDF
LLAMADO PARA ARRENDAMIENTO
PPTX
Possibilities for magazine.
 
PPS
Fsm Operations on Nigeria map
PDF
Presentacion aconcagua saia 2
PPTX
Què és Periscope i com utilitzar-lo?
Ts 590 s-usb_audio_settings_manual
Analisa sinyal kecil
Pubudu_Silva_Parallel-Universe-Issue-27
SANJAY_ALAHAM_Resume_01.08.16
Chapter 1 - A Historical Overview
CARA - Coding Dojo TDD & Open Closed Principle
Peptic ulcer
Google Traffic Tips, Tactics and Strategies
LLAMADO PARA ARRENDAMIENTO
Possibilities for magazine.
 
Fsm Operations on Nigeria map
Presentacion aconcagua saia 2
Què és Periscope i com utilitzar-lo?
Ad

Similar to Guidelines and Best Practices for Sencha Projects (20)

PDF
O365Con18 - Using ARM Templates to Deploy Solutions on Azure - Kevin Timmermann
PPTX
Grails Services
PDF
Upcoming changes in MySQL 5.7
PPTX
9781337102087 ppt ch13
PPTX
.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design
PPTX
SF Architect Interview questions v1.3.pptx
PPTX
Java springboot microservice - Accenture Technology Meetup
PDF
Overview of the AngularJS framework
PPTX
AZ-900T00 Microsoft Azure Fundamentals-06 (pricing and spt)_FINAL.pptx
PDF
Virtual Meetup: Mule 4 Error Handling and Logging
PPTX
Webinar - Building Custom Extensions With AppDynamics
PPTX
Tips for Developing and Testing IBM HATS Applications
PPTX
The Flink - Apache Bigtop integration
PPT
7\9 SSIS 2008R2_Training - Script Task
PDF
Presentation v mware roi tco calculator
PPTX
Play with azure functions
PPTX
Joget Workflow v6 Training Slides - 13 - Improving your Form Design and Prese...
PPTX
Custom Controllers and Controller Extensions
PPTX
9781337102087 ppt ch12
PPTX
Serverless patterns
O365Con18 - Using ARM Templates to Deploy Solutions on Azure - Kevin Timmermann
Grails Services
Upcoming changes in MySQL 5.7
9781337102087 ppt ch13
.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design
SF Architect Interview questions v1.3.pptx
Java springboot microservice - Accenture Technology Meetup
Overview of the AngularJS framework
AZ-900T00 Microsoft Azure Fundamentals-06 (pricing and spt)_FINAL.pptx
Virtual Meetup: Mule 4 Error Handling and Logging
Webinar - Building Custom Extensions With AppDynamics
Tips for Developing and Testing IBM HATS Applications
The Flink - Apache Bigtop integration
7\9 SSIS 2008R2_Training - Script Task
Presentation v mware roi tco calculator
Play with azure functions
Joget Workflow v6 Training Slides - 13 - Improving your Form Design and Prese...
Custom Controllers and Controller Extensions
9781337102087 ppt ch12
Serverless patterns
Ad

Recently uploaded (20)

PDF
SEO Checklist for a Website Redesign Project
PPTX
Turn ideas into stunning timelines in seconds—powered by smart AI: AI Timelin...
PPTX
History of interior design- european and american styles.pptx
PDF
Wio LTE JP Version v1.3b- 4G, Cat.1, Espruino Compatible\202001935, PCBA;Wio ...
PPTX
Riverfront Development maharashtra nagpur
PPTX
Wisp Textiles: Where Comfort Meets Everyday Style
DOCX
algorithm desgin technologycsecsecsecsecse
DOCX
The story of the first moon landing.docx
PPTX
Simple Business Pitch · SlidesMania 13.pptx
PPTX
knee & Ankle Joint Mobilization techniques.pptx
PDF
The Advantages of Working With a Design-Build Studio
DOCX
Personalized Jewellery Guide: Engraved Rings, Initial Necklaces & Birthstones...
PDF
Trusted Executive Protection Services in Ontario — Discreet & Professional.pdf
PPTX
Basic of Product Design in Architecture.pptx
PPTX
503ea471-f798-4324-90e8-275bdab41942.pptx
PPTX
Fundamental Principles of Visual Graphic Design.pptx
PDF
solar design by every detail p.d.f download
PPTX
Riverfront Development_nashikcity_landscape
DOCX
actividad 20% informatica microsoft project
PPTX
TLE-10-PPTHAJAOSBDJDEKSNbknbtktktmktkttk
SEO Checklist for a Website Redesign Project
Turn ideas into stunning timelines in seconds—powered by smart AI: AI Timelin...
History of interior design- european and american styles.pptx
Wio LTE JP Version v1.3b- 4G, Cat.1, Espruino Compatible\202001935, PCBA;Wio ...
Riverfront Development maharashtra nagpur
Wisp Textiles: Where Comfort Meets Everyday Style
algorithm desgin technologycsecsecsecsecse
The story of the first moon landing.docx
Simple Business Pitch · SlidesMania 13.pptx
knee & Ankle Joint Mobilization techniques.pptx
The Advantages of Working With a Design-Build Studio
Personalized Jewellery Guide: Engraved Rings, Initial Necklaces & Birthstones...
Trusted Executive Protection Services in Ontario — Discreet & Professional.pdf
Basic of Product Design in Architecture.pptx
503ea471-f798-4324-90e8-275bdab41942.pptx
Fundamental Principles of Visual Graphic Design.pptx
solar design by every detail p.d.f download
Riverfront Development_nashikcity_landscape
actividad 20% informatica microsoft project
TLE-10-PPTHAJAOSBDJDEKSNbknbtktktmktkttk

Guidelines and Best Practices for Sencha Projects

  • 1. Guidelines and Best Practices for Sencha Projects
  • 2. Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd. • Performance Guidelines • General Guidelines • Documentation Guidelines • View Models and Data Binding • Lifecycle Guidelines - New Operator - Controllers & Views • Logging and Tracing • Form Validation and Submission • Scope Agenda 2
  • 4. Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd. Avoid Using doLayout()/updateLayout(): If at all there is a need, use suspendLayout flag. • / /Turn the suspendLayout flag on • containerPanel.suspendLayout: true • // Trigger a layout. • containerPanel.resumeLayouts(); • containerPanel.updateLayout();
  • 5. Copyright © 2008 Walking Tree Consultancy Services . All rights reserved. F 300 F F 500 suspendLayouts() height width zindex display resumeLayouts(flushlayouts true/false) updateLayout()
  • 6. Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd. Effective use of event listeners : Inefficient use slows down the application performance. For example: listeners: { load: { fn: onFirstLoadData, single: true } }
  • 7. Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd. Avoid Over nesting : It unnecessarily increases DOM Size and might lead to layout issues. Replace Panels with Containers : Ext JS Panels are more powerful (and expensive!) than basic containers.
  • 8. Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd. Initial Page Load : • <script src="filename.js"> tags should be placed as late in the body as possible • Make use of Ext JS “requires” • Do not use Ext.require() Event bubbling is a costly operation : So handle it carefully.
  • 9. Copyright © 2008 Walking Tree Consultancy Services . All rights reserved. 1 2 3 Handler for handleParent event. return false. 4 5. this.enableBubble(‘handleparent’); fireEvent(‘handleparent’);
  • 10. Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd. Example: xtype: 'button', handler: function() { this.enableBubble('MoreClicked'); this.fireEvent('MoreClicked', this); }
  • 11. Copyright © 2008 Walking Tree Consultancy Services . All rights reserved. Suspend and Resume events : While manipulating bulk Dom elements of a component or bulk store records or bulk array objects, suspend events to avoid multiple event execution, nested layout executions and recursive DOM manipulation. For example, INCORRECT CORRECT
  • 12. Copyright © 2008 Walking Tree Consultancy Services . All rights reserved. Performance Factors In Loops : • Declaration of functions (and for that matter, other re-usable things) inside loops wastes processing time, memory, and garbage collection cycles INCORRECT CORRECT • Calculate array length only once upfront and assign its value to a variable
  • 13. Copyright © 2008 Walking Tree Consultancy Services . All rights reserved. Regular Expression: • Store regular expressions in a variable • Always add comments INCORRECT CORRECT • Cache literal Regular Expressions in a more permanent way INCORRECT CORRECT
  • 15. Copyright © 2008 Walking Tree Consultancy Services . All rights reserved. • Do not use Ext.apply () if recursive merging and cloning without referencing the original objects / arrays is needed. Use Ext.Object.merge instead. • Avoid hard coding of id property. Alternatively, use “itemId”. • Avoid hard coding of height and width. • If using a storeId, use fully qualified store class name as the storeId (e.g. storeId : ‘MyApp.store.Businesses’). • Specify font size as "em" or "%". Localization and Internationalization: • All static text should be defined in a separate file by keeping localization in perspective.
  • 17. Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd. Code documentation must be done using JSDuck annotations. Following are the minimal documentation requirement: • Every class must be documented • Every public and protected property of a class must be documented along with an example value. Document must indicate whether the property is mandatory or optional. Default value must be specified for the optional properties. • Every public and protected method of a class must be documented • Events fired by a class must be documented along with the parameters that will be passed to a listener JSDuck document must be generated from the documented code. https://github.com/senchalabs/jsduck/wiki
  • 18. View Models and Data Binding 18
  • 19. Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd. • Preferred syntax for configuring a View Model. viewModel : { type: ‘app-main’ } • Prefer using declarations over procedural calls. For example: stores: { businesses: { model : ‘MyApp.model.Business’, autoLoad : true } }
  • 20. Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd. • Preferably, bind properties in the view class declaration itself rather than binding procedurally • Don’t create child View Models unless they are actually needed. • For derived variables, use formulas • Use formulas instead of repeating binds. For example, one formula with 3 dependencies and 4 users make 3 + 4 = 7 dependencies to track in the ViewModel. Compared to 4 users with those 3 dependencies on themselves we would have 3 * 4 = 12 dependencies. Fewer dependencies to track means less memory used and time to process them.
  • 21. Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd. • Use “deep:true” while binding config with an object / property embedded inside another object. For example, if this is the object detail : { name : ‘Rohit’, address : { state : ‘Telangana’, city: ‘Hyderabad’ } } To be notified of changes in the address object, use the following syntax: bind : { data : { bindTo : ‘{detail}’, deep: true }
  • 23. Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd. New Operator : • Use {} instead of new Object() • Use [] instead of new Array() • For Ext JS objects, you should use the create() method • For dates related objects, you still require to use new
  • 24. Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd. Views and View Controllers: • Views have the following lifecycle methods: 1. constructor 2. initComponent • View Controllers have the following 3 lifecycle methods : 1. beforeInit 2. init 3. initViewModel
  • 25. Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd. When combined, the view and controller lifecycle methods are executed in following order 1. constructor of View 2. beforeInit of Controller 3. initComponent of View 4. init of Controller 5. initViewModel of Controller
  • 26. Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd. Dom Updates In Component LifeCycle: • Changing elements after DOM elements are rendered causes reflows, resulting in slowing down of the application. Write code that avoids DOM read/writes. • If required, add CSS classes and set styles in beforerender event handler rather than afterrender. • For some code, we may need to acquire the element size. If this is the case, then consider handling the ‘boxready’ event. For example: if ( height of element > 100px ) { //do something }
  • 28. Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd. Tracing : • Use Ext.getDisplayName(). For example: throw new Error('['+ Ext.getDisplayName(arguments.callee) +'] Some message here'); • Check call stack.
  • 29. Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd. Logging : • Use Ext.log compared to console.log. If console is present, it will be used. In other cases, the message is logged to an array: "Ext.log.out“ An attached debugger can watch this array and view the log. The log buffer is limited to a maximum of "Ext.log.max" entries (defaults to 250). • Debugging statements like console.log() and debugger should never be shipped into standard production environments. INCORRECT CORRECT
  • 30. Copyright © Walking Tree Consultancy Services Pvt. Ltd.Copyright © Walking Tree Consultancy Services Pvt. Ltd. • Use the <debug> tag. • Ext JS 5.x provides “debugHooks” config for a class, through which you can write debugging statements.
  • 31. Form Validation & Submission 31
  • 32. Copyright © 2008 Walking Tree Consultancy Services . All rights reserved. • Use models for validating and submitting the forms and push the field validation logic (including custom validations) inside models. • Use loadRecord method of the FormPanel. • Instead of using explicit logic to enable / disable a submit button, make use of “formBind: true”.
  • 34. Copyright © 2008 Walking Tree Consultancy Services . All rights reserved. Global Variables: • Variables declared outside a function are considered in global scope – irrespective of the usage of “var” keyword. • These variables are in global “window” namespace. For example, the following are same: var gCompanyName = “Walking Tree”; window.companyName = “Walking Tree”; //more explicit • If you want to define global variables then use them inside application namespace. For example: Ext.define( ‘MyApp.util.Constants’,{ singleton : true, ANIMATION_Time : 100, // more variables and methods });
  • 35. Copyright © 2008 Walking Tree Consultancy Services . All rights reserved. • Consider saving the “this” scope into a different (and smaller) name (e.g. me). For example, Ext.define(‘MyApp.view.MyPanel’,{ initComponent : function () { var me=this; me.add () { xtype : ‘button’, handler: function () { this.getHeight(); me.getTitle(); } me.callParent( arguments ); } });
  • 36. Copyright © 2008 Walking Tree Consultancy Services . All rights reserved. Upcoming Online Training On Best Practices and Coding Guidelines on: 28th Nov’, 2015 For details contact: Ratan Agarwal cel: +91 95 81400033