SlideShare a Scribd company logo
Sencha TouchのMVCについて
∼スケールするアプリケーションをもとめて∼
Profile
๏ Ariel Networks Inc.
๏ @kiris
๏ Server Side Engineer
๏ Hate JavaScript :-(
๏ ECMAScript is OK
Sencha TouchのMVCを中心に
感想や意見を憶測を交えながら
まとまりなく話します
Sencha Touchって何?
JavaScirpt Framework for Mobile
Ext.create('Ext.TabPanel', {
fullscreen: true,
tabBarPosition: 'bottom',
defaults: {
'Ext.MessageBox',
items: [
{
title: 'Home',
iconCls: 'home',
html: 'Home Screen'
},
{
title: 'Contact',
iconCls: 'user',
html: 'Contact Screen'
}
]
});
Native Application like Components
Ext JS based Class System
๏ Class-based OOP
๏ Mix-in
๏ Dependencies and
Dynamic Loading
๏ Autogen getter/
setter and more...
Ext.define('Human', {
extend: 'Animal',
mixins: ['Ext.mixin.Observable'],
requires: 'Ext.MessageBox',
config: {
name: null
},
constructor: function(config) {
this.initConfig(config);
},
speak: function() {
Ext.Msg.alert(this.getName(),
'Speaks...');
}
});
More topics
๏ Vendor Development
๏ Supported Devices
iOS/Android/Black Berry/Windows Phone
๏ Sass Supported
๏ MVC Architecture
Sencha Touch MVC
Model
๏ User-Defined Fields
String/Integer/Float/Boolean
๏ Data Bindings
AJAX/REST/Localstorage/JSON-P
๏ Associations
hasMany/BelongsTo
๏ Validations
Presence/Format/Length/Custom
Ext.define('User', {
extend: 'Ext.data.Model',
config: {
fields: [
{ name: 'id', type: 'int' },
{ name: 'name', type: 'string' }
],
proxy: {
type: 'rest',
url : 'data/users',
reader: {
type: 'json',
root: 'users'
}
},
hasMany: 'Post',
validations: [
{ type: 'presence',
field: 'name' }
]
}
});
View
๏ Plain Ext JS Class
NOT HTML Template
Ext.define('MyApp.view.Welcome', {
extend: 'Ext.Panel',
config: {
html: 'Welcome to my app',
fullscreen: true
}
});
Ext.create('MyApp.view.Welcome', {
styleHtmlContent: true
});
Controller
๏ Routing with
Hash Fragments
๏ References Views
๏ Event Handling
Ext.define('MyApp.controller.Users', {
extend: 'Ext.app.Controller',
config: {
routes: {
'user/:id': 'showUserById'
},
refs: {
loginButton: 'button[action=login]'
},
control: {
loginButton: {
tap: 'doLogin'
}
},
},
showUserById: function(id) {
...
},
doLogin: function() {
this.redirectTo('/login');
}
});
Events
๏ mixin Ext.mixin.Observable
๏ call fireEvent method
Ext.define('Employee', {
mixins: ['Ext.mixin.Observable'],
config: {
fullName: ''
},
constructor: function(config) {
this.initConfig(config);
},
quitJob: function() {
this.fireEvent('quit');
}
});
如何にスケールさせるか?
典型的な例
ModelView
Controller
Data BindingsHTML Buildings
Other
Reference
Data Flow
ModelView
Controller
Data BindingsHTML Buildings
Other
After half a year...
MVCの理解を深めよう
Model
๏ Model Data Binder
๏ Has Domain Logic
๏ Fire Events
push-based MVC
View
๏ View HTML Template
๏ Has Presentation Logic
Fattest for Client Side MVC
๏ Can call Models
๏ Fire Presentation/Domain Level Events
๏ Handle Presentation Level Events
Controller
๏ Control Models
๏ Call Views
๏ Handle Domain Level Events
ModelView
Controller
Event
Operation & Reference
同一レイヤー間の連携
Model to Model
๏ Can call associated Models
๏ Control other Models via Controller
View to View
๏ Can call child Views
๏ call other Views with Events
Controller to Controller
๏ Redirect Page
change hash fragment
๏ notify by Events
固有の問題
Client Side Logic
VS
Server Side Logic
Not Easy
๏ Better push them to the Server Side
๏ Hide inside Models
Don t made barrel full of sewage!
๏ Better not to call Models getter/setter
Pull-based MVC
VS
Push-based MVC
Pull-based MVC is OK
๏ Mobile Display is small
๏ Push-based MVC seems to be more
useful on Tablet?
Model mixin Ext.mixins.Observable
ServerとClientの協調
Cross Check Validation
๏ Generate Model fields and
validations from Server code
๏ Fields and Validations are Protocol
テストはどうするのか?
Test is necessary
๏ Writing Unit Tests for Models
๏ Writing Scenario Tests for Views
๏ Keep Easy, Keep Small,
Keep Loose coupling
ドメインオブジェクトを
如何に構築するか?
My Questions
๏ Server Side Domain Client Side Domain
๏ Different viewpoints?
๏ Different techniques?
Finally
๏ MVC is NOT a Silver Bullet
๏ Building Service Layer?
๏ Try Other Patterns?
MVVM or MVP or ...
๏ Keep thinking
Thank you for listening :-)

More Related Content

What's hot (20)

PDF
AngularJS - What is it & Why is it awesome ? (with demos)
Gary Arora
 
PPTX
Angular js tutorial slides
samhelman
 
PPTX
AngularJS intro
dizabl
 
PDF
Karlsruher Entwicklertag 2013 - Webanwendungen mit AngularJS
Philipp Burgmer
 
PDF
Angularjs in mobile app
Yvonne Yu
 
PPTX
Introduction à AngularJS
Nicolas PENNEC
 
PPTX
ASP.NET MVC for Begineers
Shravan Kumar Kasagoni
 
PPTX
Introduction to single page application with angular js
Mindfire Solutions
 
PPTX
ASP.NET MVC 3
joselinoneto
 
PDF
OpenDolphin: Enterprise Apps for collaboration on Desktop, Web, and Mobile
Dierk König
 
PDF
AngularJS: Overview & Key Features
Mohamad Al Asmar
 
PPT
Introduction To Asp.Net Mvc
Rishu Mehra
 
PPTX
MVVM Applied: From Silverlight to Windows Phone to Windows 8
Microsoft Developer Network (MSDN) - Belgium and Luxembourg
 
PPTX
AngularJS is awesome
Eusebiu Schipor
 
PDF
Kickstarting Node.js Projects with Yeoman
Patrick Buergin
 
PPTX
Why angular js Framework
Sakthi Bro
 
PPTX
5 angularjs features
Alexey (Mr_Mig) Migutsky
 
PPTX
Angular js
Dinusha Nandika
 
PPTX
Membangun Moderen UI dengan Vue.js
Froyo Framework
 
PPTX
Introduction to Angular js 2.0
Nagaraju Sangam
 
AngularJS - What is it & Why is it awesome ? (with demos)
Gary Arora
 
Angular js tutorial slides
samhelman
 
AngularJS intro
dizabl
 
Karlsruher Entwicklertag 2013 - Webanwendungen mit AngularJS
Philipp Burgmer
 
Angularjs in mobile app
Yvonne Yu
 
Introduction à AngularJS
Nicolas PENNEC
 
ASP.NET MVC for Begineers
Shravan Kumar Kasagoni
 
Introduction to single page application with angular js
Mindfire Solutions
 
ASP.NET MVC 3
joselinoneto
 
OpenDolphin: Enterprise Apps for collaboration on Desktop, Web, and Mobile
Dierk König
 
AngularJS: Overview & Key Features
Mohamad Al Asmar
 
Introduction To Asp.Net Mvc
Rishu Mehra
 
MVVM Applied: From Silverlight to Windows Phone to Windows 8
Microsoft Developer Network (MSDN) - Belgium and Luxembourg
 
AngularJS is awesome
Eusebiu Schipor
 
Kickstarting Node.js Projects with Yeoman
Patrick Buergin
 
Why angular js Framework
Sakthi Bro
 
5 angularjs features
Alexey (Mr_Mig) Migutsky
 
Angular js
Dinusha Nandika
 
Membangun Moderen UI dengan Vue.js
Froyo Framework
 
Introduction to Angular js 2.0
Nagaraju Sangam
 

Similar to Sencha TouchのMVCについて 〜スケールするアプリケーションを求めて〜 (8)

PPTX
Mobile gotcha
phegaro
 
PPTX
Mobile native-hacks
DevelopmentArc LLC
 
PDF
MVC pattern for widgets
Behnam Taraghi
 
PDF
4 JVM Web Frameworks
Joe Kutner
 
PDF
Sencha and Spring (Spring 2GX 2013)
Sencha
 
PDF
Good bye Massive View Controller!
Supercharge
 
PPTX
Building SPA’s (Single Page App) with Backbone.js
Microsoft Developer Network (MSDN) - Belgium and Luxembourg
 
PDF
Hypermedia: The Missing Element to Building Adaptable Web APIs in Rails
Toru Kawamura
 
Mobile gotcha
phegaro
 
Mobile native-hacks
DevelopmentArc LLC
 
MVC pattern for widgets
Behnam Taraghi
 
4 JVM Web Frameworks
Joe Kutner
 
Sencha and Spring (Spring 2GX 2013)
Sencha
 
Good bye Massive View Controller!
Supercharge
 
Building SPA’s (Single Page App) with Backbone.js
Microsoft Developer Network (MSDN) - Belgium and Luxembourg
 
Hypermedia: The Missing Element to Building Adaptable Web APIs in Rails
Toru Kawamura
 
Ad

Sencha TouchのMVCについて 〜スケールするアプリケーションを求めて〜