SlideShare una empresa de Scribd logo
1 de 35
AngularJS
Single Page Applications
Side note: just 1 hour…and I am Italian :-)
• We have a tons of things to say;
• We have a tons of slides (ok, my fault :-P);
• We have huge and complex demos;
• My English is the worst thing you’ll ever hear :-)
• If you, guys, can delay questions, leaving them for the break, it will be
much easier :-)
• Especially for me :-P
Mauro Servienti
CTO @ Mastreeno, Ltd (Dublin)
mauro@mastreeno.com
@mauroservienti
//milestone.topics.it
(English Blog)
RavenDB trainer
NServiceBus trainer/support
Microsoft MVP – Visual C#
Background
• I’m mainly a developer and not a manager despite the CTO title;
• I started with web development 15 years ago, with notepad and a lot
of imagination;
• Then I moved to back-end services, enterprise applications and
desktop software built with Windows Forms and my beloved WPF;
• And finally 2 years ago, due to a project requirement, I jumped back
to the not so beloved JavaScript development :-)
• I hate and love JavaScript at the same time;
Resources
• Slides on SlideShare: //slideshare.net/mauroservienti
• Samples on GitHub: //github.com/mauroservienti
• Repository: Conferences
• Branches:
• 2014/DDDSouthWest
• Full-Stack-Sample
• Directives on GitHub: //github.com/RadicalFx
• Repository: radical-directives
Introduction to AngularJS
Web Application -> Single Page Application (SPA)
• No more “web apps” in the traditional term of web apps (post back
based);
• The browser is simply a container whose role is to host the app,
nothing else;
• Exactly what we have had with Silverlight unless it has been Silverlighted;
• The SPA is a first class citizen application, especially giving a look at
where HTML5, and browsers capabilities such as LocalStorage or
WebSockets, is driving us;
Save Our Souls
• The Hash hidden power:
• http://localhost/myApplication/#/Foo/Bar
• Html(5) custom attributes:
• data-ng-* (ng is the angular reserved name)
• By convention all AngularJS components are prefixed with «$»:
• $window, $http, $scope, $resource, etc…
• $window??? Why not window from the browser DOM?
• Testability! Everything in AngularJS is thought with test and mock in mind;
Warning…
No SEO
repeat after me
No SEO
demo
A first look…
AngularJS foundation
Application, Modules, Controllers & Views, Services
«modules»
• Can be compared to assemblies or namespaces in a .NET world;
• It is not required to define/create modules: it is a good practice;
• Useful to organize our codebase, required if we need to create a really
modular application, where each module can be seen as a plugin;
//creates new module
var module = angular.module( “my.module”, [ … ] );
//grab a reference to an existing module
var module = angular.module( “my.module” );
«application»
• It is a module: so we have at least 1 module;
• Represents the application (pretty obvious);
• Can be compared to the «main» entry point of a C# Program;
• The important thing is that its startup process is a «2 phase startup
process»
• Configuration phase: each module can setup its own configuration
independently;
• Run phase: each module is started and knows that can rely on other modules
to be already configured (but not necessarily started);
• Each module has a 2 phase startup process, Application is the first
one that AngularJS invokes;
«There can be only one» (cit.)
• Not really: at least one per page
• One single page can host multiple apps; I do not see why at the moment but we can;
• One web app can host multiple AngularJS app: generally by «bounded context»
• (but in the end it is up to us)
http request Web Server
<html> pagebrowserAngularJS App
http response
«controllers» & «views»
• As Controllers and Views in MVC with support for 2-way data-binding
as in MVVM via a special “ViewBag” called $scope;
• A View is not required to have a controller: PartialView;
• A design rule of thumb, a must: a controller cannot manipulate the
DOM (period):
• You’ll never try to highjack the HTML in a controller action in Asp.Net MVC so
do not use jQuery here to achieve the same;
• Testing we’ll become a nightmare;
MVVM + MVC + $scope == AngularJS
View Controller
$scope
(ViewBag)
$scope 2 way data-binding
$scope inheritance: be careful
• The parent $scope is “inherited” by child(ren) $scope(s);
• Inherited means that from the child point of view the rule “is a” equals to true, but
due to the way “inheritance” works in JavaScript you can face really cool/strange
behaviors;
$scope.firstName = ‘bla bla…’; //basically dangerous
$scope.model = {
firstName: ‘bla bla…’
}
Main content (ctrl + view + $scope)
Content (ctrl + view + $scope)Menu (ctrl + view + $scope)
Services: the «router»
• We have «services», in the singleton concept of «service»;
• The first you’ll face will be the $routeProvider;
• I love the $stateProvider plugin (made by the team): a powerful
routing engine that replaces the default routing service;
• The role of a routing engine is to match URIs to states/routes/views
Services: the «router»
• We have «services», in the singleton concept of «service»;
• The first you’ll face will be the $routeProvider;
• I love the $stateProvider plugin (made by the team): a powerful
routing engine that replaces the default routing service;
• The role of a routing engine is to match URIs to states/routes/views
TypeScript -> safe JavaScript
• Pros:
• “Compile”* time checks;
• Less prone to errors, the “compiler”* tells us that firstName and FirstName are
not the same thing;
• Our TypeScript code is currently > 90% the same as the ECMA 6 specification;
• The TypeScript compiler writes JavaScript for us;
• Cons:
• More code to write only to benefit of some TypeScript functionalities;
• If you are experienced with JavaScript in the long term you don’t see so many
benefits;
(pure personal opinion)
* it not complied in the sense of compiled :-), “generated” should be the term.
demo
Falling in love with TypeScript
«dependency injection»
• I suppose you noticed that functions and «constructors» (such as
controllers constructors) can declare/have dependencies:
• Even on stuff not owned by AngularJS;
Dependency Injection: the «$injector»
• AngularJS has a built-in dependency injection engine that we are
implicitly configuring:
“controller” registers a transient instance
“constant”, “factory” or “service” registers a singleton instance
«unfortunately» it is only JavaScript
• DI can only be based on the «name» of the component and not on
the type or on the interface;
• AngularJS still allows us to implement cool patterns such as decorator
or chain of responsibility;
• “$inject” is there to survive to the minification process;
Guarantees that AngularJS
knows what we want even if the
minification process has changed
variables names
Asp.Net WebAPI as backend
But not only that :-)
Demo structure
RavenDB
Backend
Services
Queue
(MSMQ)
Web Api
Host
AngularJS
Application
http / ajax
http / requests
SignalR
read
Our focus
demo
Let’s get serious :-)
«services»
• We have already introduced the concept of services (singleton
components):
• In order to register one we can use the factory method on the module;
Regex support
Named «views» &
multiple «views»
per state
Named parameters
$stateProvider
$rootScope / $scope -> $broadcast
• The $rootScope is a special $scope, managed by Angular itself, whose lifetime is
bound to the application one: It is singleton, it is something like the Asp.Net
HttpApplicationState;
• Since we have «UI Composition» everywhere: Various pieces of the application
composed by AngularJS does not know each other (and this is a good thing);
• But there should be some way to allow communication:
• …and on the other side:
real power is in the details
Amazing features
demo
Fire! Fire! Fire! :-)
«filters»
• In the second sample we saw:
ng-repeat=‘d in data’
a «foreach» loop that iterates over the data array;
• from a C# perspective really similar to Linq; we can create our own
“extension methods”:
ng-repeat=‘d in data | myFilter: { /* filter config */ }’
• For a Xaml developers they can be considered as «converters»;
• Can be chained as we like in any binding expression;
• {{data | fA | fB: 10 | fC: { ‘a’: ‘hi, there’, ‘b’: 2 } }}
«directives»
• Have you noticed, if you had time, a code duplication?
• In the header there is the pending command list and in the page too;
• The role of a directive is to allow us to build reusable, visual, components via
composition: UserControls :-)
• A directive hides the dust under the carpet: here we do DOM manipulation;
• It is composed of:
• A «controller»;
• An optional template (it is a view);
• A «link» function whose role is to glue things manipulating the DOM and attach
DOM events;
• Lots of other cool stuff out of our scope;
I’m done, thank you very much!
…and do not shoot to the pianist ;-)

