SlideShare a Scribd company logo
Thinking in Components
Web Components, Polymer, React.js, Angular.js
Anton Ivanov, Helsinki.js, 28.04.2015
Why?
● Maintainability
● Code reuse
● Similar to classes, functions
● Familiar concept
1997
2015
div soup
A bit of Philosophy
Powerful Language
“Every powerful language has three mechanisms:
● primitive expressions - which represent the
simplest entities the language is concerned with
● means of combination, by which compound
elements are built from simpler ones, and
● means of abstraction, by which compound
elements can be named and manipulated as units”
“Structure and Interpretation of Computer
Programs”, The MIT Press, ISBN-10: 0262510871
Web Components
● HTML imports
● Custom elements
● Shadow DOM
● Templates
Set of standards, a bit like DOM. Provides low
level mechanisms.
HTML Imports
● #include for HTML
● Styles, scripts, markup imported together
<link rel="import" href="breadcrumbs.html">
Custom Elements
● Extend HTML
● Standard APIs continue working
var prototype = Object.create(HTMLElement.prototype);
prototype.setPath = function(path) {...};
document.registerElement('comp-breadcrumbs', {
prototype: prototype
});
Shadow DOM
● Hide markup implementation details
● Shadow root
prototype.createdCallback = function() {
...
this.createShadowRoot().appendChild(element);
};
Shadow DOM
● Already used by <video> in Chrome
Templates
● Inert pieces of markup
● No advanced binding, not like Mustache
● Styles
<template id="breadcrumbs-template">
<style>
…
</style>
<div class="breadcrumbs"></div>
</template>
Templates
● To activate should be imported
prototype.createdCallback = function() {
var element = document.importNode(template.content,
true);
...
this.createShadowRoot().appendChild(element);
};
Demo
● Source
● Viewable in Chrome
Polymer
● Enables support of new standards
● Advanced templating, inheritance
● Set of ready to extend useful components
● Minor differences with the standards
Library built on top of Web Components
standards, like jQuery in 2000s.
Advanced Templating
● Loops, conditionals
● Data binding
<template id="breadcrumbs-template">
…
<div class="breadcrumbs" on-keypress="{{_onKeypress}}">
<template id="crumbs" repeat="{{crumb, index in crumbs}}">
...
</template>
</div>
</template>
Useful Components
● core-item, core-ajax, core-collapse, etc.
● Inherit to use in your component
<polymer-element name="my-element" extends="core-ajax">
Demo
● Source or standards-only source
● Viewable not only in Chrome
React.js
● Components ~ functions
● Declarative
● Everything is a component
● Own tree of components in memory
● Clever to re-render only what's needed
Transforms data into 'immutable' HTML via a
tree of components. View library not a
framework.
Component
● render method
● Life cycle hooks
● props - immutable state, set as attributes
● state – mutable state
● Hierarchy of components, data 'flows' from
root
Component
var CrumbSeparator = React.createClass({
render: function() {
return (
<span className="crumb-separator"
title={this.props.tooltip}>{this.props.value}</span>
)
}
});
● Declarative, functional-like
● JSX for templates
Component
var BreadcrumbsDemo = React.createClass({
...
render: function() {
return (
<div>
<div id="breadcrumb-container">
<Breadcrumbs path={this.state.path} maxEntries="5"
onChange={this.onPathChange}/>
</div>
...
</div>
)
● Nesting
Flux
● How data should be fed to component tree
● Data flows through one control point
Recommended architecture for React.
Flux
Demo
● Source
● Viewable
Angular.js
● Testability
● Templates, view updates
● Directives
● Predefined directives
● Components implemented as directives,
not a central feature
MVC framework. Enhances HTML annotated
with directives, handles routine tasks.
Testability
angular.module('Components')
.controller('breadcrumbsController', function ($scope) {
…
});
● Dependency injection
● Modularity
Templates
<div class="breadcrumbs">
<span ng-class="{'crumb': !pathPart.dots, 'crumb-separator':
pathPart.dots}"
ng-click="activatePathPart(pathPart)" ...
ng-repeat-start="pathPart in pathToRender">
{{pathPart.value}}
</span>
<span class="crumb-separator" ng-if="$index <
pathToRender.length - 1" ng-repeat-end>&gt;</span>
</div>
● Two-way data binding
● HTML generation
Directives
● Predefined: ng-app, ng-controller, etc.
● Annotating HTML
● As classes, attributes, elements
Directives
angular.module('Components')
.directive('compBreadcrumbs', function () {
return {
restrict: 'E',
scope: {
path: '=',
...
},
controller: 'breadcrumbsController',
templateUrl: 'breadcrumbs.tpl.html'
};
});
Scopes
● Model
● Hierarchy
● Bound to HTML with special directives
Controllers
<body ng-app="BreadcrumbsDemo" ng-controller="Path">
...
</body>
angular.module('Components')
.controller('Path', function Path($scope, fullPath) {
$scope.reset = function() {
$scope.path = fullPath;
};
...
});
● Augment scope with behavior
More core concepts...
● Services
● Factories
● Constants
Angular 2.0
@Component({selector: 'my-app' })
@Template({inline: '<h1>Hello {{ name }}</h1>' })
class MyAppComponent {
constructor() {
this.name = 'Alice';
}
}
● Simplified
● Focus on components
● ES6 support
Demo
● Source
● Viewable
Mental Model
● Thinking in components
Summary
● Web Components just low level standards
● Polymer like jQuery
● If more needed, React or Angular
● React philosophy more in line with JS
● Angular radically redefines JS
development practices. Good or bad?
● Future integration with Web Components
● Other options
Thank you!
Attribution
● Image of Apple Web site in 1997 from https://www.magicdust.com.au/evolution-apples-website/
● Cloud9 IDE image taken as screenshot from https://c9.io/ (example of a Web app in 2015)
● “School of Athens” fresco by Raphael, Apostolic Palace, Vatican City, fragment from
http://en.wikipedia.org/wiki/The_School_of_Athens#/media/File:Sanzio_01.jpg
● “Structure and Interpretation of Computer Programs” book cover image from
https://mitpress.mit.edu/sicp/full-text/book/book.html
● Web Components logo from http://webcomponents.org/
● Polymer logo from https://www.polymer-project.org/0.5/
● React.js logo from https://facebook.github.io/react/
● Flux architecture image from https://facebook.github.io/react/docs/flux-overview.html
● “Java EE Design Patterns” book cover image from
http://www.wrox.com/WileyCDA/WroxTitle/Professional-Java-EE-Design-Patterns.productCd-111884341X.html
● Angular.js logo from https://angular.io/
● App split into components image from https://facebook.github.io/react/docs/thinking-in-react.html
● Curtains image by eveyD http://eveyd.deviantart.com
● Made with LibreOffice Impress https://www.libreoffice.org/discover/impress/

More Related Content

What's hot

AngularJS introduction
AngularJS introductionAngularJS introduction
AngularJS introduction
Tania Gonzales
 
AngularJS Workshop
AngularJS WorkshopAngularJS Workshop
AngularJS Workshop
Gianluca Cacace
 
An Introduction To Testing In AngularJS Applications
An Introduction To Testing In AngularJS Applications An Introduction To Testing In AngularJS Applications
An Introduction To Testing In AngularJS Applications
Rohan Chandane
 
AngularJS - Architecture decisions in a large project 
AngularJS - Architecture decisionsin a large project AngularJS - Architecture decisionsin a large project 
AngularJS - Architecture decisions in a large project 
Elad Hirsch
 
Workshop 9: BackboneJS y patrones MVC
Workshop 9: BackboneJS y patrones MVCWorkshop 9: BackboneJS y patrones MVC
Workshop 9: BackboneJS y patrones MVC
Visual Engineering
 
AngularJS for designers and developers
AngularJS for designers and developersAngularJS for designers and developers
AngularJS for designers and developersKai Koenig
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - Introduction
Sagar Acharya
 
Step by Step - AngularJS
Step by Step - AngularJSStep by Step - AngularJS
Step by Step - AngularJS
Infragistics
 
Workshop 16: EmberJS Parte I
Workshop 16: EmberJS Parte IWorkshop 16: EmberJS Parte I
Workshop 16: EmberJS Parte I
Visual Engineering
 
OpenCms Days 2013 - Details of the OpenCms 9 detail pages
OpenCms Days 2013 - Details of the OpenCms 9 detail pagesOpenCms Days 2013 - Details of the OpenCms 9 detail pages
OpenCms Days 2013 - Details of the OpenCms 9 detail pages
Alkacon Software GmbH & Co. KG
 
Chap4 4 2
Chap4 4 2Chap4 4 2
Chap4 4 2
Hemo Chella
 
Backbone js
Backbone jsBackbone js
Backbone js
Rohan Chandane
 
Workshop Intro: FrontEnd General Overview
Workshop Intro: FrontEnd General OverviewWorkshop Intro: FrontEnd General Overview
Workshop Intro: FrontEnd General Overview
Visual Engineering
 
Getting Started with Angular JS
Getting Started with Angular JSGetting Started with Angular JS
Getting Started with Angular JS
Akshay Mathur
 
Web components - An Introduction
Web components - An IntroductionWeb components - An Introduction
Web components - An Introduction
cherukumilli2
 
Angular js 1.3 basic tutorial
Angular js 1.3 basic tutorialAngular js 1.3 basic tutorial
Angular js 1.3 basic tutorial
Al-Mutaz Bellah Salahat
 
Java script tutorial
Java script tutorialJava script tutorial
Java script tutorial
Doeun KOCH
 
JavaScript Modules Done Right
JavaScript Modules Done RightJavaScript Modules Done Right
JavaScript Modules Done Right
Mariusz Nowak
 
준비하세요 Angular js 2.0
준비하세요 Angular js 2.0준비하세요 Angular js 2.0
준비하세요 Angular js 2.0
Jeado Ko
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular js
Tamer Solieman
 

What's hot (20)

AngularJS introduction
AngularJS introductionAngularJS introduction
AngularJS introduction
 
AngularJS Workshop
AngularJS WorkshopAngularJS Workshop
AngularJS Workshop
 
An Introduction To Testing In AngularJS Applications
An Introduction To Testing In AngularJS Applications An Introduction To Testing In AngularJS Applications
An Introduction To Testing In AngularJS Applications
 
AngularJS - Architecture decisions in a large project 
AngularJS - Architecture decisionsin a large project AngularJS - Architecture decisionsin a large project 
AngularJS - Architecture decisions in a large project 
 
Workshop 9: BackboneJS y patrones MVC
Workshop 9: BackboneJS y patrones MVCWorkshop 9: BackboneJS y patrones MVC
Workshop 9: BackboneJS y patrones MVC
 
AngularJS for designers and developers
AngularJS for designers and developersAngularJS for designers and developers
AngularJS for designers and developers
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - Introduction
 
Step by Step - AngularJS
Step by Step - AngularJSStep by Step - AngularJS
Step by Step - AngularJS
 
Workshop 16: EmberJS Parte I
Workshop 16: EmberJS Parte IWorkshop 16: EmberJS Parte I
Workshop 16: EmberJS Parte I
 
OpenCms Days 2013 - Details of the OpenCms 9 detail pages
OpenCms Days 2013 - Details of the OpenCms 9 detail pagesOpenCms Days 2013 - Details of the OpenCms 9 detail pages
OpenCms Days 2013 - Details of the OpenCms 9 detail pages
 
Chap4 4 2
Chap4 4 2Chap4 4 2
Chap4 4 2
 
Backbone js
Backbone jsBackbone js
Backbone js
 
Workshop Intro: FrontEnd General Overview
Workshop Intro: FrontEnd General OverviewWorkshop Intro: FrontEnd General Overview
Workshop Intro: FrontEnd General Overview
 
Getting Started with Angular JS
Getting Started with Angular JSGetting Started with Angular JS
Getting Started with Angular JS
 
Web components - An Introduction
Web components - An IntroductionWeb components - An Introduction
Web components - An Introduction
 
Angular js 1.3 basic tutorial
Angular js 1.3 basic tutorialAngular js 1.3 basic tutorial
Angular js 1.3 basic tutorial
 
Java script tutorial
Java script tutorialJava script tutorial
Java script tutorial
 
JavaScript Modules Done Right
JavaScript Modules Done RightJavaScript Modules Done Right
JavaScript Modules Done Right
 
준비하세요 Angular js 2.0
준비하세요 Angular js 2.0준비하세요 Angular js 2.0
준비하세요 Angular js 2.0
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular js
 

Viewers also liked

Thinking Reasoning & Problem Solving (Human Behavior)
Thinking Reasoning & Problem Solving (Human Behavior)Thinking Reasoning & Problem Solving (Human Behavior)
Thinking Reasoning & Problem Solving (Human Behavior)
zohebchana
 
Chapter 12 Reasoning!
Chapter 12 Reasoning!Chapter 12 Reasoning!
Chapter 12 Reasoning!VickD
 
Thinking, reasoning, decision making, and problem solving: All in one Present...
Thinking, reasoning, decision making, and problem solving: All in one Present...Thinking, reasoning, decision making, and problem solving: All in one Present...
Thinking, reasoning, decision making, and problem solving: All in one Present...
Hathib KK
 
Week 3 Lecture: Gestalt Theories
Week 3 Lecture: Gestalt TheoriesWeek 3 Lecture: Gestalt Theories
Week 3 Lecture: Gestalt Theorieslizlance
 
Gestalt Psychology
Gestalt PsychologyGestalt Psychology
Gestalt PsychologyPiper Uy
 
Problem Solving PowerPoint PPT Content Modern Sample
Problem Solving PowerPoint PPT Content Modern SampleProblem Solving PowerPoint PPT Content Modern Sample
Problem Solving PowerPoint PPT Content Modern Sample
Andrew Schwartz
 
Problem solving ppt
Problem solving pptProblem solving ppt
Problem solving pptIka Rose
 
Gestalt LEARNING THEORY SULTAN THE MONKEY
Gestalt LEARNING THEORY SULTAN THE MONKEYGestalt LEARNING THEORY SULTAN THE MONKEY
Gestalt LEARNING THEORY SULTAN THE MONKEY
Murat Turk
 
Gestalt Theory
Gestalt TheoryGestalt Theory
Gestalt Theory
roger Pitiot
 
information processing theory
information processing theoryinformation processing theory
information processing theory
Iris Israel
 
Gestalt psychology slideshare
Gestalt psychology slideshareGestalt psychology slideshare
Gestalt psychology slideshare
jrbt2014
 
Thiniking
ThinikingThiniking
Thiniking
anasejazbutt
 
Problem Solving and Decision Making
Problem Solving and Decision MakingProblem Solving and Decision Making
Problem Solving and Decision Making
Ibrahim M. Morsy
 
Problem Solving Method
Problem Solving MethodProblem Solving Method
Problem Solving Method
Roxanne Deang
 
Gestalt presentation
Gestalt presentationGestalt presentation
Gestalt presentationLily Pad
 
Cognitive theory
Cognitive theoryCognitive theory
Cognitive theory
yaseen zebary
 
Decision making & problem solving
Decision making & problem solvingDecision making & problem solving
Decision making & problem solvingashish1afmi
 
Decision making ppt
Decision making pptDecision making ppt
Decision making ppt
ashgrover
 

Viewers also liked (20)

Thinking Reasoning & Problem Solving (Human Behavior)
Thinking Reasoning & Problem Solving (Human Behavior)Thinking Reasoning & Problem Solving (Human Behavior)
Thinking Reasoning & Problem Solving (Human Behavior)
 
Gestalt Psychology
Gestalt PsychologyGestalt Psychology
Gestalt Psychology
 
Chapter 12 Reasoning!
Chapter 12 Reasoning!Chapter 12 Reasoning!
Chapter 12 Reasoning!
 
Thinking, reasoning, decision making, and problem solving: All in one Present...
Thinking, reasoning, decision making, and problem solving: All in one Present...Thinking, reasoning, decision making, and problem solving: All in one Present...
Thinking, reasoning, decision making, and problem solving: All in one Present...
 
Thinking and Reasoning
Thinking and ReasoningThinking and Reasoning
Thinking and Reasoning
 
Week 3 Lecture: Gestalt Theories
Week 3 Lecture: Gestalt TheoriesWeek 3 Lecture: Gestalt Theories
Week 3 Lecture: Gestalt Theories
 
Gestalt Psychology
Gestalt PsychologyGestalt Psychology
Gestalt Psychology
 
Problem Solving PowerPoint PPT Content Modern Sample
Problem Solving PowerPoint PPT Content Modern SampleProblem Solving PowerPoint PPT Content Modern Sample
Problem Solving PowerPoint PPT Content Modern Sample
 
Problem solving ppt
Problem solving pptProblem solving ppt
Problem solving ppt
 
Gestalt LEARNING THEORY SULTAN THE MONKEY
Gestalt LEARNING THEORY SULTAN THE MONKEYGestalt LEARNING THEORY SULTAN THE MONKEY
Gestalt LEARNING THEORY SULTAN THE MONKEY
 
Gestalt Theory
Gestalt TheoryGestalt Theory
Gestalt Theory
 
information processing theory
information processing theoryinformation processing theory
information processing theory
 
Gestalt psychology slideshare
Gestalt psychology slideshareGestalt psychology slideshare
Gestalt psychology slideshare
 
Thiniking
ThinikingThiniking
Thiniking
 
Problem Solving and Decision Making
Problem Solving and Decision MakingProblem Solving and Decision Making
Problem Solving and Decision Making
 
Problem Solving Method
Problem Solving MethodProblem Solving Method
Problem Solving Method
 
Gestalt presentation
Gestalt presentationGestalt presentation
Gestalt presentation
 
Cognitive theory
Cognitive theoryCognitive theory
Cognitive theory
 
Decision making & problem solving
Decision making & problem solvingDecision making & problem solving
Decision making & problem solving
 
Decision making ppt
Decision making pptDecision making ppt
Decision making ppt
 

Similar to Thinking in Components

AngularJS
AngularJSAngularJS
Introduction to AngularJs
Introduction to AngularJsIntroduction to AngularJs
Introduction to AngularJs
murtazahaveliwala
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
Jussi Pohjolainen
 
AngularJS
AngularJSAngularJS
AngularJS
Yogesh L
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_HourDilip Patel
 
Learning AngularJS - Complete coverage of AngularJS features and concepts
Learning AngularJS  - Complete coverage of AngularJS features and conceptsLearning AngularJS  - Complete coverage of AngularJS features and concepts
Learning AngularJS - Complete coverage of AngularJS features and concepts
Suresh Patidar
 
AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS Basics
Manaday Mavani
 
Dust.js
Dust.jsDust.js
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introduction
Luigi De Russis
 
Introduction to Ember.js
Introduction to Ember.jsIntroduction to Ember.js
Introduction to Ember.js
Vinoth Kumar
 
CraftCamp for Students - Introduction to AngularJS
CraftCamp for Students - Introduction to AngularJSCraftCamp for Students - Introduction to AngularJS
CraftCamp for Students - Introduction to AngularJS
craftworkz
 
Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJs
Tudor Barbu
 
Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)
Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)
Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)
Movel
 
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFGStHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
StHack
 
