SlideShare une entreprise Scribd logo
1  sur  31
Fabio Franzini
Designing complex applications using HTML5 and
KnockoutJS

fabio@fabiofranzini.com - @franzinifabio
About Me
                  Fabio franzini                 fabio@fabiofranzini.com - @franzinifabio




   Senior Consultant and Software Engineer
   MCT Trainer, MCPD Web Applications, MCTS SharePoint 2010/2007
   Official Ignite Trainer for SharePoint 2013 & 2010 in Italy
   Web Stack Lover
   Over 9 years experience in IT as a software engineer

Blog: www.fabiofranzini.com
Email: fabio@fabiofranzini.com
Agenda
                    Fabio franzini           fabio@fabiofranzini.com - @franzinifabio




1.   Introduction
2.   HTML5
3.   JavaScript and Client Side Frameworks
4.   Server Side Tools
5.   Multiplatform
6.   Demo
Introduction
              Fabio franzini              fabio@fabiofranzini.com - @franzinifabio




What is the keys to create complex applications in javascript
without becoming crazy?

1. Write clean code!!
2. Modularization and Reuse of code!!
3. Use frameworks or tools that simplify the work!!
Why HTML5?
             Fabio franzini           fabio@fabiofranzini.com - @franzinifabio




• Cross Browser
• Cross Platform
• W3C Standards
• All modern browsers and mobile devices supports
  HTML5
• Rich set of controls and APIs
JavaScript is…
                Fabio franzini                 fabio@fabiofranzini.com - @franzinifabio




• From Wikipedia:
   – A prototype-based scripting language that is dynamic, weakly
     typed and has first-class functions.
   – A multi-paradigm language, supporting object-oriented,
     imperative, and functional programming styles.


• In short, a big mess for most developers :)
Modularize your code using the module pattern!
                   Fabio franzini                      fabio@fabiofranzini.com - @franzinifabio




• Group several related elements such as classes, singletons, methods,
  globally used, into a simple object.
• It fakes classes in Javascript.

• Pros
    – Encapsulation, it gives us an API (public and private attributes or
      methods)
    – Avoid names conflicting with other function
    – Easier debugging (public functions are named)
• Cons:
    – Difficult to refactor
Module Pattern: Example
                 Fabio franzini                  fabio@fabiofranzini.com - @franzinifabio




 var testModule = ( function() {
      var counter = 0;
      var privateMethod = function() {
        // do something….
      }
      return {
        incrementCounter: function() { return counter++; },
        resetCounter: function() { counter = 0; }
      };
})();
Revealing Module Pattern
                  Fabio franzini              fabio@fabiofranzini.com - @franzinifabio




Coined by Christian Heilmann (Mozilla Foundation)
Pros
    – Sintax more consistent and easy to read
    – Easier to refactor
var myRevealingModule = ( function() {
     var name = 'John Smith';
     function updatePerson() {
               name = 'John Smith Updated';
     }
     function setPerson (value) {
               name = value;
     }
     return { set: setPerson };
}());
RequireJs for implement Module Pattern
                  Fabio franzini                     fabio@fabiofranzini.com - @franzinifabio




• RequireJs is a JavaScript file and module loader.
• Using a modular script loader like RequireJS will improve the speed
  and quality of your code!

[myPage.html]
<script data-main="scripts/main" src="scripts/require-jquery.js"></script>
…..
[main.js]
require(["jquery", "jquery.alpha", "jquery.beta"], function($) {
    //the jquery.alpha.js and jquery.beta.js plugins have been loaded.
    $(function() {
         $('body').alpha().beta();
    });
});
Another Pattern
                 Fabio franzini                  fabio@fabiofranzini.com - @franzinifabio




•   MV* Pattern
    – The MV* Pattern allows to separate the functionalities and
      introduce greater flexibility to customize the presentation of
      items
    – Provides a standard model interface to allow a wide range of data
      sources to be used with existing item views
    – Different implementation: MVC, MVP, MVVM
•   Observer (Pub/Sub) Pattern
    – It is a design pattern which allows an object (known as a
      subscriber) to watch another object (the publisher)
    – Loose coupling, ability to break down our applications into
      smaller, general manageability
KnockoutJs
                 Fabio franzini                  fabio@fabiofranzini.com - @franzinifabio




• Model: It uses the Observable property that can notify subscribers
  about changes and automatically detect dependencies