Más contenido relacionado

La actualidad más candente

20160905 - BrisJS - nightwatch testing
20160905 - BrisJS - nightwatch testing20160905 - BrisJS - nightwatch testing
20160905 - BrisJS - nightwatch testingVladimir Roudakov
 
Crash Course in AngularJS + Ionic (Deep dive)
Crash Course in AngularJS + Ionic (Deep dive)Crash Course in AngularJS + Ionic (Deep dive)
Crash Course in AngularJS + Ionic (Deep dive)ColdFusionConference
 
Tutorial: Develop Mobile Applications with AngularJS
Tutorial: Develop Mobile Applications with AngularJSTutorial: Develop Mobile Applications with AngularJS
Tutorial: Develop Mobile Applications with AngularJSPhilipp Burgmer
 
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.js
ForwardJS 2017 -  Fullstack end-to-end Test Automation with node.jsForwardJS 2017 -  Fullstack end-to-end Test Automation with node.js
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.jsMek Srunyu Stittri
 
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Javascript Frameworks Comparison - Angular, Knockout, Ember and BackboneJavascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Javascript Frameworks Comparison - Angular, Knockout, Ember and BackboneDeepu S Nath
 
Tek 2013 - Building Web Apps from a New Angle with AngularJS
Tek 2013 - Building Web Apps from a New Angle with AngularJSTek 2013 - Building Web Apps from a New Angle with AngularJS
Tek 2013 - Building Web Apps from a New Angle with AngularJSPablo Godel
 
