20
z JavaScript Architecture Introduction to Scalable Enterprise Level JavaScript Application Architecture with Microsoft's TypeScript - Presented by Michael Kappel http://35z.us/ge otspp

JavaScript Architecture

  • Upload
    nessa

  • View
    48

  • Download
    0

Embed Size (px)

DESCRIPTION

http://35z.us/geotspp. JavaScript Architecture. Introduction to Scalable Enterprise Level JavaScript Application Architecture with Microsoft's TypeScript - Presented by Michael Kappel. Michael Kappel, MCPD. https://www.mcpvirtualbusinesscard.com/VBCServer/MichaelKappel/profile. - PowerPoint PPT Presentation

Citation preview

Page 1: JavaScript Architecture

z

JavaScript ArchitectureIntroduction to Scalable Enterprise Level JavaScript Application

Architecture with Microsoft's TypeScript

- Presented by Michael Kappel

http://35z.us/geotspp

Page 2: JavaScript Architecture

z

Michael Kappel, MCPDhttps://www.mcpvirtualbusinesscard.com/VBCServer/MichaelKappel/profile

http://MichaelKappel.com/

Page 3: JavaScript Architecture

z

What we are going to cover• What is TypeScript and why I chose it for Geotrackable.mobi• TypeScript- vs - DART - vs - CoffeeScript• TypeScript Language Features• Jump into Code, look into Architecture• Some ways to avoid common issues• Wrap-up and give away stuff

Page 4: JavaScript Architecture

z

Geotrackable QR Codes

Page 5: JavaScript Architecture

z

Geotrackable Geocoins

Page 6: JavaScript Architecture

z

Geotrackable.org & Geotrackable.mobi

http://Geotrackable.org http://Geotrackable.mobi

Page 7: JavaScript Architecture

z

Coordinate Converterhttp://geotrackable.mobi/CoordinateConverter/

Page 8: JavaScript Architecture

z

What is TypeScript?• TypeScript is a syntactic sugar for JavaScript. • TypeScript syntax is a superset of Ecmascript 5 (ES5) syntax• TypeScript syntax includes several proposed features of Ecmascript 6

(ES6)

• Top 10 reasons why TypeScript will be widely adopted• http://www.pursuitofgreatdesign.com/2012/10/top-10-reasons-why-typescript-will-be.html

Page 9: JavaScript Architecture

z

TypeScript, DART, & CoffeeScript

Micorsoft / Open Source Google Jeremy Ashkenas / Open Source

Open Sourcehttp://typescript.codeplex.com/

Open Sourcehttps://code.google.com/p/dart/

Open Sourcehttps://github.com/jashkenas/coffee-script/

http://coffeescript.org/http://www.dartlang.org/http://www.typescriptlang.org/

Page 10: JavaScript Architecture

z

CoffeeScript, JavaScript, TypeScript, DART, and ECMA Script 6 Comparison Chart

http://smthngsmwhr.wordpress.com/2013/02/25/javascript-and-friends-coffeescript-dart-and-typescript/JavaScript and Friends: CoffeeScript, Dart and TypeScript

Page 11: JavaScript Architecture

z

TypeScript Language Features• Type Inference

• Type Annotations

• Ambient Declarations

• Classes• Modules• Interfaces• Enumerations

var link:HTMLAnchorElement = <HTMLAnchorElement>document.getElementById('test');link.href = 'http://geotrackable.org';

var node = document.getElementById('test');node.style.color = '#0f0';

declare var ExternalModule: any;ExternalModule.anything = 'value'

Page 12: JavaScript Architecture

z

Enumerations export module Enumerations { //Step 1 - Geographic coordinate conversion Types// //http://en.wikipedia.org/wiki/Geographic_coordinate_conversion// export enum DirectionTypes { North, East, South, West } export enum LatitudeLongitudeTypes { Latitude, Longitude } }

Page 13: JavaScript Architecture

z

Classesexport class PublicKeyInfo implements Interfaces.IPublicKey {

private publicKey: string;

constructor(publicKey: string) { this.publicKey = publicKey; }

get PublicKey(): string { return this.publicKey; }}

Page 14: JavaScript Architecture

z

Interfacesexport interface IStringable {

ToString(): string;

}

export interface ICoordinateConversions extends IStringable {

ToCoordinateDecimal(): ICoordinateDecimal;

ToCoordinateDms(): ICoordinateDms;

ToCoordinateDm(): ICoordinateDm;

}

Page 15: JavaScript Architecture

z

Lambda Expressions export interface IEvent { add(listener: () => void ): void; remove(listener: () => void ): void; trigger(...a: any[]): void;}

Page 16: JavaScript Architecture

z

Definition Files• https://github.com/borisyankov/DefinitelyTyped/tree/master/jquery

• /// <reference path="../jquery.d.ts" />

• /// <reference path="../google.maps.d.ts" />

Page 17: JavaScript Architecture

z

JavaScript Scope And Closuresmodule Geo.Location { export function GetPosition() { navigator.geolocation.getCurrentPosition((position) => { this.GotPosition(new Geo…..Info(position.coords.latitude, position.coords.longitude)); }, (err) => { alert('navigator.geolocation.getCurrentPosition ERROR ' + err.message); }); } function GotPosition(position:Geo.CoordinateConverter.Interfaces.ICoordinateDecimal) { ViewModel.CoordinateInput = position.ToString(); }}

Page 18: JavaScript Architecture

z

Avoiding Problems• If Visual Studio becomes unresponsive oven up the .ts file you last made

changes to in Notepad and remove all the code. Removing code should fix visual studio so you can go back in and re-add it.• If Visual Studio lags adjust Automatic Formatting

Tools->Options->Text Editor->TypeScript->Formatting

Page 19: JavaScript Architecture

z

Helpful Links• Language Specification PDF 35z.com/typescript• TypeScript vs Dart http://youtu.be/5AqbCQuK0gM• Contact Me http://MJK.tel• PowerPoint http://35z.us/geotspp

• Like Software Development Community on Facebook• https://www.facebook.com/pages/Software-Development-Community/2052773329

16057

• Like Geotrackable on Facebook https://www.facebook.com/Geotrackable

Page 20: JavaScript Architecture

z

Geocaching

http://www.opencaching.com/en/#!geocache/OXZTAHD