• View: A KnockoutJs View is simply a HTML document with
  declarative bindings to link it to the ViewModel
• ViewModel: The ViewModel can be considered a specialized
  Controller that acts as a data converter. It changes Model information
  into View information, passing commands from the View to the
  Model
KnockoutJs ViewModel
                     Fabio franzini                       fabio@fabiofranzini.com - @franzinifabio




function AppViewModel() {
  this.firstName = ko.observable("Bert");
  this.lastName = ko.observable("Bertington");

    this.fullName = ko.computed(function() {
       return this.firstName() + " " + this.lastName();
    }, this);

    this.capitalizeLastName = function() {
       var currentVal = this.lastName();
       this.lastName(currentVal.toUpperCase());
    };
}

// Activates knockout.js
ko.applyBindings(new AppViewModel());
KnockoutJs View
                    Fabio franzini                          fabio@fabiofranzini.com - @franzinifabio




<p>First name: <input data-bind="value: firstName" /></p>

<p>Last name: <input data-bind="value: lastName" /></p>

<p>Full name: <strong data-bind="text: fullName"></strong></p>

<button data-bind="click: capitalizeLastName">Go caps</button>
List of other Powerfull JavaScript FX
           Fabio franzini                  fabio@fabiofranzini.com - @franzinifabio




•   AmplifyJs
•   UnderscoreJs
•   LinqJs
•   DurandalJs
•   BreezeJS
AmplifyJs
                 Fabio franzini                   fabio@fabiofranzini.com - @franzinifabio




Is a set of components designed to solve common web application
problems with a simplistic API like
     – amplify.request provides a clean and elegant request abstraction
        for all types of data, even allowing for transformation prior to
        consumption.
     – amplify.publish/subscribe provides a clean, performant API for
        component to component communication.
     – amplify.store takes the confusion out of HTML5 localStorage. It
        doesn't get simpler than using amplify.store(key, data)! It even
        works flawlessly on mobile devices.
UnderscoreJs
                       Fabio franzini                                fabio@fabiofranzini.com - @franzinifabio




Underscore is a utility library that provides a lots of functions without
extending any of the built-in JavaScript objects



 UnderscoreJs Functions
  Collection   Arrays               Functions     Objects       Utility             Chaining
  •   Each     •   First            •   Bind      •   Keys      •   Random          • Chain
  •   Map      •   Initial          •   BindAll   •   Values    •   uniqueId        • Value
  •   Reduce   •   Union            •   Wrap      •   Extend    •   Escape
  •   Find     •   Etc…             •   Etc…      •   isEqual   •   Etc..
  •   Where                                       •   isEmpty
  •   Any                                         •   Etc…
  •   Etc…
linq.js - LINQ for JavaScript
                          Fabio franzini                                 fabio@fabiofranzini.com - @franzinifabio




•   implement all .NET 4.0 linq to object methods and extra methods
•   complete lazy evaluation
•   full IntelliSense support for VisualStudio
•   two versions: linq.js and jquery.linq.js (jQuery plugin)

var jsonArray = [
   { "user": { "id": 100, "screen_name": "d_linq" }, "text": "to objects" },
   { "user": { "id": 130, "screen_name": "c_bill" }, "text": "g" },
   { "user": { "id": 155, "screen_name": "b_mskk" }, "text": "kabushiki kaisha" },
   { "user": { "id": 301, "screen_name": "a_xbox" }, "text": "halo reach" }
];
var queryResult = Enumerable.From(jsonArray)
   .Where(function (x) { return x.user.id < 200 })
   .OrderBy(function (x) { return x.user.screen_name })
   .Select(function (x) { return x.user.screen_name + ':' + x.text })
   .ToArray();
DurandalJs
                        Fabio franzini                                fabio@fabiofranzini.com - @franzinifabio




Durandal is small JavaScript framework designed to make building Single Page Applications
(SPAs) simple and elegant. We didn't try to re-invent the wheel. Durandal is built on libs you know
and love like jQuery, Knockout and RequireJS. There's little to learn and building apps feels
comfortable and familiar.

•   Clean MV* Architecture
•   JS & HTML Modularity
•   Simple App Lifecycle
•   Eventing, Modals, Message Boxes, etc.
•   Navigation & Screen State Management
•   Consistent Async Programming w/ Promises
•   App Bundling and Optimization
•   Use any Backend Technology
•   Built on top of jQuery, Knockout & RequireJS
•   Integrates with other libraries such as SammyJS & Bootstrap
•   Make jQuery & Bootstrap widgets templatable and bindable (or build your own widgets).
DurandalJs – Demo
Fabio franzini          fabio@fabiofranzini.com - @franzinifabio




             DEMO
           DurandalJs