Getting Started with React Native (and should I use it at all?)
Getting Started with React Native (and should I use it at all?)Getting Started with React Native (and should I use it at all?)
Getting Started with React Native (and should I use it at all?)Devin Abbott
 
AngularJS best-practices
AngularJS best-practicesAngularJS best-practices
AngularJS best-practicesHenry Tao
 
Node.JS error handling best practices
Node.JS error handling best practicesNode.JS error handling best practices
Node.JS error handling best practicesYoni Goldberg
 
Angular 2 overview
Angular 2 overviewAngular 2 overview
Angular 2 overviewJesse Warden
 
On Selecting JavaScript Frameworks (Women Who Code 10/15)
On Selecting JavaScript Frameworks (Women Who Code 10/15)On Selecting JavaScript Frameworks (Women Who Code 10/15)
On Selecting JavaScript Frameworks (Women Who Code 10/15)Zoe Landon
 
Gettings started with the superheroic JavaScript library AngularJS
Gettings started with the superheroic JavaScript library AngularJSGettings started with the superheroic JavaScript library AngularJS
Gettings started with the superheroic JavaScript library AngularJSArmin Vieweg
 
AngularJS - The Next Big Thing?
AngularJS - The Next Big Thing?AngularJS - The Next Big Thing?
AngularJS - The Next Big Thing?Tom Hombergs
 
Angular js tutorial slides
Angular js tutorial slidesAngular js tutorial slides
Angular js tutorial slidessamhelman
 
Mvvm knockout vs angular
Mvvm knockout vs angularMvvm knockout vs angular
Mvvm knockout vs angularBasarat Syed
 
Testing nightwatch, by David Torroija
Testing nightwatch, by David TorroijaTesting nightwatch, by David Torroija
Testing nightwatch, by David TorroijaDavid Torroija
 
AngularJS vs React JS vs Node JS: Which is Best For Web Development ?
AngularJS vs React JS vs Node JS: Which is Best For Web Development ?AngularJS vs React JS vs Node JS: Which is Best For Web Development ?
AngularJS vs React JS vs Node JS: Which is Best For Web Development ?MarkupBox
 
AngularJS for Legacy Apps
AngularJS for Legacy AppsAngularJS for Legacy Apps
AngularJS for Legacy AppsPeter Drinnan
 

La actualidad más candente (20)

20160905 - BrisJS - nightwatch testing
20160905 - BrisJS - nightwatch testing20160905 - BrisJS - nightwatch testing
20160905 - BrisJS - nightwatch testing
 
Crash Course in AngularJS + Ionic (Deep dive)
Crash Course in AngularJS + Ionic (Deep dive)Crash Course in AngularJS + Ionic (Deep dive)
Crash Course in AngularJS + Ionic (Deep dive)
 
Tutorial: Develop Mobile Applications with AngularJS
Tutorial: Develop Mobile Applications with AngularJSTutorial: Develop Mobile Applications with AngularJS
Tutorial: Develop Mobile Applications with AngularJS
 
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.js
ForwardJS 2017 -  Fullstack end-to-end Test Automation with node.jsForwardJS 2017 -  Fullstack end-to-end Test Automation with node.js
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.js
 
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Javascript Frameworks Comparison - Angular, Knockout, Ember and BackboneJavascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
 
Tek 2013 - Building Web Apps from a New Angle with AngularJS
Tek 2013 - Building Web Apps from a New Angle with AngularJSTek 2013 - Building Web Apps from a New Angle with AngularJS
Tek 2013 - Building Web Apps from a New Angle with AngularJS
 
SxSW 2015
SxSW 2015SxSW 2015
SxSW 2015
 
Getting Started with React Native (and should I use it at all?)
Getting Started with React Native (and should I use it at all?)Getting Started with React Native (and should I use it at all?)
Getting Started with React Native (and should I use it at all?)
 
AngularJS best-practices
AngularJS best-practicesAngularJS best-practices
AngularJS best-practices
 
Node.JS error handling best practices
Node.JS error handling best practicesNode.JS error handling best practices
Node.JS error handling best practices
 
Angular 2 overview
Angular 2 overviewAngular 2 overview
Angular 2 overview
 
On Selecting JavaScript Frameworks (Women Who Code 10/15)
On Selecting JavaScript Frameworks (Women Who Code 10/15)On Selecting JavaScript Frameworks (Women Who Code 10/15)
On Selecting JavaScript Frameworks (Women Who Code 10/15)
 
Gettings started with the superheroic JavaScript library AngularJS
Gettings started with the superheroic JavaScript library AngularJSGettings started with the superheroic JavaScript library AngularJS
Gettings started with the superheroic JavaScript library AngularJS
 
