46
JavaScript Artur Skowroński

JavaScript Classified

Embed Size (px)

DESCRIPTION

W wyniku różnorodnych metod implementacji przez poszczególne frameworki, w temacie klas w JavaScript zdiagnozowano rozszczepienie osobowości. Na szczęście odpowiednie lekarstwo powoli jest szykowane, o czym będę starał się opowiedzieć w tej prezentacji. Jednocześnie postaram się przypomnieć historie choroby, jej objawy i wytłumaczyć, dlaczego kuracja jest tak bardzo pożądana.

Citation preview

Page 1: JavaScript Classified

JavaScript

Artur Skowroński

Page 2: JavaScript Classified
Page 3: JavaScript Classified

Abstrakcja (łac. abstractio - oderwanie)

Page 4: JavaScript Classified

Klasyczne podejście

Konstruktor Funkcyjny

Page 5: JavaScript Classified

function Person(name){

this.name=name;

}

Person.prototype.show=function(){

console.log("Jestem " + this.firm);

};

Page 6: JavaScript Classified

Employee.prototype = new Person(); Employee.prototype.constructor = Employee;

Page 7: JavaScript Classified

Employee.prototype.show = function(){

Person.prototype.show.call(this);

console.log("Pracuje w firme " + this.firm);

};

Page 8: JavaScript Classified
Page 9: JavaScript Classified

Object.create For Loop

Page 10: JavaScript Classified
Page 11: JavaScript Classified
Page 12: JavaScript Classified
Page 13: JavaScript Classified

Core API

Page 14: JavaScript Classified
Page 15: JavaScript Classified

EcmaScript 3Grudzień 1999

Wyrażenia regularne

Try Catch

Page 16: JavaScript Classified

ECMAScript 4

Packages

NamespacesKlasy

Page 17: JavaScript Classified
Page 18: JavaScript Classified

Grudzień 2009

ECMAScript 3.1ECMAScript 5

Page 19: JavaScript Classified
Page 20: JavaScript Classified
Page 21: JavaScript Classified

maximally_minimal_classes

Aktualny Draft

Page 22: JavaScript Classified

Tworzenie i konstruktory

Page 23: JavaScript Classified

ECMAScript 3

function Person(name){ this.name=name; }

Page 24: JavaScript Classified

ECMAScript 6

class Person { constructor(name){ this.name=name; } }

Page 25: JavaScript Classified

Metody

Page 26: JavaScript Classified

Person.prototype.hello = function(){ console.log("Osoba " + this.name ); };

ECMAScript 3

Page 27: JavaScript Classified

class Person { (…) hello(){ console.log("Osoba "+this.name); } }

ECMAScript 6

Page 28: JavaScript Classified
Page 29: JavaScript Classified

Dziedziczenie

Page 30: JavaScript Classified

ECMAScript 3

Man.prototype = new Mammal(); Man.prototype.constructor = Man; !

function Man(firm){ this.firm=firm; }

Page 31: JavaScript Classified

ECMAScript 6

class Man extends Mammal { constructor(firm){ this.firm= firm; } }

Page 32: JavaScript Classified

SuperMetody

Page 33: JavaScript Classified

ECMAScript 3

Employee.prototype.show = function(){ Person.prototype.show.call(this); alert("Pracuje w firme " + this.firm); }

Page 34: JavaScript Classified

class Employee extends Person { (…) !

show(){ super() alert("Pracuje w firme " + this.firm); } !

}

ECMAScript 6

Page 35: JavaScript Classified

Czego jeszcze nie dostaniemy

• Zamkniętego stanu• Properties

NazwaKlasy.prototype.nazwaPop = 0;

Page 36: JavaScript Classified

Future editions of ECMAScript may and probably will extend the proposed class definitions. However, the intent for “ES6” is to only include the features described in this proposal. Attempting to extend this proposal is likely to result in

dead-lock that would result in the inclusion of no class definition support in “ES6”.

Page 37: JavaScript Classified

Podsumowując

•Standard dziedziczenia dla wszystkich !

•Naturalne Core API dla twórców Frameworków

Page 38: JavaScript Classified

Nadzieje

Page 39: JavaScript Classified

Interoperacyjność

Page 40: JavaScript Classified

IDE Support

Page 41: JavaScript Classified

Performance języka

http://sealedabstract.com/rants/why-mobile-web-apps-are-slow/

Page 42: JavaScript Classified

Kiedy?

Page 43: JavaScript Classified

http://kangax.github.io/compat-table/es6

Page 44: JavaScript Classified
Page 45: JavaScript Classified

https://github.com/google/traceur-compiler

Page 46: JavaScript Classified

Dziękuje bardzo… i zapraszam do pytańArtur Skowroński