BreezeJs
                                 Fabio franzini                                                fabio@fabiofranzini.com - @franzinifabio




Breeze is a library for rich client applications written in HTML and JavaScript.
It concentrates on the challenge of building and maintaining highly responsive, data-intensive applications in which users
      search, add, update, and view complex data from different angles as they pursue solutions to real problems in real time.

Features include:
•    Rich queries using a LINQ-like query syntax
•    Client-side caching
•    Change tracking
•    Validation
•    Pluggable back-end
       •    Full integration with the Entity Framework.
       •    Supports WebAPI and OData back-ends.
       •    Works with NoSQL, non-.NET, and SOA back-ends
•    Data management
•    Batched saves
•    Library and Tooling support
       •    Out-of-box support for Knockout, Angular, and Backbone.
       •    TypeScript support for compile-time type checking, classes, interfaces, and inheritance.
       •    IntelliSense support for Visual Studio 2012.
       •    RequireJS-enabled for modular applications.
       •    Open API that allows additional front or back-ends to be plugged in.
BreezeJs
Fabio franzini   fabio@fabiofranzini.com - @franzinifabio
BreezeJs– Demo
Fabio franzini              fabio@fabiofranzini.com - @franzinifabio




                  DEMO
                 BreezeJs
Server Side Tools
           Fabio franzini     fabio@fabiofranzini.com - @franzinifabio




• TypeScript
• ScriptSharp
TypeScript
                    Fabio franzini                      fabio@fabiofranzini.com - @franzinifabio




TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.

•   TypeScript starts from the syntax and semantics that millions of JavaScript
    developers know today.

•   You can use existing JavaScript code, incorporate popular JavaScript
    libraries, and be called from other JavaScript code.

•   Compiles to clean, simple JavaScript code which runs on any browser, in
    Node.js, or in any other ES3-compatible environment.
TypeScript – Simple Example
                       Fabio franzini                     fabio@fabiofranzini.com - @franzinifabio




            TypeScript                                 JavaScript
class Greeter {                           var Greeter = (function () {
   greeting: string;                         function Greeter(message) {
   constructor (message: string) {              this.greeting = message;
      this.greeting = message;               }
   }                                         Greeter.prototype.greet =
   greet() {                                 function () {
      return "Hello, " + this.greeting;         return "Hello, " + this.greeting;
   }                                         };
}                                           return Greeter;
                                          })();
var greeter = new Greeter("world");       var greeter = new Greeter("world");
alert(greeter.greet());                   alert(greeter.greet());
ScriptSharp
                    Fabio franzini                       fabio@fabiofranzini.com - @franzinifabio




Script# is a free tool that generates JavaScript by compiling C# source code.

•   The goal is to enable you to leverage the productivity of C#, the Visual Studio
    IDE, and .NET tools and apply them to your HTML5 development.

•   The Script# compiler is a development/build-time tool that takes a
    pragmatic approach to generating script for use in real-world script-based
    applications, without introducing any unnecessary layers of abstraction.
Package Apps
         Fabio franzini   fabio@fabiofranzini.com - @franzinifabio




• Apache Cordova
• AppJs
Apache Cordova (PhoneGap)
                   Fabio franzini                     fabio@fabiofranzini.com - @franzinifabio




Is a platform for building native mobile applications using HTML, CSS
and JavaScript
• Pros
     – The Power of HTML5
     – Build native App
     – Interact with Device API’s
• Conts
     – Performance of WebBrowser
        Control on target device…
AppJs
                  Fabio franzini                   fabio@fabiofranzini.com - @franzinifabio




AppJS is an SDK to develop desktop applications using Node.js melded
with Chromium.

You get all the following in one package:
• JS, HTML5, CSS, SVG, WebGL — by Chromium
• mature HTTP/HTTPS servers and client APIs — by Node.js
• filesystem, DNS, cryptography, subprocesses, OS APIs — by Node.js
• sandboxed code execution environements, virtual machines — by Node.js
• tools for exposing native C++ bindings to JavaScript — by Node.js
Q&A
    Fabio franzini   fabio@fabiofranzini.com - @franzinifabio




           ;-)