Getting started with angular js
Getting started with angular jsGetting started with angular js
Getting started with angular js
 
AngularJS - The Next Big Thing?
AngularJS - The Next Big Thing?AngularJS - The Next Big Thing?
AngularJS - The Next Big Thing?
 
Angular js tutorial slides
Angular js tutorial slidesAngular js tutorial slides
Angular js tutorial slides
 
Mvvm knockout vs angular
Mvvm knockout vs angularMvvm knockout vs angular
Mvvm knockout vs angular
 
Testing nightwatch, by David Torroija
Testing nightwatch, by David TorroijaTesting nightwatch, by David Torroija
Testing nightwatch, by David Torroija
 
AngularJS vs React JS vs Node JS: Which is Best For Web Development ?
AngularJS vs React JS vs Node JS: Which is Best For Web Development ?AngularJS vs React JS vs Node JS: Which is Best For Web Development ?
AngularJS vs React JS vs Node JS: Which is Best For Web Development ?
 
AngularJS for Legacy Apps
AngularJS for Legacy AppsAngularJS for Legacy Apps
AngularJS for Legacy Apps
 

Similar a Angular js

Integrating AngularJS into the Campus CMS
Integrating AngularJS into the Campus CMSIntegrating AngularJS into the Campus CMS
Integrating AngularJS into the Campus CMSTom Borger
 
AngularJS Beginners Workshop
AngularJS Beginners WorkshopAngularJS Beginners Workshop
AngularJS Beginners WorkshopSathish VJ
 
Angularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetupAngularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetupGoutam Dey
 
AngularJs presentation
AngularJs presentation AngularJs presentation
AngularJs presentation Phan Tuan
 
Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5Ganesh Kondal
 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to conceptsAbhishek Sur
 
End to-End SPA Development Using ASP.NET and AngularJS
End to-End SPA Development Using ASP.NET and AngularJSEnd to-End SPA Development Using ASP.NET and AngularJS
End to-End SPA Development Using ASP.NET and AngularJSGil Fink
 
Valentine with Angular js - Introduction
Valentine with Angular js - IntroductionValentine with Angular js - Introduction
Valentine with Angular js - IntroductionSenthil Kumar
 
Web worker in your angular application
Web worker in your angular applicationWeb worker in your angular application
Web worker in your angular applicationSuresh Patidar
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - IntroductionSagar Acharya
 
Lightweight webdev
Lightweight webdevLightweight webdev
Lightweight webdevdamianofusco
 
Escaping the yellow bubble - rewriting Domino using MongoDb and Angular
Escaping the yellow bubble - rewriting Domino using MongoDb and AngularEscaping the yellow bubble - rewriting Domino using MongoDb and Angular
Escaping the yellow bubble - rewriting Domino using MongoDb and AngularMark Leusink
 
Pearls and Must-Have Tools for the Modern Web / .NET Developer
Pearls and Must-Have Tools for the Modern Web / .NET DeveloperPearls and Must-Have Tools for the Modern Web / .NET Developer
Pearls and Must-Have Tools for the Modern Web / .NET DeveloperOfer Zelig
 
How I learned to stop worrying and love embedding JavaScript
How I learned to stop worrying and love embedding JavaScriptHow I learned to stop worrying and love embedding JavaScript
How I learned to stop worrying and love embedding JavaScriptKevin Read
 
Embedding V8 in Android apps with Ejecta-V8
Embedding V8 in Android apps with Ejecta-V8Embedding V8 in Android apps with Ejecta-V8
Embedding V8 in Android apps with Ejecta-V8Kevin Read
 
Advanced AngularJS Tips and Tricks
Advanced AngularJS Tips and TricksAdvanced AngularJS Tips and Tricks
Advanced AngularJS Tips and TricksJeremy Likness
 

Similar a Angular js (20)

Integrating AngularJS into the Campus CMS
Integrating AngularJS into the Campus CMSIntegrating AngularJS into the Campus CMS
Integrating AngularJS into the Campus CMS
 
AngularJS Beginners Workshop
AngularJS Beginners WorkshopAngularJS Beginners Workshop
AngularJS Beginners Workshop
 
Angularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetupAngularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetup
 
AngularJs presentation
AngularJs presentation AngularJs presentation
AngularJs presentation
 
Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5
 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to concepts
 
End to-End SPA Development Using ASP.NET and AngularJS
End to-End SPA Development Using ASP.NET and AngularJSEnd to-End SPA Development Using ASP.NET and AngularJS
End to-End SPA Development Using ASP.NET and AngularJS
 
Valentine with Angular js - Introduction
Valentine with Angular js - IntroductionValentine with Angular js - Introduction
Valentine with Angular js - Introduction
 
