Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
How to Re-Architect a JavaScript Class System
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Olga
May 13, 2019
Programming
140
0
Share
How to Re-Architect a JavaScript Class System
Olga
May 13, 2019
More Decks by Olga
See All by Olga
Visual Feature Engineering for Machine Learning with React
olgapetrova
0
290
Introduction to ExtReact, ExtAngular and ExtWebComponents
olgapetrova
0
99
Visual Feature Engineering for ML with React and TensorFlow.js
olgapetrova
0
95
Web Push Notifications
olgapetrova
1
320
How to add D3.js visualization to your Ext JS application
olgapetrova
1
630
Turbo-charged Data Analysis and Visualization using Ext JS 6.2
olgapetrova
3
120
ExtJS 6: one framework for all devices
olgapetrova
1
810
Other Decks in Programming
See All in Programming
TSKaigi 2026 TypeScriptバックエンドのオブザーバビリティ戦略 — Datadog × NestJSの実践
taiseiyamamotoan
1
210
Stage 3 Decorators でできること / できないこと / TSKaigi 2026
susisu
1
1.4k
次世代リンターで探る、tsgo 時代における型認識カスタムルールの現実解
ytakahashii
3
1.4k
新規プロダクトを高速で生み出すハーネスエンジニアリング
seanchas116
18
7.7k
Oxcを導入して開発体験が向上した話
yug1224
4
260
Zod v4 Codec でスキーマに型変換を埋め込む REST API 設計 #TSKaigi2026
ryutaro_yako
0
180
誰も頼んでない機能を出荷した話
zekutax
0
150
JavaDoc 再入門
nagise
0
220
Lemonade + Foundry Toolkit でお手軽アプリ開発
seosoft
1
250
Migrations : C'est une question d'hygiène !
vinceamstoutz
0
2.7k
OCRを使ってゲームのアイテムをデータ化する
kishikawakatsumi
0
120
プラグインで拡張される Context をtype-safe にする難しさと設計判断
kazupon
2
510
Featured
See All Featured
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
210
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
930
From π to Pie charts
rasagy
0
190
Side Projects
sachag
455
43k
Designing Powerful Visuals for Engaging Learning
tmiket
1
390
GraphQLとの向き合い方2022年版
quramy
50
15k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
30 Presentation Tips
portentint
PRO
1
310
Writing Fast Ruby
sferik
630
63k
Raft: Consensus for Rubyists
vanstee
141
7.5k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
180
Navigating Team Friction
lara
192
16k
Transcript
None
How to Re-Architect a JavaScript Class System Olga Petrova, @tyoushe
Developer Advocate, Sencha
Olga Petrova, @tyoushe Evolution of Standards and Technologies
Olga Petrova, @tyoushe
Olga Petrova, @tyoushe
Olga Petrova, @tyoushe What Makes Technology Future-Proof?
Olga Petrova, @tyoushe
Olga Petrova, @tyoushe
Olga Petrova, @tyoushe
Olga Petrova, @tyoushe Inheritance via Prototyping function MyComponent() {} MyComponent.prototype.init
= function() { //... } function MyChildComponent() {} MyChildComponent.prototype = Object.create(new MyComponent()); MyChildComponent.prototype.destroy = function() { //... } var cmp = new MyChildComponent(); cmp.init(); cmp.destroy();
Olga Petrova, @tyoushe
Olga Petrova, @tyoushe
Olga Petrova, @tyoushe
Olga Petrova, @tyoushe
Olga Petrova, @tyoushe Ext JS Class System ✔ Inheritance ✔
Config properties ✔ Dependencies ✔ Mixins ✔ Overrides ✔ Build tool
Olga Petrova, @tyoushe Ext JS Class Ext.define('My.own.Component', { extend: 'Ext.Component',
requires: ['My.Component.Dependency'], myProperty: true, myMethod: function() { //... this.callParent(arguments); }, statics: { staticMethod: function() { //... } } });
Olga Petrova, @tyoushe Ext JS Config Properties Ext.define('My.own.Component', { extend:
'Ext.Component‘, config: { myConfig: 'My Text' }, applyMyConfig: function(newTitle, oldTitle) { //implement validation return newTitle; }, updateMyConfig: function(newTitle, oldTitle) { //implement side effects } });
Olga Petrova, @tyoushe Ext JS Overrides var MyComponent = new
Ext.Component({}); Ext.override(MyComponent, { myProperty: 'My Text', myMethod: function () { //... } });
Olga Petrova, @tyoushe Ext JS Mixins Ext.define('Mixin‘, { processData: function(data)
{ /**/ } }); Ext.define('MyComponent‘, { mixins: { myMixin: 'Mixin' }, processData: function(data) { //... this.mixins.myMixin.processData.call(this); } });
Olga Petrova, @tyoushe 10K CUSTOMERS WORLDWIDE 2M SENCHA DEVS WORLDWIDE
7.2M PRODUCT DOWNLOADS 500K ACTIVE FORUM MEMBERS 60% of Fortune 100 Companies Rely on Sencha
Olga Petrova, @tyoushe
Olga Petrova, @tyoushe ECMAScript6 Class system
Olga Petrova, @tyoushe
Olga Petrova, @tyoushe
Olga Petrova, @tyoushe
Olga Petrova, @tyoushe ECMAScript6 Class Systems ✔ Inheritance ✔ Dependencies
✔ Build tool ❌ Config properties ❌ Mixins ❌ Overrides
Olga Petrova, @tyoushe
Olga Petrova, @tyoushe + =
Olga Petrova, @tyoushe + =
Olga Petrova, @tyoushe
Olga Petrova, @tyoushe Decorator pattern is a design pattern that
allows behavior to be added to an individual object, dynamically, without affecting the behavior of other objects from the same class
Olga Petrova, @tyoushe JavaScript Decorators
Olga Petrova, @tyoushe @wrap Method class C { @wrap(f) method()
{ } } class C { method() { } } C.prototype.method = f(C.prototype.method); =>
Olga Petrova, @tyoushe @wrap Class @wrap(f) class C { }
class C { } C = f(C); =>
Olga Petrova, @tyoushe JavaScript Class Fields
Olga Petrova, @tyoushe Class Fields class MyComponent { myField =
42; }
Olga Petrova, @tyoushe ECMAScript 6 to Ext JS Class Systems
✔ Inheritance ✔ Dependencies ✔ Build tool ✔ Config properties @define for class & @config for class fields ✔ Mixins @define for class ✔ Overrides @override for class
Olga Petrova, @tyoushe Class @define({ prototype: { myProperty: "My text"
}, static: { myStaticProperty: 42 } }) class MyOwnComponent extends Component { // }
Olga Petrova, @tyoushe Configs @define class MyOwnComponent extends Component {
@config('nullify') myConfig = 42; applyMyConfig (value, oldValue) { //validation return value; } updateMyConfig (value, oldValue) { //side effects } }
Olga Petrova, @tyoushe Mixins @define class Mixin extends Base {
processData (data) {...} } @define({ mixins: [ Mixin ] }) class MyComponent extends Component { @junction processData (data) { super.processData(data); } }
Olga Petrova, @tyoushe Overrides class MyComponent extends Component {} @override(MyComponent)
class MyComponentOverride { myProperty = ‘My Text’; myMethod () { //... } }
Olga Petrova, @tyoushe Life-cycle Methods class MyComponent extends Component {
ctor () { // do constructor-like things } setup() { // finalize configuration } dtor () { // do destructor-like things } }
Olga Petrova, @tyoushe Lessons Learned
Olga Petrova, @tyoushe Follow Standards if You Can
Olga Petrova, @tyoushe Estimate Effort on Re-write
Olga Petrova, @tyoushe Encapsulate
Olga Petrova, @tyoushe Keep your Eyes on New Standards
Olga Petrova, @tyoushe Start to Adapt Earlier
Olga Petrova, @tyoushe Keep Decorator/Adapter/Facade Patterns in Mind
Olga Petrova, @tyoushe 3