Questions & Answer time!

Contenu connexe

Tendances

STUG-Client Object Model SharePoint 2010
STUG-Client Object Model SharePoint 2010STUG-Client Object Model SharePoint 2010
STUG-Client Object Model SharePoint 2010
Shakir Majeed Khan
 

Tendances (20)

Single page applications & SharePoint
Single page applications & SharePointSingle page applications & SharePoint
Single page applications & SharePoint
 
SPTechCon 2014 How to develop and debug client side code in SharePoint
SPTechCon 2014 How to develop and debug client side code in SharePointSPTechCon 2014 How to develop and debug client side code in SharePoint
SPTechCon 2014 How to develop and debug client side code in SharePoint
 
Chris O'Brien - Comparing SharePoint add-ins (apps) with Office 365 apps
Chris O'Brien - Comparing SharePoint add-ins (apps) with Office 365 appsChris O'Brien - Comparing SharePoint add-ins (apps) with Office 365 apps
Chris O'Brien - Comparing SharePoint add-ins (apps) with Office 365 apps
 
Chris O'Brien - Modern SharePoint sites and the SharePoint Framework - reference
Chris O'Brien - Modern SharePoint sites and the SharePoint Framework - referenceChris O'Brien - Modern SharePoint sites and the SharePoint Framework - reference
Chris O'Brien - Modern SharePoint sites and the SharePoint Framework - reference
 
Chris O'Brien - Modern SharePoint development: techniques for moving code off...
Chris O'Brien - Modern SharePoint development: techniques for moving code off...Chris O'Brien - Modern SharePoint development: techniques for moving code off...
Chris O'Brien - Modern SharePoint development: techniques for moving code off...
 
STUG-Client Object Model SharePoint 2010
STUG-Client Object Model SharePoint 2010STUG-Client Object Model SharePoint 2010
STUG-Client Object Model SharePoint 2010
 