Web worker in your angular application
Web worker in your angular applicationWeb worker in your angular application
Web worker in your angular application
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - Introduction
 
Lightweight webdev
Lightweight webdevLightweight webdev
Lightweight webdev
 
Escaping the yellow bubble - rewriting Domino using MongoDb and Angular
Escaping the yellow bubble - rewriting Domino using MongoDb and AngularEscaping the yellow bubble - rewriting Domino using MongoDb and Angular
Escaping the yellow bubble - rewriting Domino using MongoDb and Angular
 
Pearls and Must-Have Tools for the Modern Web / .NET Developer
Pearls and Must-Have Tools for the Modern Web / .NET DeveloperPearls and Must-Have Tools for the Modern Web / .NET Developer
Pearls and Must-Have Tools for the Modern Web / .NET Developer
 
Intro to AngularJs
Intro to AngularJsIntro to AngularJs
Intro to AngularJs
 
Angularjs
AngularjsAngularjs
Angularjs
 
Introduction to AngularJs
Introduction to AngularJsIntroduction to AngularJs
Introduction to AngularJs
 
How I learned to stop worrying and love embedding JavaScript
How I learned to stop worrying and love embedding JavaScriptHow I learned to stop worrying and love embedding JavaScript
How I learned to stop worrying and love embedding JavaScript
 
Embedding V8 in Android apps with Ejecta-V8
Embedding V8 in Android apps with Ejecta-V8Embedding V8 in Android apps with Ejecta-V8
Embedding V8 in Android apps with Ejecta-V8
 
Angular js for Beginnners
Angular js for BeginnnersAngular js for Beginnners
Angular js for Beginnners
 
Advanced AngularJS Tips and Tricks
Advanced AngularJS Tips and TricksAdvanced AngularJS Tips and Tricks
Advanced AngularJS Tips and Tricks
 

Más de Mauro Servienti

Welcome to the (state) machine @ ExploreDDD 2019
Welcome to the (state) machine @ ExploreDDD 2019Welcome to the (state) machine @ ExploreDDD 2019
Welcome to the (state) machine @ ExploreDDD 2019Mauro Servienti
 
Designing a ui for microservices @ .NET Day Switzerland 2019
Designing a ui for microservices @ .NET Day Switzerland 2019Designing a ui for microservices @ .NET Day Switzerland 2019
Designing a ui for microservices @ .NET Day Switzerland 2019Mauro Servienti
 
Welcome to the (state) machine @ Xe One Day Enterprise Applications
Welcome to the (state) machine @ Xe One Day Enterprise ApplicationsWelcome to the (state) machine @ Xe One Day Enterprise Applications
Welcome to the (state) machine @ Xe One Day Enterprise ApplicationsMauro Servienti
 
All our aggregates are wrong @ NDC Copenhagen 2019
All our aggregates are wrong @ NDC Copenhagen 2019All our aggregates are wrong @ NDC Copenhagen 2019
All our aggregates are wrong @ NDC Copenhagen 2019Mauro Servienti
 
Be like water, my friend @ Agile for Innovation 2019
Be like water, my friend @ Agile for Innovation 2019Be like water, my friend @ Agile for Innovation 2019
Be like water, my friend @ Agile for Innovation 2019Mauro Servienti
 
Microservices architecture is it the right choice to design long-living syste...
Microservices architecture is it the right choice to design long-living syste...Microservices architecture is it the right choice to design long-living syste...
Microservices architecture is it the right choice to design long-living syste...Mauro Servienti
 
Titles, abstracts, and bio matter... oh my! @ Global Diversity CFP Day 2019
Titles, abstracts, and bio matter... oh my! @ Global Diversity CFP Day 2019Titles, abstracts, and bio matter... oh my! @ Global Diversity CFP Day 2019
Titles, abstracts, and bio matter... oh my! @ Global Diversity CFP Day 2019Mauro Servienti
 
Living organizations, particular software @ do IT Better Parma
Living organizations, particular software @ do IT Better ParmaLiving organizations, particular software @ do IT Better Parma
Living organizations, particular software @ do IT Better ParmaMauro Servienti
 
Welcome to the (state) machine @ Crafted Software
Welcome to the (state) machine @ Crafted SoftwareWelcome to the (state) machine @ Crafted Software
Welcome to the (state) machine @ Crafted SoftwareMauro Servienti
 
PO is dead, long live the PO - Italian Agile Day 2018
PO is dead, long live the PO - Italian Agile Day 2018PO is dead, long live the PO - Italian Agile Day 2018
PO is dead, long live the PO - Italian Agile Day 2018Mauro Servienti
 
Design a UI for your Microservices @ Do IT Better
Design a UI for your Microservices @ Do IT BetterDesign a UI for your Microservices @ Do IT Better
Design a UI for your Microservices @ Do IT BetterMauro Servienti
 
