17
Design Principles of Miško Hevery Father of AngularJS

Design Principles of

  • Upload
    ratana

  • View
    60

  • Download
    0

Embed Size (px)

DESCRIPTION

Design Principles of . Mi š ko Hevery Father of AngularJS. The Principles. Boilerplate. D.R.Y. Structure. Testability. 2009: GetAngular. . Results. Project. 17,000 LOC. 1,500 LOC. Before. with Angular. . . . RAM. . . . Database. - PowerPoint PPT Presentation

Citation preview

Page 1: Design Principles of

Design Principles of

Miško HeveryFather of AngularJS

Page 2: Design Principles of

The Principles

Boilerplate

D.R.Y. Structure Testability

Page 3: Design Principles of

<angular/>

2009: GetAngular

Page 4: Design Principles of

with Angular

1,500 LOC

Before

17,000 LOC

Project Results

Page 5: Design Principles of

DatabaseRAM

<div>

<span> <ul>

<li><li><li>

Page 6: Design Principles of

Data Binding<html ng-app><body> <input ng-model='user.name'> <p ng-show='user.name'>Hi {{user.name}}</p>

<script src='angular.js'></script></body></html>

Eureka: DOM

Page 7: Design Principles of

RAM

{{ databinding }}

Logic<div>

<span> <ul>

<li><li><li>

Page 8: Design Principles of

function UserCtrl() {

this.user = {

first:'Larry',

last:'Page'

};

this.bye = function() {

alert('bye:' + this.user.first);

};

}

<html ng-app>

<body ng-controller='UserCtrl as uCtrl'>

Hi <input ng-model='uCtrl.user.first'>

<button ng-click='uCtrl.bye()'>bye</button>

<script src='angular.js'></script>

<script src='UserControllers.js'></script>

</body>

</html>

MVC

index.html UserController.js

Page 9: Design Principles of

Structure

ManagesNotifies

Observes

Logic / Controller(JS Classes)

UI / View(DOM) RAM

Data / Model(JS Objects)

<div>

<span> <ul>

<li>

Page 10: Design Principles of

Dependency Injectionfunction UserController(voiceSynth) {

this.user = { first:'Larry', last: 'Page' };

this.bye = function() { voiceSynth.say('bye') };

}

function VoiceSynth(webAudio) {

this.say = function(text) {// do Web Audio stuff};

};

var myApp = angular.module('myApp', []);

myApp.controller('UserController', UserController);

myApp.service('voiceSynth', VoiceSynth);

Module: myApp

UserController

WebAudio

VoiceSynth

View (DOM)

Page 11: Design Principles of

Module: myMocks -> myApp

Dependency Injection: Mocking

function VoiceSynthMock() {

this.say = function(text) {

this.said.push(text);

};

this.said = [];

};

var myMocks = angular.module('myMocks', ['myApp']);

myApp.service('voiceSynth', VoiceSynthMock);

UserController

VoiceSynthMock

WebAudio

VoiceSynth

View (DOM)

Page 12: Design Principles of

Eureka!!! my-tab

my-panemy-map

Imperative{{ databinding }}ng-hideng-controllerng-model

Declarative

Page 13: Design Principles of

Directives as Components

<rating max="5" model="stars.average">

</rating>

<tabs>

<tab title="Active tab">...</tab>

<tab title="Inactive tab">...</tab>

</tabs>

<span tooltip="{{messages.tip1}}">

Page 14: Design Principles of

Live Coding

Page 15: Design Principles of

Community

Page 16: Design Principles of

EcosystemTools UI Components Libraries Books

AngularUIBatarang

Page 17: Design Principles of

Thank You!angularjs.org

+angularjs@angularjs@mhevery

Code samples: http://goo.gl/N1sCd