Chris O'Brien - Customizing the SharePoint/Office 365 UI with JavaScript (ESP...
Chris O'Brien - Customizing the SharePoint/Office 365 UI with JavaScript (ESP...Chris O'Brien - Customizing the SharePoint/Office 365 UI with JavaScript (ESP...
Chris O'Brien - Customizing the SharePoint/Office 365 UI with JavaScript (ESP...
 
Bringing HTML5 alive in SharePoint
Bringing HTML5 alive in SharePointBringing HTML5 alive in SharePoint
Bringing HTML5 alive in SharePoint
 
Chris O'Brien - Introduction to the SharePoint Framework for developers
Chris O'Brien - Introduction to the SharePoint Framework for developersChris O'Brien - Introduction to the SharePoint Framework for developers
Chris O'Brien - Introduction to the SharePoint Framework for developers
 
SharePoint REST vs CSOM
SharePoint REST vs CSOMSharePoint REST vs CSOM
SharePoint REST vs CSOM
 
Getting Started with SharePoint Development
Getting Started with SharePoint DevelopmentGetting Started with SharePoint Development
Getting Started with SharePoint Development
 
Industrial training seminar ppt on asp.net
Industrial training seminar ppt on asp.netIndustrial training seminar ppt on asp.net
Industrial training seminar ppt on asp.net
 
O365Con18 - Site Templates, Site Life Cycle Management and Modern SharePoint ...
O365Con18 - Site Templates, Site Life Cycle Management and Modern SharePoint ...O365Con18 - Site Templates, Site Life Cycle Management and Modern SharePoint ...
O365Con18 - Site Templates, Site Life Cycle Management and Modern SharePoint ...
 
Introduction to Client Side Dev in SharePoint Workshop
Introduction to Client Side Dev in SharePoint WorkshopIntroduction to Client Side Dev in SharePoint Workshop
Introduction to Client Side Dev in SharePoint Workshop
 
Connect 2014 - EXTJS in XPages: Modernizing IBM Notes Views Without Sacrifici...
Connect 2014 - EXTJS in XPages: Modernizing IBM Notes Views Without Sacrifici...Connect 2014 - EXTJS in XPages: Modernizing IBM Notes Views Without Sacrifici...
Connect 2014 - EXTJS in XPages: Modernizing IBM Notes Views Without Sacrifici...
 
IBM Digital Experience Theme Customization
IBM Digital Experience Theme CustomizationIBM Digital Experience Theme Customization
IBM Digital Experience Theme Customization
 
HTML5: the new frontier of the web
HTML5: the new frontier of the webHTML5: the new frontier of the web
HTML5: the new frontier of the web
 
Hard learned CSOM and REST tips
Hard learned CSOM and REST tipsHard learned CSOM and REST tips
Hard learned CSOM and REST tips
 
Share point apps the good, the bad, and the pot of gold at the end of the r...
Share point apps   the good, the bad, and the pot of gold at the end of the r...Share point apps   the good, the bad, and the pot of gold at the end of the r...
Share point apps the good, the bad, and the pot of gold at the end of the r...
 
More object oriented development with Page Type Builder
More object oriented development with Page Type BuilderMore object oriented development with Page Type Builder
More object oriented development with Page Type Builder
 

Similaire à Codemotion 2013 - Designing complex applications using html5 and knockoutjs

Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
Jeremy Likness
 
jQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesjQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPages
Mark Roden
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App Engine
Yared Ayalew
 
John Resig Beijing 2010 (English Version)
John Resig Beijing 2010 (English Version)John Resig Beijing 2010 (English Version)
John Resig Beijing 2010 (English Version)
Jia Mi
 

Similaire à Codemotion 2013 - Designing complex applications using html5 and knockoutjs (20)

JavaScript for ASP.NET programmers (webcast) upload
JavaScript for ASP.NET programmers (webcast) uploadJavaScript for ASP.NET programmers (webcast) upload
JavaScript for ASP.NET programmers (webcast) upload
 
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
 
web2py:Web development like a boss
web2py:Web development like a bossweb2py:Web development like a boss
web2py:Web development like a boss
 
Awesome html with ujs, jQuery and coffeescript
Awesome html with ujs, jQuery and coffeescriptAwesome html with ujs, jQuery and coffeescript
Awesome html with ujs, jQuery and coffeescript
 
jQuery: The World's Most Popular JavaScript Library Comes to XPages
jQuery: The World's Most Popular JavaScript Library Comes to XPagesjQuery: The World's Most Popular JavaScript Library Comes to XPages
jQuery: The World's Most Popular JavaScript Library Comes to XPages
 
jQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesjQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPages
 
From Backbone to Ember and Back(bone) Again
From Backbone to Ember and Back(bone) AgainFrom Backbone to Ember and Back(bone) Again
From Backbone to Ember and Back(bone) Again
 
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD CombinationLotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 
Intro to .NET for Government Developers
Intro to .NET for Government DevelopersIntro to .NET for Government Developers
Intro to .NET for Government Developers
 
Angular mobile angular_u
Angular mobile angular_uAngular mobile angular_u
Angular mobile angular_u
 
Life outside WO
Life outside WOLife outside WO
Life outside WO
 
RapidApp - YAPC::NA 2014
RapidApp - YAPC::NA 2014RapidApp - YAPC::NA 2014
RapidApp - YAPC::NA 2014
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App Engine
 
Cordova: Making Native Mobile Apps With Your Web Skills
Cordova: Making Native Mobile Apps With Your Web SkillsCordova: Making Native Mobile Apps With Your Web Skills
Cordova: Making Native Mobile Apps With Your Web Skills
 
2017 03 25 Microsoft Hacks, How to code efficiently
2017 03 25 Microsoft Hacks, How to code efficiently2017 03 25 Microsoft Hacks, How to code efficiently
2017 03 25 Microsoft Hacks, How to code efficiently
 
Service worker API
Service worker APIService worker API
Service worker API
 
Building assets on the fly with Node.js
Building assets on the fly with Node.jsBuilding assets on the fly with Node.js
Building assets on the fly with Node.js
 
John Resig Beijing 2010 (English Version)
John Resig Beijing 2010 (English Version)John Resig Beijing 2010 (English Version)
John Resig Beijing 2010 (English Version)
 
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)
 

Plus de Fabio Franzini

Whymca - Sviluppare applicazioni mobile native in html e javascript
Whymca - Sviluppare applicazioni mobile native in html e javascriptWhymca - Sviluppare applicazioni mobile native in html e javascript
Whymca - Sviluppare applicazioni mobile native in html e javascript
Fabio Franzini
 

Plus de Fabio Franzini (6)

Use the PnP SharePoint Starter Kit to create your intranet in a box
Use the PnP SharePoint Starter Kit to create your intranet in a boxUse the PnP SharePoint Starter Kit to create your intranet in a box
Use the PnP SharePoint Starter Kit to create your intranet in a box
 