Microservices and pineapple on pizza what do they have in common - dos and ...
Microservices and pineapple on pizza   what do they have in common - dos and ...Microservices and pineapple on pizza   what do they have in common - dos and ...
Microservices and pineapple on pizza what do they have in common - dos and ...Mauro Servienti
 
All our aggregates are wrong (ExploreDDD 2018)
All our aggregates are wrong (ExploreDDD 2018)All our aggregates are wrong (ExploreDDD 2018)
All our aggregates are wrong (ExploreDDD 2018)Mauro Servienti
 
Designing a ui for microservices
Designing a ui for microservicesDesigning a ui for microservices
Designing a ui for microservicesMauro Servienti
 
Po is dead, long live the po
Po is dead, long live the poPo is dead, long live the po
Po is dead, long live the poMauro Servienti
 
Shipping code is not the problem, deciding what to ship it is!
Shipping code is not the problem, deciding what to ship it is!Shipping code is not the problem, deciding what to ship it is!
Shipping code is not the problem, deciding what to ship it is!Mauro Servienti
 
GraphQL - Where are you from? Where are you going?
GraphQL - Where are you from? Where are you going?GraphQL - Where are you from? Where are you going?
GraphQL - Where are you from? Where are you going?Mauro Servienti
 
Dall'idea al deploy un lungo viaggio che passa per git flow e semver
Dall'idea al deploy   un lungo viaggio che passa per git flow e semverDall'idea al deploy   un lungo viaggio che passa per git flow e semver
Dall'idea al deploy un lungo viaggio che passa per git flow e semverMauro Servienti
 
Progettare una UI per i Microservices
Progettare una UI per i MicroservicesProgettare una UI per i Microservices
Progettare una UI per i MicroservicesMauro Servienti
 
The road to a Service Oriented Architecture is paved with messages
The road to a Service Oriented Architecture is paved with messagesThe road to a Service Oriented Architecture is paved with messages
The road to a Service Oriented Architecture is paved with messagesMauro Servienti
 

Más de Mauro Servienti (20)

Welcome to the (state) machine @ ExploreDDD 2019
Welcome to the (state) machine @ ExploreDDD 2019Welcome to the (state) machine @ ExploreDDD 2019
Welcome to the (state) machine @ ExploreDDD 2019
 
Designing a ui for microservices @ .NET Day Switzerland 2019
Designing a ui for microservices @ .NET Day Switzerland 2019Designing a ui for microservices @ .NET Day Switzerland 2019
Designing a ui for microservices @ .NET Day Switzerland 2019
 
Welcome to the (state) machine @ Xe One Day Enterprise Applications
Welcome to the (state) machine @ Xe One Day Enterprise ApplicationsWelcome to the (state) machine @ Xe One Day Enterprise Applications
Welcome to the (state) machine @ Xe One Day Enterprise Applications
 
All our aggregates are wrong @ NDC Copenhagen 2019
All our aggregates are wrong @ NDC Copenhagen 2019All our aggregates are wrong @ NDC Copenhagen 2019
All our aggregates are wrong @ NDC Copenhagen 2019
 
Be like water, my friend @ Agile for Innovation 2019
Be like water, my friend @ Agile for Innovation 2019Be like water, my friend @ Agile for Innovation 2019
Be like water, my friend @ Agile for Innovation 2019
 
Microservices architecture is it the right choice to design long-living syste...
Microservices architecture is it the right choice to design long-living syste...Microservices architecture is it the right choice to design long-living syste...
Microservices architecture is it the right choice to design long-living syste...
 
Titles, abstracts, and bio matter... oh my! @ Global Diversity CFP Day 2019
Titles, abstracts, and bio matter... oh my! @ Global Diversity CFP Day 2019Titles, abstracts, and bio matter... oh my! @ Global Diversity CFP Day 2019
Titles, abstracts, and bio matter... oh my! @ Global Diversity CFP Day 2019
 
Living organizations, particular software @ do IT Better Parma
Living organizations, particular software @ do IT Better ParmaLiving organizations, particular software @ do IT Better Parma
Living organizations, particular software @ do IT Better Parma
 
Welcome to the (state) machine @ Crafted Software
Welcome to the (state) machine @ Crafted SoftwareWelcome to the (state) machine @ Crafted Software
Welcome to the (state) machine @ Crafted Software
 
PO is dead, long live the PO - Italian Agile Day 2018
PO is dead, long live the PO - Italian Agile Day 2018PO is dead, long live the PO - Italian Agile Day 2018
PO is dead, long live the PO - Italian Agile Day 2018
 
Design a UI for your Microservices @ Do IT Better
Design a UI for your Microservices @ Do IT BetterDesign a UI for your Microservices @ Do IT Better
Design a UI for your Microservices @ Do IT Better
 
