pavlo yuriychuk — switching to angular.js. silk way

16
Switching to Angular.js Silk way

Upload: globallogic-ukraine

Post on 05-Dec-2014

3.272 views

Category:

Technology


3 download

DESCRIPTION

1. What is Angular.JS according to PM and Developer 2. Automation tools stack for Angular.JS development 3. Implementation of a domain using Angular.JS 4. Switching from other frameworks and libraries to Angular 5. Doing it wrong / Doing it right This presentetion is complemented by Ukrainian-languaged presentation by Pavlo — "Павло Юрійчук — Перехід на Angular.js. Howto"

TRANSCRIPT

Page 1: Pavlo Yuriychuk — Switching to Angular.js. Silk way

Switching to Angular.jsSilk way

Page 3: Pavlo Yuriychuk — Switching to Angular.js. Silk way

Angular.js - PM point of view● First release @ Oct 20, 2010, 0.9.0● Contributors:

○ Miško Hevery - original author○ Igor Minar○ Vojta Jina○ Matias Niemelä - Year of Moo blog○ Pete Bacon Darwin

● Reputation of vendor Google Closure && GWT● Docs: O’Reilly book, Packt publishing, Scripty book● Support: Google groups && Github issues● Ecosystem

Page 5: Pavlo Yuriychuk — Switching to Angular.js. Silk way

This presentation is not about worrying ;)

Page 6: Pavlo Yuriychuk — Switching to Angular.js. Silk way

Hierarchy of front-end problems solved by frameworks and libraries1. Cross browser - jQuery, Underscore, Twitter bootstrap2. Applications

a. MV* - Backbone, Exos.JS, Knockout, Ember, Ext.JS, Chaplin, Marionette, Can.JS, Thorax

b. Realtime - Meteor, Derbyc. Functional - Bacon.JS

3. Modularity and packaging - Require.JS || LMD, Bower, Component.JS

4. Infrastructure - Angular.JS, Closure, DojoToolkit

Page 8: Pavlo Yuriychuk — Switching to Angular.js. Silk way
Page 9: Pavlo Yuriychuk — Switching to Angular.js. Silk way

Implementation of domain aspects

● Switch from Inheritance to Dependency Injection

● Decoupling of Model and Collection from connection to the server side

● Directive as the only place to work with DOM● No dedicated router class

Page 10: Pavlo Yuriychuk — Switching to Angular.js. Silk way
Page 11: Pavlo Yuriychuk — Switching to Angular.js. Silk way

Continuation● Factories to store shared data● Services to handle business logic● Providers to store configurable shared data, i.e. i18n,

i10n, routes● Directives to modify DOM and for small components● Views for widgets● Controllers to connect view and services● Decorators to modify the behavior of existing services

Page 12: Pavlo Yuriychuk — Switching to Angular.js. Silk way

Dos and Donts

● if ($scope.$$phase) $apply() / $digest() everywhere - No

● DOM manipulation in controller - No● $.Deferred and $.ajax instead of $http,

$resource, $q● Minsafe [`$http`, function ($http) {}] - Yes

Page 13: Pavlo Yuriychuk — Switching to Angular.js. Silk way

Dos and Donts● Do not try to put custom method into $rootScope● If you have data that is shared between elements that

are using ng-repeat and filters - split it over separate arrays

● Whenever you see $scope.filterByXXX, $scope.mapXXXtoYYY, $scope.getXXXbyYY it is high time to use filters

● Do not put heavyweight operations into $watch and $scope event heandlers

Page 14: Pavlo Yuriychuk — Switching to Angular.js. Silk way

Switching to Angular.js

When not to switch:1. Perhaps you need something simpler,

different paradigm, see the slide #62. Game development3. High-performance data visualization and

rendering (VNC console, real-time video)4. Lightweightness is critical

Page 16: Pavlo Yuriychuk — Switching to Angular.js. Silk way

A little bit of Angular ;)// Insanity Warning: scope depth-first traversal

// yes, this code is a bit crazy, but it works and we have tests to prove it!