five tips to improve your ext js application

34
Five Tips to Improve Your Ext JS Application

Upload: jonathan-julian

Post on 16-Nov-2014

24.617 views

Category:

Technology


0 download

DESCRIPTION

Ext JS apps can be complex. Out-of-the box, it's not apparent how to structure and build your new application. In this presentation, we will review some simple techniques to improve the design and maintainability of a complex Ext JS application.Presented at the first Three Pillar Global meeting in Fairfax, VA, on January 19, 2010.http://www.meetup.com/baltimore-dc-javascript-users/calendar/12219819/

TRANSCRIPT

Page 1: Five Tips To Improve Your Ext Js Application

Five Tips to Improve Your Ext JS Application

Page 2: Five Tips To Improve Your Ext Js Application

@jonathanjulian

Page 3: Five Tips To Improve Your Ext Js Application

1. Define your own components

Page 4: Five Tips To Improve Your Ext Js Application

Be explicit

Page 5: Five Tips To Improve Your Ext Js Application

reusablemodular

maintainable

Page 6: Five Tips To Improve Your Ext Js Application

MyApp.MyPanel = function(config) { MyApp.MyPanel.superclass.constructor.call(this, Ext.applyIf(config, { title: 'default title' }));};

Ext.extend(MyApp.MyPanel, Ext.Panel, { // override methods go here});

Ext.reg('mypanel', MyApp.MyPanel);

Page 7: Five Tips To Improve Your Ext Js Application

var p = new MyApp.MyPanel({ title: ‘MY title’});

var config = { xtype: ‘mypanel’, title: ‘MY title’};

Page 8: Five Tips To Improve Your Ext Js Application

2. Use an event manager

Page 9: Five Tips To Improve Your Ext Js Application

UI Logic

Page 10: Five Tips To Improve Your Ext Js Application

Event

Event Manager

Secondary Event(s)

Page 11: Five Tips To Improve Your Ext Js Application

MyApp.eventManager = new Ext.util.Observable();MyApp.eventManager.addEvents('selectnode');..// in a tree click listener:MyApp.eventManager.fireEvent('selectnode', node);..// after a grid is defined - wire it up to the tree:MyApp.eventManager.on('selectnode', grid.loadNodeData.createDelegate(grid));

Page 12: Five Tips To Improve Your Ext Js Application

consolidate codesimplify adding features

Page 13: Five Tips To Improve Your Ext Js Application

3. Override the framework properly

Page 14: Five Tips To Improve Your Ext Js Application

Do not edit the library files

Page 15: Five Tips To Improve Your Ext Js Application

DO NOT EDIT THE LIBRARY FILES

Page 16: Five Tips To Improve Your Ext Js Application

DO NOT EDIT THE LIBRARY

FILES!

Page 17: Five Tips To Improve Your Ext Js Application

Ext.override

Page 18: Five Tips To Improve Your Ext Js Application

Ext.override(Ext.data.Store, { getByName: function(name) { this.getAt(this.findExact('name', name)); }});

Page 19: Five Tips To Improve Your Ext Js Application

overrides.js

Page 20: Five Tips To Improve Your Ext Js Application

directory structure

Page 21: Five Tips To Improve Your Ext Js Application

+-ext-3.1.0 +-ext-base.js +-ext-all.js +-resources +-css +-ext-all.css +-images +-default+-ux (User eXtensions) +-Ext.ux.tree.TreeFilterX.js+-project-name +-overrides.js +-application.js +-MoviesGrid.js

Page 22: Five Tips To Improve Your Ext Js Application

4. Remember, it’s still a web app

Page 23: Five Tips To Improve Your Ext Js Application

JSLint

Page 24: Five Tips To Improve Your Ext Js Application

Speedor

Perception of Speed

Page 25: Five Tips To Improve Your Ext Js Application

Content delivery:combineminimize

gzip

Page 26: Five Tips To Improve Your Ext Js Application

browser cache with Expires header

Page 27: Five Tips To Improve Your Ext Js Application
Page 28: Five Tips To Improve Your Ext Js Application

5. Prefer an Ext JS SPA to a classic "web app"

Page 29: Five Tips To Improve Your Ext Js Application

var grid = { id: <%= @article.id %>, border: <%= @article.size > 50 ? ‘true’ : ‘false’ %> xtype: ‘grid’, items: [ <%= generate_items(@article) %> ]};

Page 30: Five Tips To Improve Your Ext Js Application

var grid = { id: <%= @article.id %>, border: <%= @article.size > 50 ? ‘true’ : false %> xtype: ‘grid’, items: [ <%= generate_items(@article) %> ]};

AVOID

Page 31: Five Tips To Improve Your Ext Js Application

ServerRails, PHP, JSP, ASP.NET,ColdFusion, Perl

UI - Ext JSJSON

Page 32: Five Tips To Improve Your Ext Js Application

"Don't buy a cow and then milk the goat."

Page 33: Five Tips To Improve Your Ext Js Application

"Don't buy a cow and then milk the goat."

Page 34: Five Tips To Improve Your Ext Js Application

jonathanjulian.com