Microservices and pineapple on pizza what do they have in common - dos and ...
Microservices and pineapple on pizza   what do they have in common - dos and ...Microservices and pineapple on pizza   what do they have in common - dos and ...
Microservices and pineapple on pizza what do they have in common - dos and ...
 
All our aggregates are wrong (ExploreDDD 2018)
All our aggregates are wrong (ExploreDDD 2018)All our aggregates are wrong (ExploreDDD 2018)
All our aggregates are wrong (ExploreDDD 2018)
 
Designing a ui for microservices
Designing a ui for microservicesDesigning a ui for microservices
Designing a ui for microservices
 
Po is dead, long live the po
Po is dead, long live the poPo is dead, long live the po
Po is dead, long live the po
 
Shipping code is not the problem, deciding what to ship it is!
Shipping code is not the problem, deciding what to ship it is!Shipping code is not the problem, deciding what to ship it is!
Shipping code is not the problem, deciding what to ship it is!
 
GraphQL - Where are you from? Where are you going?
GraphQL - Where are you from? Where are you going?GraphQL - Where are you from? Where are you going?
GraphQL - Where are you from? Where are you going?
 
Dall'idea al deploy un lungo viaggio che passa per git flow e semver
Dall'idea al deploy   un lungo viaggio che passa per git flow e semverDall'idea al deploy   un lungo viaggio che passa per git flow e semver
Dall'idea al deploy un lungo viaggio che passa per git flow e semver
 
Progettare una UI per i Microservices
Progettare una UI per i MicroservicesProgettare una UI per i Microservices
Progettare una UI per i Microservices
 
The road to a Service Oriented Architecture is paved with messages
The road to a Service Oriented Architecture is paved with messagesThe road to a Service Oriented Architecture is paved with messages
The road to a Service Oriented Architecture is paved with messages
 

Último

Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 

Último (20)

Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 

