SlideShare a Scribd company logo
JavascriptMVC
JavascriptMVC
  Another javascript MVC framework
Me

                    Alive

• Mozilla Corp. Taiwan, Frontend engineer
• ~1.5 year experience on web
• https://github.com/alivedise
• email: alegnadise@gmail.com
        alive@mozilla.com
Mozilla is hiring!
You




• A web developer
• Use lots of jQuery plugins in your site
• Javascript newbie
• Building a complex web application
• Hate backend stuff
Developing web
application is a
   struggle.
BackboneJS is much more known to people.




Amazing! They have their own backboneConf!
http://backboneconf.com/
But I would love to
provide another choice
         to you
Successfull story: Grooveshark.com
http://javascriptmvc.com
• PROS
  o MIT license
  o Clear documentation
  o Nearly total solution to build a web
    application
• CONS
  o Less known, less resource (in Taiwan)
  o No preset UI layer implementation
Clear&models/
views/controllers&                         Na9ve&event&      View&with&
    and&class&       CRUD&Model&layer&
                                            delega9on&      Embedded&js&
   inheritance&


                          Library&
                                                              {LESS}&CSS&
     Fixture&          dependancy&        Build&process&
                                                             integra9on&
                         solu9on&


                          A&basic&
                        applica9on/
OpenAjax&pubsub&      project/product&   Model&Valida9on&   Form&Paramize&
                       management&
Class
$.Class('Monster',
{
   count: 0
},
{
   init: function( name ) {
      // saves name on the monster instance
      this.name = name;
      this.health = 10;
      this.constructor.count++;
   },
   eat: function( smallChildren ){
      this.health += smallChildren;
   },
   fight: function() {
      this.health -= 2;
   }
});

hydra = new Monster('hydra');
dragon = new Monster('dragon');

hydra.name        // -> hydra
Monster.count     // -> 2
Monster.shortName // -> 'Monster'

hydra.eat(2);     // health = 12

dragon.fight();   // health = 8
CSS collision




/* a.css */
div.data {
! background-color: red;
}
/* b.css */
div.data {
! background-color: white;
}
{LESS}

@company_blue: #0186d1;
@focus_width: 100;
div#content {
  div.title {
    background-color: @company_blue;
      &:hover,&:active {
        width: @focus_width;
    }
  }
}