Angular JS, steal the idea
Angular JS, steal the ideaAngular JS, steal the idea
Angular JS, steal the idea
Scott Lee
 
Angular js 1.3 presentation for fed nov 2014
Angular js 1.3 presentation for fed   nov 2014Angular js 1.3 presentation for fed   nov 2014
Angular js 1.3 presentation for fed nov 2014
Sarah Hudson
 
Nicolas Embleton, Advanced Angular JS
Nicolas Embleton, Advanced Angular JSNicolas Embleton, Advanced Angular JS
Nicolas Embleton, Advanced Angular JS
JavaScript Meetup HCMC
 
Extending CMS Made Simple
Extending CMS Made SimpleExtending CMS Made Simple
Extending CMS Made Simple
cmsmssjg
 
ME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS FundamentalsME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS Fundamentals
Aviran Cohen
 

Similar to Thinking in Components (20)

AngularJS
AngularJSAngularJS
AngularJS
 
Introduction to AngularJs
Introduction to AngularJsIntroduction to AngularJs
Introduction to AngularJs
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
AngularJS
AngularJSAngularJS
AngularJS
 
JavaScripts & jQuery
JavaScripts & jQueryJavaScripts & jQuery
JavaScripts & jQuery
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
 
Learning AngularJS - Complete coverage of AngularJS features and concepts
Learning AngularJS  - Complete coverage of AngularJS features and conceptsLearning AngularJS  - Complete coverage of AngularJS features and concepts
Learning AngularJS - Complete coverage of AngularJS features and concepts
 
AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS Basics
 
Dust.js
Dust.jsDust.js
Dust.js
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introduction
 
Introduction to Ember.js
Introduction to Ember.jsIntroduction to Ember.js
Introduction to Ember.js
 
CraftCamp for Students - Introduction to AngularJS
CraftCamp for Students - Introduction to AngularJSCraftCamp for Students - Introduction to AngularJS
CraftCamp for Students - Introduction to AngularJS
 
Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJs
 
Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)
Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)
Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)
 
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFGStHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
 
Angular JS, steal the idea
Angular JS, steal the ideaAngular JS, steal the idea
Angular JS, steal the idea
 
Angular js 1.3 presentation for fed nov 2014
Angular js 1.3 presentation for fed   nov 2014Angular js 1.3 presentation for fed   nov 2014
Angular js 1.3 presentation for fed nov 2014
 
Nicolas Embleton, Advanced Angular JS
Nicolas Embleton, Advanced Angular JSNicolas Embleton, Advanced Angular JS
Nicolas Embleton, Advanced Angular JS
 
Extending CMS Made Simple
Extending CMS Made SimpleExtending CMS Made Simple
Extending CMS Made Simple
 
ME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS FundamentalsME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS Fundamentals
 

Recently uploaded

The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 

Recently uploaded (20)

The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 