Angular js

  • 2. Side note: just 1 hour…and I am Italian :-) • We have a tons of things to say; • We have a tons of slides (ok, my fault :-P); • We have huge and complex demos; • My English is the worst thing you’ll ever hear :-) • If you, guys, can delay questions, leaving them for the break, it will be much easier :-) • Especially for me :-P
  • 3. Mauro Servienti CTO @ Mastreeno, Ltd (Dublin) mauro@mastreeno.com @mauroservienti //milestone.topics.it (English Blog) RavenDB trainer NServiceBus trainer/support Microsoft MVP – Visual C#
  • 4. Background • I’m mainly a developer and not a manager despite the CTO title; • I started with web development 15 years ago, with notepad and a lot of imagination; • Then I moved to back-end services, enterprise applications and desktop software built with Windows Forms and my beloved WPF; • And finally 2 years ago, due to a project requirement, I jumped back to the not so beloved JavaScript development :-) • I hate and love JavaScript at the same time;
  • 5. Resources • Slides on SlideShare: //slideshare.net/mauroservienti • Samples on GitHub: //github.com/mauroservienti • Repository: Conferences • Branches: • 2014/DDDSouthWest • Full-Stack-Sample • Directives on GitHub: //github.com/RadicalFx • Repository: radical-directives
  • 7. Web Application -> Single Page Application (SPA) • No more “web apps” in the traditional term of web apps (post back based); • The browser is simply a container whose role is to host the app, nothing else; • Exactly what we have had with Silverlight unless it has been Silverlighted; • The SPA is a first class citizen application, especially giving a look at where HTML5, and browsers capabilities such as LocalStorage or WebSockets, is driving us;
  • 8. Save Our Souls • The Hash hidden power: • http://localhost/myApplication/#/Foo/Bar • Html(5) custom attributes: • data-ng-* (ng is the angular reserved name) • By convention all AngularJS components are prefixed with «$»: • $window, $http, $scope, $resource, etc… • $window??? Why not window from the browser DOM? • Testability! Everything in AngularJS is thought with test and mock in mind;
  • 11. AngularJS foundation Application, Modules, Controllers & Views, Services
  • 12. «modules» • Can be compared to assemblies or namespaces in a .NET world; • It is not required to define/create modules: it is a good practice; • Useful to organize our codebase, required if we need to create a really modular application, where each module can be seen as a plugin; //creates new module var module = angular.module( “my.module”, [ … ] ); //grab a reference to an existing module var module = angular.module( “my.module” );
  • 13. «application» • It is a module: so we have at least 1 module; • Represents the application (pretty obvious); • Can be compared to the «main» entry point of a C# Program; • The important thing is that its startup process is a «2 phase startup process» • Configuration phase: each module can setup its own configuration independently; • Run phase: each module is started and knows that can rely on other modules to be already configured (but not necessarily started); • Each module has a 2 phase startup process, Application is the first one that AngularJS invokes;
  • 14. «There can be only one» (cit.) • Not really: at least one per page • One single page can host multiple apps; I do not see why at the moment but we can; • One web app can host multiple AngularJS app: generally by «bounded context» • (but in the end it is up to us) http request Web Server <html> pagebrowserAngularJS App http response
  • 15. «controllers» & «views» • As Controllers and Views in MVC with support for 2-way data-binding as in MVVM via a special “ViewBag” called $scope; • A View is not required to have a controller: PartialView; • A design rule of thumb, a must: a controller cannot manipulate the DOM (period): • You’ll never try to highjack the HTML in a controller action in Asp.Net MVC so do not use jQuery here to achieve the same; • Testing we’ll become a nightmare;
  • 16. MVVM + MVC + $scope == AngularJS View Controller $scope (ViewBag) $scope 2 way data-binding
  • 17. $scope inheritance: be careful • The parent $scope is “inherited” by child(ren) $scope(s); • Inherited means that from the child point of view the rule “is a” equals to true, but due to the way “inheritance” works in JavaScript you can face really cool/strange behaviors; $scope.firstName = ‘bla bla…’; //basically dangerous $scope.model = { firstName: ‘bla bla…’ } Main content (ctrl + view + $scope) Content (ctrl + view + $scope)Menu (ctrl + view + $scope)
  • 18. Services: the «router» • We have «services», in the singleton concept of «service»; • The first you’ll face will be the $routeProvider; • I love the $stateProvider plugin (made by the team): a powerful routing engine that replaces the default routing service; • The role of a routing engine is to match URIs to states/routes/views
  • 19. Services: the «router» • We have «services», in the singleton concept of «service»; • The first you’ll face will be the $routeProvider; • I love the $stateProvider plugin (made by the team): a powerful routing engine that replaces the default routing service; • The role of a routing engine is to match URIs to states/routes/views
  • 20. TypeScript -> safe JavaScript • Pros: • “Compile”* time checks; • Less prone to errors, the “compiler”* tells us that firstName and FirstName are not the same thing; • Our TypeScript code is currently > 90% the same as the ECMA 6 specification; • The TypeScript compiler writes JavaScript for us; • Cons: • More code to write only to benefit of some TypeScript functionalities; • If you are experienced with JavaScript in the long term you don’t see so many benefits; (pure personal opinion) * it not complied in the sense of compiled :-), “generated” should be the term.
  • 21. demo Falling in love with TypeScript
  • 22. «dependency injection» • I suppose you noticed that functions and «constructors» (such as controllers constructors) can declare/have dependencies: • Even on stuff not owned by AngularJS;
  • 23. Dependency Injection: the «$injector» • AngularJS has a built-in dependency injection engine that we are implicitly configuring: “controller” registers a transient instance “constant”, “factory” or “service” registers a singleton instance
  • 24. «unfortunately» it is only JavaScript • DI can only be based on the «name» of the component and not on the type or on the interface; • AngularJS still allows us to implement cool patterns such as decorator or chain of responsibility; • “$inject” is there to survive to the minification process; Guarantees that AngularJS knows what we want even if the minification process has changed variables names
  • 25. Asp.Net WebAPI as backend But not only that :-)
  • 28. «services» • We have already introduced the concept of services (singleton components): • In order to register one we can use the factory method on the module;
  • 29. Regex support Named «views» & multiple «views» per state Named parameters $stateProvider
  • 30. $rootScope / $scope -> $broadcast • The $rootScope is a special $scope, managed by Angular itself, whose lifetime is bound to the application one: It is singleton, it is something like the Asp.Net HttpApplicationState; • Since we have «UI Composition» everywhere: Various pieces of the application composed by AngularJS does not know each other (and this is a good thing); • But there should be some way to allow communication: • …and on the other side:
  • 31. real power is in the details Amazing features
  • 33. «filters» • In the second sample we saw: ng-repeat=‘d in data’ a «foreach» loop that iterates over the data array; • from a C# perspective really similar to Linq; we can create our own “extension methods”: ng-repeat=‘d in data | myFilter: { /* filter config */ }’ • For a Xaml developers they can be considered as «converters»; • Can be chained as we like in any binding expression; • {{data | fA | fB: 10 | fC: { ‘a’: ‘hi, there’, ‘b’: 2 } }}
  • 34. «directives» • Have you noticed, if you had time, a code duplication? • In the header there is the pending command list and in the page too; • The role of a directive is to allow us to build reusable, visual, components via composition: UserControls :-) • A directive hides the dust under the carpet: here we do DOM manipulation; • It is composed of: • A «controller»; • An optional template (it is a view); • A «link» function whose role is to glue things manipulating the DOM and attach DOM events; • Lots of other cool stuff out of our scope;
  • 35. I’m done, thank you very much! …and do not shoot to the pianist ;-)