Toolchain
Frameworks
&
Libraries
UI / UX
Platforms
SOA
Performance
Browsers
Testing
i18n
Security
Existing Code
var a = 1;
function foo() {
var b = 0
if (a) {
var a = 2;
var b = a + 2;
console.log(b);
}
console.log(a);
console.log(b);
}
console.log(a);
foo();
1
undefined
0
let a = 1;
function foo() {
let b = 0
if (a) {
let a = 2;
let b = a + 2;
console.log( b );
}
console.log( a );
console.log( b );
}
console.log( a );
foo();
1
4
0
1
class Rectangle extends Shape {
constructor (id, x, y, width, height) {
super(id, x, y)
this.width = width
this.height = height
}
}
class Circle extends Shape {
constructor (id, x, y, radius) {
super(id, x, y)
this.radius = radius
}
}
"use strict";
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}
subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });
if (superClass)
Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
}
var Rectangle = (function (_Shape) {
_inherits(Rectangle, _Shape);
function Rectangle(id, x, y, width, height) {
_classCallCheck(this, Rectangle);
_Shape.call(this, id, x, y);
this.width = width;
this.height = height;
}
return Rectangle;
})(Shape);
var Circle = (function (_Shape2) {
_inherits(Circle, _Shape2);
function Circle(id, x, y, radius) {
_classCallCheck(this, Circle);
_Shape2.call(this, id, x, y);
this.radius = radius;
}
return Circle;
})(Shape);
Focus on designing and building engaging UI
Useful for cross-browser testing
Alive and always up-to-date
1. Choose a library
2. Configure It
3. Extract strings from JavaScript
4. Find Translator
5. Determine the user's language
6. Broadcast language support
<div ng-repeat="model in collection">
{{model.name}}
</div>
collection.map(model => (
<div>{model.name}</div>
))
<select name="month">
<option>(01) January</option>
<option>(02) February</option>
...
</select>
<select name="month">
<option ng-repeat="month in months">
({{$index | padMonth}}) {{month}}
</option>
</select>
<select>
{months.map((month, index) => (
<option>({padMonth(index)}) {month}</option>
))}
</select>
Java Script | Templates |
---|---|
Use vars in function scope | Guess where vars come from |
Use JavaScript methods like Array#map | Invent our own DSL |
Carry knowledge to next project | Describe ourselves as "X developers" |
Person = Ember.Object.extend({
// these will be supplied by `create`
firstName: null,
lastName: null,
fullName: Ember.computed('firstName', 'lastName', function() {
return `${this.get('firstName')} ${this.get('lastName')}`;
}),
fullNameChanged: Ember.observer('fullName', function() {
// deal with the change
})
});
var person = Person.create({
firstName: 'Yehuda',
lastName: 'Katz'
});
person.set('firstName', 'Brohuda'); // observer will fire
setState | KVO |
---|---|
One object contains state | Many objects contain state |
Imperative, intent is obvious | Behaviour depends on side effects |
Easy to grasp | Difficult to grasp |
Virtual DOM | DOM |
---|---|
Describe what UI looks like | Actually manipulate DOM |
Framework handles optimization | Optimize by hand |
Easy to introduce new render targets | Difficult to render to new targets |
Data-Driven Documents : A JavaScript library for manipulating documents based on data
Bring data to life using HTML, SVG, and CSS.
Modern way of building visulization
Fine Print:
BUT a month later, can't understand the code already...
elegant + sleek + awesome!
D3 is hard
Challeng to deal with the State
enter, update, exist
with too many dataset
A team of people working on ONE data visualization
Turn every frame/state of visualization into function of data
React: redraw for Web
D3
Calculation / math / position
Define behaviours
Play Together
D3 generates layout and let React render with giving positions through property
Reuse component anywhere with different data
Library Vs. Full Fledged Framework
React does not help you with
Application routing
Communicating with a server
Validating models
Injecting dependencies
Logic and markup are inextricably linked together VS. Template being the view in MVC
SOA
i18n
Automation
Visualisation with D3
ECMAScript 2015
Babel
Web Component building / testing
React advocates
Angular?
1. Choose a library
2. Configure it
3. Extract strings from JavaScript
> cat ./app/components/hello.js
let React = require('react');
module.exports = React.createClass({
render() {
return (
<div>hello world</div>
)
}
})
> cat ./app/components/hello.js
let React = require('react');
// i18n! is a plugin connect _t to translations
let _t = require('i18n!app/i10n/hello');
module.exports = React.createClass({
render() {
return (
// wrap string with _t()
<div>{_t('hello wrold')}</div>
)
}
> cat ./app/l10n/jp/hello.js
{
"hello world": "こんにちは世界"
}
4. Find Translator
5. Determine the user's language
6. Broadcast language support