steal('steal/less').then('a.less',
'b.less').then(function() {
  // ...
});
Data chaos...
$.ajax({
  url: '/cgi-bin/character?id=1',
  dataType: 'json',
  type: 'post',
  success: function() {
    $.ajax('/data/item.json',
    dataType: 'json',
     type: 'post',
    success: function() {
      // .....
    },
    error: function() {
    }
  },
  error: function() {
  }
});
$.Model


• CRUD functions, overwrittable
• Event callback whenever data is
  o   created
    o deleted
    o updated
    o and if you like, custom event on model is
      creatable.
•   DOM embeddable
    o <div <%= model %></div>
•   Validation in data model layer
Data mess solution




$.when(
  Character.findOne({id: 1}),
  Item.findAll({char_id: 1})
  .done(function(){ /*...*/ });
When you have more and more jQuery plugins..




   • None loosely coupled.
   • No cross function communication.
   • DOM renew and event rebind
     oa long long string in your javascript like

$('#div').html('<div class="event"><span
class="name"></span><span class="icon"></span><span
class="content"></span><span class="screenshot"></
span></div>');
$.Controller - Event delegation function


$.Controller("Crazy",{

  // listens to all clicks on this element
  "click" : function(el, ev){},

  // listens to all mouseovers on
  // li elements withing this controller
  "li mouseover" : function(el, ev){}

  // listens to the window being resized
  "{window} resize" : function(window, ev){}
});
$.Controller - OpenAjax Pubsub

$.Controller("Listener", {
  "something.updated subscribe" : function(called,
data){
    console.log(data.name);
  }
});

// called elsewhere
$.Controller("Renewer", {
  init: function(){
    var data = { name: 'lol' };
    this.publish("something.updated", data);
  }
});
$.View




  • Seperate HTML from your javascript codes.
  • Reusable, cachable
  • Logic (javascript) in HTML
    o http://embeddedjs.com
<ul>
<% for(var i=0; i<supplies.length; i++) {%>
<li><%= supplies[i] %></li>
<% } %>
</ul>
header...



<script src="http://ajax.googleapis.com/ajax/libs/
jquery/1.6.2/jquery.min.js"></script>
<script src="http://threedubmedia.googlecode.com/
files/jquery.event.drag-2.0.min.js"></script>
<script src="http://github.com/cowboy/jquery-resize/
raw/v1.1/jquery.ba-resize.min.js"></script>
<script src="http://remysharp.com/demo/
mousehold.js"></script>
<script src="https://raw.github.com/brandonaaron/
jquery-mousewheel/master/jquery.mousewheel.js"></
script>
StealJS




          Library dependency solution
steal('jquery').then('jquery/resize','jquery/
mousehold','jquery/event/drag').then('./
my.css', function(){
/*...*/
});
More about...fixture
•You can do nothing without server.
 Do you?
• Multi ajax request solution
Deferred model
•Since jQuery 1.5, ajax is implemented as a
 deferred object.
•Models CRUD support deferred operation.

$.fixture
o Create a deferred instead of sending
  XMLHttpRequest to the server, but to the
  function you preferred.
$.fixture("/foobar.json", function(orig, settings,
headers){
  return [200, "success", {json: {foo: "bar" } },
{} ]
});



$.ajax({
  url: "/foobar.json",
  success: function(data) {
    console.log(data.json.foo);
  }
});
Q&A




      Javascript is beautiful.
Let's use it to get the world better.

More Related Content

What's hot

jQuery: Tips, tricks and hints for better development and Performance
jQuery: Tips, tricks and hints for better development and PerformancejQuery: Tips, tricks and hints for better development and Performance
jQuery: Tips, tricks and hints for better development and Performance
Jonas De Smet
 
Web Components With Rails
Web Components With RailsWeb Components With Rails
Web Components With Rails
Boris Nadion
 
Webapps without the web
Webapps without the webWebapps without the web
Webapps without the web
Remy Sharp
 
Drupal, meet Assetic
Drupal, meet AsseticDrupal, meet Assetic
Drupal, meet Assetic
Kris Wallsmith
 
JavaScript for Flex Devs
JavaScript for Flex DevsJavaScript for Flex Devs
JavaScript for Flex Devs
Aaronius
 
Ember background basics
Ember background basicsEmber background basics
Ember background basics
Philipp Fehre
 
Responsive Design with WordPress
Responsive Design with WordPressResponsive Design with WordPress
Responsive Design with WordPress
Joe Casabona
 
HTML5 JavaScript APIs
HTML5 JavaScript APIsHTML5 JavaScript APIs
HTML5 JavaScript APIs
Remy Sharp
 
Javascript Frameworks for Joomla
Javascript Frameworks for JoomlaJavascript Frameworks for Joomla
Javascript Frameworks for JoomlaLuke Summerfield
 
JavaScript APIs - The Web is the Platform - MDN Hack Day, Sao Paulo
JavaScript APIs - The Web is the Platform - MDN Hack Day, Sao PauloJavaScript APIs - The Web is the Platform - MDN Hack Day, Sao Paulo
JavaScript APIs - The Web is the Platform - MDN Hack Day, Sao PauloRobert Nyman
 
In-depth changes to Drupal 8 javascript
In-depth changes to Drupal 8 javascriptIn-depth changes to Drupal 8 javascript
In-depth changes to Drupal 8 javascript
Théodore Biadala
 
Leave No One Behind with HTML5 - FFWD.PRO, Croatia
Leave No One Behind with HTML5 - FFWD.PRO, CroatiaLeave No One Behind with HTML5 - FFWD.PRO, Croatia
Leave No One Behind with HTML5 - FFWD.PRO, CroatiaRobert Nyman
 
HOW TO UPLOAD AND DISPLAY IMAGE PHP HTML SQL
HOW TO UPLOAD AND DISPLAY IMAGE PHP HTML SQLHOW TO UPLOAD AND DISPLAY IMAGE PHP HTML SQL
HOW TO UPLOAD AND DISPLAY IMAGE PHP HTML SQL
mauricemuteti2015
 
Building a real life application in node js
Building a real life application in node jsBuilding a real life application in node js
Building a real life application in node js
fakedarren
 
Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!
Anatoly Sharifulin
 
Yearning jQuery
Yearning jQueryYearning jQuery
Yearning jQueryRemy Sharp
 
jQuery (DrupalCamp Toronto)
jQuery (DrupalCamp Toronto)jQuery (DrupalCamp Toronto)
jQuery (DrupalCamp Toronto)
jeresig
 
Javascript is your (Auto)mate
Javascript is your (Auto)mateJavascript is your (Auto)mate
Javascript is your (Auto)mate
Codemotion
 
Sprout core and performance
Sprout core and performanceSprout core and performance
Sprout core and performanceYehuda Katz
 
jQuery (BostonPHP)
jQuery (BostonPHP)jQuery (BostonPHP)
jQuery (BostonPHP)
jeresig
 

What's hot (20)

jQuery: Tips, tricks and hints for better development and Performance
jQuery: Tips, tricks and hints for better development and PerformancejQuery: Tips, tricks and hints for better development and Performance
jQuery: Tips, tricks and hints for better development and Performance
 
Web Components With Rails
Web Components With RailsWeb Components With Rails
Web Components With Rails
 
Webapps without the web
Webapps without the webWebapps without the web
Webapps without the web
 
Drupal, meet Assetic
Drupal, meet AsseticDrupal, meet Assetic
Drupal, meet Assetic
 
JavaScript for Flex Devs
JavaScript for Flex DevsJavaScript for Flex Devs
JavaScript for Flex Devs
 
Ember background basics
Ember background basicsEmber background basics
Ember background basics
 
Responsive Design with WordPress
Responsive Design with WordPressResponsive Design with WordPress
Responsive Design with WordPress
 
HTML5 JavaScript APIs
HTML5 JavaScript APIsHTML5 JavaScript APIs
HTML5 JavaScript APIs
 
Javascript Frameworks for Joomla
Javascript Frameworks for JoomlaJavascript Frameworks for Joomla
Javascript Frameworks for Joomla
 
JavaScript APIs - The Web is the Platform - MDN Hack Day, Sao Paulo
JavaScript APIs - The Web is the Platform - MDN Hack Day, Sao PauloJavaScript APIs - The Web is the Platform - MDN Hack Day, Sao Paulo
JavaScript APIs - The Web is the Platform - MDN Hack Day, Sao Paulo
 
In-depth changes to Drupal 8 javascript
In-depth changes to Drupal 8 javascriptIn-depth changes to Drupal 8 javascript
In-depth changes to Drupal 8 javascript
 
Leave No One Behind with HTML5 - FFWD.PRO, Croatia
Leave No One Behind with HTML5 - FFWD.PRO, CroatiaLeave No One Behind with HTML5 - FFWD.PRO, Croatia
Leave No One Behind with HTML5 - FFWD.PRO, Croatia
 
HOW TO UPLOAD AND DISPLAY IMAGE PHP HTML SQL
HOW TO UPLOAD AND DISPLAY IMAGE PHP HTML SQLHOW TO UPLOAD AND DISPLAY IMAGE PHP HTML SQL
HOW TO UPLOAD AND DISPLAY IMAGE PHP HTML SQL
 
Building a real life application in node js
Building a real life application in node jsBuilding a real life application in node js
Building a real life application in node js
 
Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!
 
Yearning jQuery
Yearning jQueryYearning jQuery
Yearning jQuery
 
jQuery (DrupalCamp Toronto)
jQuery (DrupalCamp Toronto)jQuery (DrupalCamp Toronto)
jQuery (DrupalCamp Toronto)
 
Javascript is your (Auto)mate
Javascript is your (Auto)mateJavascript is your (Auto)mate
Javascript is your (Auto)mate
 
Sprout core and performance
Sprout core and performanceSprout core and performance
Sprout core and performance
 
jQuery (BostonPHP)
jQuery (BostonPHP)jQuery (BostonPHP)
jQuery (BostonPHP)
 

Viewers also liked

JavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web frameworkJavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web framework
Alive Kuo
 
[COSCUP 2013] Audio Competing
[COSCUP 2013] Audio Competing[COSCUP 2013] Audio Competing
[COSCUP 2013] Audio CompetingAlive Kuo
 
FXOS Window management 101
FXOS Window management 101FXOS Window management 101
FXOS Window management 101
Alive Kuo
 
#FirefoxOS Web App development@CID Nyári Egyetem 2013
#FirefoxOS Web App development@CID Nyári Egyetem 2013#FirefoxOS Web App development@CID Nyári Egyetem 2013
#FirefoxOS Web App development@CID Nyári Egyetem 2013daf182
 
FirefoxOS Window Management
FirefoxOS Window ManagementFirefoxOS Window Management
FirefoxOS Window Management
Alive Kuo
 
Firefox OS Window management 201
Firefox OS Window management 201Firefox OS Window management 201
Firefox OS Window management 201
Alive Kuo
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving Cars
LinkedIn
 

Viewers also liked (7)

JavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web frameworkJavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web framework
 
[COSCUP 2013] Audio Competing
[COSCUP 2013] Audio Competing[COSCUP 2013] Audio Competing
[COSCUP 2013] Audio Competing
 
FXOS Window management 101
FXOS Window management 101FXOS Window management 101
FXOS Window management 101
 
#FirefoxOS Web App development@CID Nyári Egyetem 2013
#FirefoxOS Web App development@CID Nyári Egyetem 2013#FirefoxOS Web App development@CID Nyári Egyetem 2013
#FirefoxOS Web App development@CID Nyári Egyetem 2013
 
FirefoxOS Window Management
FirefoxOS Window ManagementFirefoxOS Window Management
FirefoxOS Window Management
 
Firefox OS Window management 201
Firefox OS Window management 201Firefox OS Window management 201
Firefox OS Window management 201
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving Cars
 

Similar to [Coscup 2012] JavascriptMVC

Everything is Awesome - Cutting the Corners off the Web
Everything is Awesome - Cutting the Corners off the WebEverything is Awesome - Cutting the Corners off the Web
Everything is Awesome - Cutting the Corners off the Web
James Rakich
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
David Padbury
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
toddbr
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
Doris Chen
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
Igor Bronovskyy
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVC
pootsbook
 
SAS_Forum_2015_Data_Visualisation_With_HighCharts_D3
SAS_Forum_2015_Data_Visualisation_With_HighCharts_D3SAS_Forum_2015_Data_Visualisation_With_HighCharts_D3
SAS_Forum_2015_Data_Visualisation_With_HighCharts_D3Vasilij Nevlev
 
Express Presentation
Express PresentationExpress Presentation
Express Presentation
aaronheckmann
 
Fatc
FatcFatc
JavaScript performance patterns
JavaScript performance patternsJavaScript performance patterns
JavaScript performance patterns
Stoyan Stefanov
 
Dependency Management with RequireJS
Dependency Management with RequireJSDependency Management with RequireJS
Dependency Management with RequireJSAaronius
 
Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
Daniel Cukier
 
Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Chris Alfano
 
Webpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of usWebpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of us
Stefan Adolf
 
BlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorksBlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorksmwbrooks
 
Styling components with JavaScript
Styling components with JavaScriptStyling components with JavaScript
Styling components with JavaScript
bensmithett
 
Sanjeev ghai 12
Sanjeev ghai 12Sanjeev ghai 12
Sanjeev ghai 12
Praveen kumar
 

Similar to [Coscup 2012] JavascriptMVC (20)

Everything is Awesome - Cutting the Corners off the Web
Everything is Awesome - Cutting the Corners off the WebEverything is Awesome - Cutting the Corners off the Web
Everything is Awesome - Cutting the Corners off the Web
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
 
Having Fun with Play
Having Fun with PlayHaving Fun with Play
Having Fun with Play
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVC
 
SAS_Forum_2015_Data_Visualisation_With_HighCharts_D3
SAS_Forum_2015_Data_Visualisation_With_HighCharts_D3SAS_Forum_2015_Data_Visualisation_With_HighCharts_D3
SAS_Forum_2015_Data_Visualisation_With_HighCharts_D3
 
Express Presentation
Express PresentationExpress Presentation
Express Presentation
 
Fatc
FatcFatc
Fatc
 
JavaScript performance patterns
JavaScript performance patternsJavaScript performance patterns
JavaScript performance patterns
 
Dependency Management with RequireJS
Dependency Management with RequireJSDependency Management with RequireJS
Dependency Management with RequireJS
 
Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
 
Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011
 
Webpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of usWebpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of us
 
BlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorksBlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorks
 
Styling components with JavaScript
Styling components with JavaScriptStyling components with JavaScript
Styling components with JavaScript
 
Sanjeev ghai 12
Sanjeev ghai 12Sanjeev ghai 12
Sanjeev ghai 12
 
Play framework
Play frameworkPlay framework
Play framework
 

Recently uploaded

From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 

Recently uploaded (20)

From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 

[Coscup 2012] JavascriptMVC

  • 1.
  • 3. JavascriptMVC Another javascript MVC framework
  • 4. Me Alive • Mozilla Corp. Taiwan, Frontend engineer • ~1.5 year experience on web • https://github.com/alivedise • email: alegnadise@gmail.com alive@mozilla.com
  • 5.
  • 7. You • A web developer • Use lots of jQuery plugins in your site • Javascript newbie • Building a complex web application • Hate backend stuff
  • 9.
  • 10. BackboneJS is much more known to people. Amazing! They have their own backboneConf! http://backboneconf.com/
  • 11. But I would love to provide another choice to you
  • 12.
  • 14. http://javascriptmvc.com • PROS o MIT license o Clear documentation o Nearly total solution to build a web application • CONS o Less known, less resource (in Taiwan) o No preset UI layer implementation
  • 15. Clear&models/ views/controllers& Na9ve&event& View&with& and&class& CRUD&Model&layer& delega9on& Embedded&js& inheritance& Library& {LESS}&CSS& Fixture& dependancy& Build&process& integra9on& solu9on& A&basic& applica9on/ OpenAjax&pubsub& project/product& Model&Valida9on& Form&Paramize& management&
  • 16. Class
  • 17. $.Class('Monster', { count: 0 }, { init: function( name ) { // saves name on the monster instance this.name = name; this.health = 10; this.constructor.count++; }, eat: function( smallChildren ){ this.health += smallChildren; }, fight: function() { this.health -= 2; } }); hydra = new Monster('hydra'); dragon = new Monster('dragon'); hydra.name // -> hydra Monster.count // -> 2 Monster.shortName // -> 'Monster' hydra.eat(2); // health = 12 dragon.fight(); // health = 8
  • 18. CSS collision /* a.css */ div.data { ! background-color: red; } /* b.css */ div.data { ! background-color: white; }
  • 19. {LESS} @company_blue: #0186d1; @focus_width: 100; div#content {   div.title {     background-color: @company_blue;       &:hover,&:active {         width: @focus_width;     }   } } steal('steal/less').then('a.less', 'b.less').then(function() {   // ... });
  • 21. $.ajax({   url: '/cgi-bin/character?id=1',   dataType: 'json', type: 'post',   success: function() {     $.ajax('/data/item.json',     dataType: 'json', type: 'post',     success: function() {       // .....     },     error: function() {     }   },   error: function() {   } });
  • 22. $.Model • CRUD functions, overwrittable • Event callback whenever data is o created o deleted o updated o and if you like, custom event on model is creatable. • DOM embeddable o <div <%= model %></div> • Validation in data model layer
  • 23. Data mess solution $.when( Character.findOne({id: 1}), Item.findAll({char_id: 1}) .done(function(){ /*...*/ });
  • 24. When you have more and more jQuery plugins.. • None loosely coupled. • No cross function communication. • DOM renew and event rebind oa long long string in your javascript like $('#div').html('<div class="event"><span class="name"></span><span class="icon"></span><span class="content"></span><span class="screenshot"></ span></div>');
  • 25. $.Controller - Event delegation function $.Controller("Crazy",{ // listens to all clicks on this element "click" : function(el, ev){}, // listens to all mouseovers on // li elements withing this controller "li mouseover" : function(el, ev){} // listens to the window being resized "{window} resize" : function(window, ev){} });
  • 26. $.Controller - OpenAjax Pubsub $.Controller("Listener", {   "something.updated subscribe" : function(called, data){     console.log(data.name);   } }); // called elsewhere $.Controller("Renewer", {   init: function(){     var data = { name: 'lol' };     this.publish("something.updated", data);   } });
  • 27. $.View • Seperate HTML from your javascript codes. • Reusable, cachable • Logic (javascript) in HTML o http://embeddedjs.com <ul> <% for(var i=0; i<supplies.length; i++) {%> <li><%= supplies[i] %></li> <% } %> </ul>
  • 28. header... <script src="http://ajax.googleapis.com/ajax/libs/ jquery/1.6.2/jquery.min.js"></script> <script src="http://threedubmedia.googlecode.com/ files/jquery.event.drag-2.0.min.js"></script> <script src="http://github.com/cowboy/jquery-resize/ raw/v1.1/jquery.ba-resize.min.js"></script> <script src="http://remysharp.com/demo/ mousehold.js"></script> <script src="https://raw.github.com/brandonaaron/ jquery-mousewheel/master/jquery.mousewheel.js"></ script>
  • 29. StealJS Library dependency solution steal('jquery').then('jquery/resize','jquery/ mousehold','jquery/event/drag').then('./ my.css', function(){ /*...*/ });
  • 31. •You can do nothing without server. Do you? • Multi ajax request solution
  • 32. Deferred model •Since jQuery 1.5, ajax is implemented as a deferred object. •Models CRUD support deferred operation. $.fixture o Create a deferred instead of sending XMLHttpRequest to the server, but to the function you preferred.
  • 33. $.fixture("/foobar.json", function(orig, settings, headers){   return [200, "success", {json: {foo: "bar" } }, {} ] }); $.ajax({ url: "/foobar.json", success: function(data) { console.log(data.json.foo); } });
  • 34. Q&A Javascript is beautiful. Let's use it to get the world better.

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n