Thinking in Components

  • 1. Thinking in Components Web Components, Polymer, React.js, Angular.js Anton Ivanov, Helsinki.js, 28.04.2015
  • 2. Why? ● Maintainability ● Code reuse ● Similar to classes, functions ● Familiar concept
  • 6. A bit of Philosophy
  • 7. Powerful Language “Every powerful language has three mechanisms: ● primitive expressions - which represent the simplest entities the language is concerned with ● means of combination, by which compound elements are built from simpler ones, and ● means of abstraction, by which compound elements can be named and manipulated as units” “Structure and Interpretation of Computer Programs”, The MIT Press, ISBN-10: 0262510871
  • 8. Web Components ● HTML imports ● Custom elements ● Shadow DOM ● Templates Set of standards, a bit like DOM. Provides low level mechanisms.
  • 9. HTML Imports ● #include for HTML ● Styles, scripts, markup imported together <link rel="import" href="breadcrumbs.html">
  • 10. Custom Elements ● Extend HTML ● Standard APIs continue working var prototype = Object.create(HTMLElement.prototype); prototype.setPath = function(path) {...}; document.registerElement('comp-breadcrumbs', { prototype: prototype });
  • 11. Shadow DOM ● Hide markup implementation details ● Shadow root prototype.createdCallback = function() { ... this.createShadowRoot().appendChild(element); };
  • 12. Shadow DOM ● Already used by <video> in Chrome
  • 13. Templates ● Inert pieces of markup ● No advanced binding, not like Mustache ● Styles <template id="breadcrumbs-template"> <style> … </style> <div class="breadcrumbs"></div> </template>
  • 14. Templates ● To activate should be imported prototype.createdCallback = function() { var element = document.importNode(template.content, true); ... this.createShadowRoot().appendChild(element); };
  • 16. Polymer ● Enables support of new standards ● Advanced templating, inheritance ● Set of ready to extend useful components ● Minor differences with the standards Library built on top of Web Components standards, like jQuery in 2000s.
  • 17. Advanced Templating ● Loops, conditionals ● Data binding <template id="breadcrumbs-template"> … <div class="breadcrumbs" on-keypress="{{_onKeypress}}"> <template id="crumbs" repeat="{{crumb, index in crumbs}}"> ... </template> </div> </template>
  • 18. Useful Components ● core-item, core-ajax, core-collapse, etc. ● Inherit to use in your component <polymer-element name="my-element" extends="core-ajax">
  • 19. Demo ● Source or standards-only source ● Viewable not only in Chrome
  • 20. React.js ● Components ~ functions ● Declarative ● Everything is a component ● Own tree of components in memory ● Clever to re-render only what's needed Transforms data into 'immutable' HTML via a tree of components. View library not a framework.
  • 21. Component ● render method ● Life cycle hooks ● props - immutable state, set as attributes ● state – mutable state ● Hierarchy of components, data 'flows' from root
  • 22. Component var CrumbSeparator = React.createClass({ render: function() { return ( <span className="crumb-separator" title={this.props.tooltip}>{this.props.value}</span> ) } }); ● Declarative, functional-like ● JSX for templates
  • 23. Component var BreadcrumbsDemo = React.createClass({ ... render: function() { return ( <div> <div id="breadcrumb-container"> <Breadcrumbs path={this.state.path} maxEntries="5" onChange={this.onPathChange}/> </div> ... </div> ) ● Nesting
  • 24. Flux ● How data should be fed to component tree ● Data flows through one control point Recommended architecture for React.
  • 25. Flux
  • 27. Angular.js ● Testability ● Templates, view updates ● Directives ● Predefined directives ● Components implemented as directives, not a central feature MVC framework. Enhances HTML annotated with directives, handles routine tasks.
  • 29. Templates <div class="breadcrumbs"> <span ng-class="{'crumb': !pathPart.dots, 'crumb-separator': pathPart.dots}" ng-click="activatePathPart(pathPart)" ... ng-repeat-start="pathPart in pathToRender"> {{pathPart.value}} </span> <span class="crumb-separator" ng-if="$index < pathToRender.length - 1" ng-repeat-end>&gt;</span> </div> ● Two-way data binding ● HTML generation
  • 30. Directives ● Predefined: ng-app, ng-controller, etc. ● Annotating HTML ● As classes, attributes, elements
  • 31. Directives angular.module('Components') .directive('compBreadcrumbs', function () { return { restrict: 'E', scope: { path: '=', ... }, controller: 'breadcrumbsController', templateUrl: 'breadcrumbs.tpl.html' }; });
  • 32. Scopes ● Model ● Hierarchy ● Bound to HTML with special directives
  • 33. Controllers <body ng-app="BreadcrumbsDemo" ng-controller="Path"> ... </body> angular.module('Components') .controller('Path', function Path($scope, fullPath) { $scope.reset = function() { $scope.path = fullPath; }; ... }); ● Augment scope with behavior
  • 34. More core concepts... ● Services ● Factories ● Constants
  • 35. Angular 2.0 @Component({selector: 'my-app' }) @Template({inline: '<h1>Hello {{ name }}</h1>' }) class MyAppComponent { constructor() { this.name = 'Alice'; } } ● Simplified ● Focus on components ● ES6 support
  • 37. Mental Model ● Thinking in components
  • 38. Summary ● Web Components just low level standards ● Polymer like jQuery ● If more needed, React or Angular ● React philosophy more in line with JS ● Angular radically redefines JS development practices. Good or bad? ● Future integration with Web Components ● Other options
  • 40. Attribution ● Image of Apple Web site in 1997 from https://www.magicdust.com.au/evolution-apples-website/ ● Cloud9 IDE image taken as screenshot from https://c9.io/ (example of a Web app in 2015) ● “School of Athens” fresco by Raphael, Apostolic Palace, Vatican City, fragment from http://en.wikipedia.org/wiki/The_School_of_Athens#/media/File:Sanzio_01.jpg ● “Structure and Interpretation of Computer Programs” book cover image from https://mitpress.mit.edu/sicp/full-text/book/book.html ● Web Components logo from http://webcomponents.org/ ● Polymer logo from https://www.polymer-project.org/0.5/ ● React.js logo from https://facebook.github.io/react/ ● Flux architecture image from https://facebook.github.io/react/docs/flux-overview.html ● “Java EE Design Patterns” book cover image from http://www.wrox.com/WileyCDA/WroxTitle/Professional-Java-EE-Design-Patterns.productCd-111884341X.html ● Angular.js logo from https://angular.io/ ● App split into components image from https://facebook.github.io/react/docs/thinking-in-react.html ● Curtains image by eveyD http://eveyd.deviantart.com ● Made with LibreOffice Impress https://www.libreoffice.org/discover/impress/