The document discusses different approaches to building web applications using components, including Web Components, Polymer, React, and Angular. It provides an overview of each approach, describing their core concepts like templates, data binding, and component-based architectures. The document concludes that Web Components are just low-level standards, Polymer is like jQuery for Web Components, and React and Angular are good options if more functionality is needed, with React aligning more with JavaScript and Angular radically changing development practices.
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
});
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
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/