All about Office UI Fabric
All about Office UI FabricAll about Office UI Fabric
All about Office UI Fabric
 
All about SPFx
All about SPFxAll about SPFx
All about SPFx
 
Introduction to SharePoint Framework (SPFx)
Introduction to SharePoint Framework (SPFx)Introduction to SharePoint Framework (SPFx)
Introduction to SharePoint Framework (SPFx)
 
Whymca - Sviluppare applicazioni mobile native in html e javascript
Whymca - Sviluppare applicazioni mobile native in html e javascriptWhymca - Sviluppare applicazioni mobile native in html e javascript
Whymca - Sviluppare applicazioni mobile native in html e javascript
 
Sviluppare applicazioni mobile native in html e java script
Sviluppare applicazioni mobile native in html e java scriptSviluppare applicazioni mobile native in html e java script
Sviluppare applicazioni mobile native in html e java script
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Dernier (20)

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 

Codemotion 2013 - Designing complex applications using html5 and knockoutjs

  • 1. Fabio Franzini Designing complex applications using HTML5 and KnockoutJS fabio@fabiofranzini.com - @franzinifabio
  • 2. About Me Fabio franzini fabio@fabiofranzini.com - @franzinifabio  Senior Consultant and Software Engineer  MCT Trainer, MCPD Web Applications, MCTS SharePoint 2010/2007  Official Ignite Trainer for SharePoint 2013 & 2010 in Italy  Web Stack Lover  Over 9 years experience in IT as a software engineer Blog: www.fabiofranzini.com Email: fabio@fabiofranzini.com
  • 3. Agenda Fabio franzini fabio@fabiofranzini.com - @franzinifabio 1. Introduction 2. HTML5 3. JavaScript and Client Side Frameworks 4. Server Side Tools 5. Multiplatform 6. Demo
  • 4. Introduction Fabio franzini fabio@fabiofranzini.com - @franzinifabio What is the keys to create complex applications in javascript without becoming crazy? 1. Write clean code!! 2. Modularization and Reuse of code!! 3. Use frameworks or tools that simplify the work!!
  • 5. Why HTML5? Fabio franzini fabio@fabiofranzini.com - @franzinifabio • Cross Browser • Cross Platform • W3C Standards • All modern browsers and mobile devices supports HTML5 • Rich set of controls and APIs
  • 6. JavaScript is… Fabio franzini fabio@fabiofranzini.com - @franzinifabio • From Wikipedia: – A prototype-based scripting language that is dynamic, weakly typed and has first-class functions. – A multi-paradigm language, supporting object-oriented, imperative, and functional programming styles. • In short, a big mess for most developers :)
  • 7. Modularize your code using the module pattern! Fabio franzini fabio@fabiofranzini.com - @franzinifabio • Group several related elements such as classes, singletons, methods, globally used, into a simple object. • It fakes classes in Javascript. • Pros – Encapsulation, it gives us an API (public and private attributes or methods) – Avoid names conflicting with other function – Easier debugging (public functions are named) • Cons: – Difficult to refactor
  • 8. Module Pattern: Example Fabio franzini fabio@fabiofranzini.com - @franzinifabio var testModule = ( function() { var counter = 0; var privateMethod = function() { // do something…. } return { incrementCounter: function() { return counter++; }, resetCounter: function() { counter = 0; } }; })();
  • 9. Revealing Module Pattern Fabio franzini fabio@fabiofranzini.com - @franzinifabio Coined by Christian Heilmann (Mozilla Foundation) Pros – Sintax more consistent and easy to read – Easier to refactor var myRevealingModule = ( function() { var name = 'John Smith'; function updatePerson() { name = 'John Smith Updated'; } function setPerson (value) { name = value; } return { set: setPerson }; }());
  • 10. RequireJs for implement Module Pattern Fabio franzini fabio@fabiofranzini.com - @franzinifabio • RequireJs is a JavaScript file and module loader. • Using a modular script loader like RequireJS will improve the speed and quality of your code! [myPage.html] <script data-main="scripts/main" src="scripts/require-jquery.js"></script> ….. [main.js] require(["jquery", "jquery.alpha", "jquery.beta"], function($) { //the jquery.alpha.js and jquery.beta.js plugins have been loaded. $(function() { $('body').alpha().beta(); }); });
  • 11. Another Pattern Fabio franzini fabio@fabiofranzini.com - @franzinifabio • MV* Pattern – The MV* Pattern allows to separate the functionalities and introduce greater flexibility to customize the presentation of items – Provides a standard model interface to allow a wide range of data sources to be used with existing item views – Different implementation: MVC, MVP, MVVM • Observer (Pub/Sub) Pattern – It is a design pattern which allows an object (known as a subscriber) to watch another object (the publisher) – Loose coupling, ability to break down our applications into smaller, general manageability
  • 12. KnockoutJs Fabio franzini fabio@fabiofranzini.com - @franzinifabio • Model: It uses the Observable property that can notify subscribers about changes and automatically detect dependencies • View: A KnockoutJs View is simply a HTML document with declarative bindings to link it to the ViewModel • ViewModel: The ViewModel can be considered a specialized Controller that acts as a data converter. It changes Model information into View information, passing commands from the View to the Model
  • 13. KnockoutJs ViewModel Fabio franzini fabio@fabiofranzini.com - @franzinifabio function AppViewModel() { this.firstName = ko.observable("Bert"); this.lastName = ko.observable("Bertington"); this.fullName = ko.computed(function() { return this.firstName() + " " + this.lastName(); }, this); this.capitalizeLastName = function() { var currentVal = this.lastName(); this.lastName(currentVal.toUpperCase()); }; } // Activates knockout.js ko.applyBindings(new AppViewModel());
  • 14. KnockoutJs View Fabio franzini fabio@fabiofranzini.com - @franzinifabio <p>First name: <input data-bind="value: firstName" /></p> <p>Last name: <input data-bind="value: lastName" /></p> <p>Full name: <strong data-bind="text: fullName"></strong></p> <button data-bind="click: capitalizeLastName">Go caps</button>
  • 15. List of other Powerfull JavaScript FX Fabio franzini fabio@fabiofranzini.com - @franzinifabio • AmplifyJs • UnderscoreJs • LinqJs • DurandalJs • BreezeJS
  • 16. AmplifyJs Fabio franzini fabio@fabiofranzini.com - @franzinifabio Is a set of components designed to solve common web application problems with a simplistic API like – amplify.request provides a clean and elegant request abstraction for all types of data, even allowing for transformation prior to consumption. – amplify.publish/subscribe provides a clean, performant API for component to component communication. – amplify.store takes the confusion out of HTML5 localStorage. It doesn't get simpler than using amplify.store(key, data)! It even works flawlessly on mobile devices.
  • 17. UnderscoreJs Fabio franzini fabio@fabiofranzini.com - @franzinifabio Underscore is a utility library that provides a lots of functions without extending any of the built-in JavaScript objects UnderscoreJs Functions Collection Arrays Functions Objects Utility Chaining • Each • First • Bind • Keys • Random • Chain • Map • Initial • BindAll • Values • uniqueId • Value • Reduce • Union • Wrap • Extend • Escape • Find • Etc… • Etc… • isEqual • Etc.. • Where • isEmpty • Any • Etc… • Etc…
  • 18. linq.js - LINQ for JavaScript Fabio franzini fabio@fabiofranzini.com - @franzinifabio • implement all .NET 4.0 linq to object methods and extra methods • complete lazy evaluation • full IntelliSense support for VisualStudio • two versions: linq.js and jquery.linq.js (jQuery plugin) var jsonArray = [ { "user": { "id": 100, "screen_name": "d_linq" }, "text": "to objects" }, { "user": { "id": 130, "screen_name": "c_bill" }, "text": "g" }, { "user": { "id": 155, "screen_name": "b_mskk" }, "text": "kabushiki kaisha" }, { "user": { "id": 301, "screen_name": "a_xbox" }, "text": "halo reach" } ]; var queryResult = Enumerable.From(jsonArray) .Where(function (x) { return x.user.id < 200 }) .OrderBy(function (x) { return x.user.screen_name }) .Select(function (x) { return x.user.screen_name + ':' + x.text }) .ToArray();
  • 19. DurandalJs Fabio franzini fabio@fabiofranzini.com - @franzinifabio Durandal is small JavaScript framework designed to make building Single Page Applications (SPAs) simple and elegant. We didn't try to re-invent the wheel. Durandal is built on libs you know and love like jQuery, Knockout and RequireJS. There's little to learn and building apps feels comfortable and familiar. • Clean MV* Architecture • JS & HTML Modularity • Simple App Lifecycle • Eventing, Modals, Message Boxes, etc. • Navigation & Screen State Management • Consistent Async Programming w/ Promises • App Bundling and Optimization • Use any Backend Technology • Built on top of jQuery, Knockout & RequireJS • Integrates with other libraries such as SammyJS & Bootstrap • Make jQuery & Bootstrap widgets templatable and bindable (or build your own widgets).
  • 20. DurandalJs – Demo Fabio franzini fabio@fabiofranzini.com - @franzinifabio DEMO DurandalJs
  • 21. BreezeJs Fabio franzini fabio@fabiofranzini.com - @franzinifabio Breeze is a library for rich client applications written in HTML and JavaScript. It concentrates on the challenge of building and maintaining highly responsive, data-intensive applications in which users search, add, update, and view complex data from different angles as they pursue solutions to real problems in real time. Features include: • Rich queries using a LINQ-like query syntax • Client-side caching • Change tracking • Validation • Pluggable back-end • Full integration with the Entity Framework. • Supports WebAPI and OData back-ends. • Works with NoSQL, non-.NET, and SOA back-ends • Data management • Batched saves • Library and Tooling support • Out-of-box support for Knockout, Angular, and Backbone. • TypeScript support for compile-time type checking, classes, interfaces, and inheritance. • IntelliSense support for Visual Studio 2012. • RequireJS-enabled for modular applications. • Open API that allows additional front or back-ends to be plugged in.
  • 22. BreezeJs Fabio franzini fabio@fabiofranzini.com - @franzinifabio
  • 23. BreezeJs– Demo Fabio franzini fabio@fabiofranzini.com - @franzinifabio DEMO BreezeJs
  • 24. Server Side Tools Fabio franzini fabio@fabiofranzini.com - @franzinifabio • TypeScript • ScriptSharp
  • 25. TypeScript Fabio franzini fabio@fabiofranzini.com - @franzinifabio TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. • TypeScript starts from the syntax and semantics that millions of JavaScript developers know today. • You can use existing JavaScript code, incorporate popular JavaScript libraries, and be called from other JavaScript code. • Compiles to clean, simple JavaScript code which runs on any browser, in Node.js, or in any other ES3-compatible environment.
  • 26. TypeScript – Simple Example Fabio franzini fabio@fabiofranzini.com - @franzinifabio TypeScript JavaScript class Greeter { var Greeter = (function () { greeting: string; function Greeter(message) { constructor (message: string) { this.greeting = message; this.greeting = message; } } Greeter.prototype.greet = greet() { function () { return "Hello, " + this.greeting; return "Hello, " + this.greeting; } }; } return Greeter; })(); var greeter = new Greeter("world"); var greeter = new Greeter("world"); alert(greeter.greet()); alert(greeter.greet());
  • 27. ScriptSharp Fabio franzini fabio@fabiofranzini.com - @franzinifabio Script# is a free tool that generates JavaScript by compiling C# source code. • The goal is to enable you to leverage the productivity of C#, the Visual Studio IDE, and .NET tools and apply them to your HTML5 development. • The Script# compiler is a development/build-time tool that takes a pragmatic approach to generating script for use in real-world script-based applications, without introducing any unnecessary layers of abstraction.
  • 28. Package Apps Fabio franzini fabio@fabiofranzini.com - @franzinifabio • Apache Cordova • AppJs
  • 29. Apache Cordova (PhoneGap) Fabio franzini fabio@fabiofranzini.com - @franzinifabio Is a platform for building native mobile applications using HTML, CSS and JavaScript • Pros – The Power of HTML5 – Build native App – Interact with Device API’s • Conts – Performance of WebBrowser Control on target device…
  • 30. AppJs Fabio franzini fabio@fabiofranzini.com - @franzinifabio AppJS is an SDK to develop desktop applications using Node.js melded with Chromium. You get all the following in one package: • JS, HTML5, CSS, SVG, WebGL — by Chromium • mature HTTP/HTTPS servers and client APIs — by Node.js • filesystem, DNS, cryptography, subprocesses, OS APIs — by Node.js • sandboxed code execution environements, virtual machines — by Node.js • tools for exposing native C++ bindings to JavaScript — by Node.js
  • 31. Q&A Fabio franzini fabio@fabiofranzini.com - @franzinifabio ;-) Questions & Answer time!