SlideShare a Scribd company logo
1 of 24
TKO
Knocking it out of the ball park with
TypeScript and knockout.js

Wekoslav Stefanovski
Senior Developer, Seavus
swekster@gmail.com
Agenda
A little bit of history
A little bit of present
Why is TypeScript needed? How is it used?
Why is knockout needed? How is it used?
Why are they great together?
Bonus Topic: Surprise
A little bit of history
 What is this thing called Javascript???

 Prototype-based dynamic scripting language
 Build in Netscape in 1995, initially focused on

non-professional developers.
 Standardized as ECMAScript (in 1999)
 Still the version most browsers / developers use.
A little bit of history, part II
 What is this thing called DOM???

 Even worse consistency than javascript.
 Latest specification is from 2004, a.k.a. Internet Prehistory
 jQuery (and friends) to the rescue
 Still, it’s not a traditional programming object model
– Hard to manipulate
– Hard to automate
A little bit of present
 The rise of the Single-Page Application
 Heavy client logic, getting heavier
 Stateless web is dead and more alive than ever
 The attack of the APIs and services
 Ongoing M/V separation
Why is TypeScript needed
 Javascript’s got 99 problems but types ain’t one
– Variable hoisting – no implicit global variables in typescript
– Truthy and falsy values – only booleans allowed in boolean
checks
– No explicit includes – has explicit references and dependencies
– The this parameter can be actually that - lexical scoping

 ECMAScript 6 standard specification is a long way off
– TypeScript type definition syntax is aligned with ECMAScript 6
Why is knockout.js needed?
 Declarative bindings
 Automatic UI updating

 Dependency tracking
 Templating
 No (or very little) code mixed with html
 No html mixed with code
Why are they great together?
Typescript generics add strictness to knockout
Encourages correct usage
Better sense of confidence in the code
Improved readability
Improved testability
The Future of C# - C# 6.0
1. Primary Constructors
Before
After
public class Point
{
private int x, y;
public Point(int x, int y)
{
this.x = x;
this.y = y;
}
}

public class Point(int x, int y)
{
private int x, y;
}
The Future of C# - C# 6.0
2. Readonly auto properties
Before
After
public readonly int x = 3;
public int X
{
get
{
return x
}
}

public int X {get; } = 3;
The Future of C# - C# 6.0
3. Static type using statements
Before
public double A
{
get { return Math.Round(Math.Sqrt(Math.Abs(someValue))); }
}

After
using System.Math;
public double A
{
get { return Round(Sqrt(Abs(someValue))); }
}
The Future of C# - C# 6.0
4. Property Expressions
Before
public double Distance
{
get { return Math.Sqrt(X * X + Y * Y); }
}

After
public double Distance => Math.Sqrt(X * X + Y * Y);
The Future of C# - C# 6.0
5. Method Expressions
Before
public double MoveRight(int dx)
{
return new Point(X + dx, Y);
}

After
public double MoveRight(int dx) => new Point(X + dx, Y);
The Future of C# - C# 6.0
6. Params for enumerables
Before
Do(someEnumerable.ToArray());
...
public void Do(params int[] values) { ... }

After
Do(someEnum);
...
public void Do(params IEnumerable<int> points) { ... }
The Future of C# - C# 6.0
7. Inline declarations for out params
Before
After
int x;
int.TryParse("123", out x);

int.TryParse("123", out int x);
The Future of C# - C# 6.0
8. Monadic null checking
Before
if (points == null)
return -1;
var next = points.FirstOrDefault();
if ((next == null) || (next.X == null))
return -1;
return next.X;

After
return points?.FirstOrDefault()?.X ?? -1;
The Future of C# - C# 6.0
9. Constructor type parameter inference
Before
var x = MyClass.Create(1, "X");
...
public static MyClass
{
public MyClass<T1, T2> Create<T1, T2>(T1 a, T2 b)
{
return new MyClass<T1, T2>(a, b);
}
}

After
var x = new MyClass(1, "X");
• Complete electronic evaluation forms on the
computers in the hall and enter to win!
– Infragistics Ultimate
– Telerik DevCraft
– JetBrains .NET tools
– Semos training vouchers
– Pluralsight subscriptions
– and many more…
TKO - Awesomeness using TypeScript with knockout.js

More Related Content

More from Wekoslav Stefanovski

Through Meteor to the stars - Developing full-stack SPA's with meteor.js
Through Meteor to the stars - Developing full-stack SPA's with meteor.jsThrough Meteor to the stars - Developing full-stack SPA's with meteor.js
Through Meteor to the stars - Developing full-stack SPA's with meteor.jsWekoslav Stefanovski
 
TypeScript 1.6 - How I learned to Stop Worrying and Love JavaScript
TypeScript 1.6 - How I learned to Stop Worrying and Love JavaScriptTypeScript 1.6 - How I learned to Stop Worrying and Love JavaScript
TypeScript 1.6 - How I learned to Stop Worrying and Love JavaScriptWekoslav Stefanovski
 
Testing your Single Page Application
Testing your Single Page ApplicationTesting your Single Page Application
Testing your Single Page ApplicationWekoslav Stefanovski
 
Smoke and Mirrors - Reflection in C#
Smoke and Mirrors - Reflection in C#Smoke and Mirrors - Reflection in C#
Smoke and Mirrors - Reflection in C#Wekoslav Stefanovski
 
TypeScript - Javascript done right
TypeScript - Javascript done rightTypeScript - Javascript done right
TypeScript - Javascript done rightWekoslav Stefanovski
 
SOLID -Clean Code For Mere Mortals
SOLID -Clean Code For Mere MortalsSOLID -Clean Code For Mere Mortals
SOLID -Clean Code For Mere MortalsWekoslav Stefanovski
 

More from Wekoslav Stefanovski (9)

Through Meteor to the stars - Developing full-stack SPA's with meteor.js
Through Meteor to the stars - Developing full-stack SPA's with meteor.jsThrough Meteor to the stars - Developing full-stack SPA's with meteor.js
Through Meteor to the stars - Developing full-stack SPA's with meteor.js
 
TypeScript 1.6 - How I learned to Stop Worrying and Love JavaScript
TypeScript 1.6 - How I learned to Stop Worrying and Love JavaScriptTypeScript 1.6 - How I learned to Stop Worrying and Love JavaScript
TypeScript 1.6 - How I learned to Stop Worrying and Love JavaScript
 
How to write bad code using C#
How to write bad code using C#How to write bad code using C#
How to write bad code using C#
 
Garbage Collection .Net
Garbage Collection .NetGarbage Collection .Net
Garbage Collection .Net
 
Testing your Single Page Application
Testing your Single Page ApplicationTesting your Single Page Application
Testing your Single Page Application
 
Smoke and Mirrors - Reflection in C#
Smoke and Mirrors - Reflection in C#Smoke and Mirrors - Reflection in C#
Smoke and Mirrors - Reflection in C#
 
TypeScript - Javascript done right
TypeScript - Javascript done rightTypeScript - Javascript done right
TypeScript - Javascript done right
 
Entity Framework 5 - Code First
Entity Framework 5 - Code FirstEntity Framework 5 - Code First
Entity Framework 5 - Code First
 
SOLID -Clean Code For Mere Mortals
SOLID -Clean Code For Mere MortalsSOLID -Clean Code For Mere Mortals
SOLID -Clean Code For Mere Mortals
 

Recently uploaded

(No.1)↠Young Call Girls in Sikanderpur (Gurgaon) ꧁❤ 9711911712 ❤꧂ Escorts
(No.1)↠Young Call Girls in Sikanderpur (Gurgaon) ꧁❤ 9711911712 ❤꧂ Escorts(No.1)↠Young Call Girls in Sikanderpur (Gurgaon) ꧁❤ 9711911712 ❤꧂ Escorts
(No.1)↠Young Call Girls in Sikanderpur (Gurgaon) ꧁❤ 9711911712 ❤꧂ EscortsDelhi Escorts Service
 
Inspiring Through Words Power of Inspiration.pptx
Inspiring Through Words Power of Inspiration.pptxInspiring Through Words Power of Inspiration.pptx
Inspiring Through Words Power of Inspiration.pptxShubham Rawat
 
(南达科他州立大学毕业证学位证成绩单-永久存档)
(南达科他州立大学毕业证学位证成绩单-永久存档)(南达科他州立大学毕业证学位证成绩单-永久存档)
(南达科他州立大学毕业证学位证成绩单-永久存档)oannq
 
西伦敦大学毕业证学位证成绩单-怎么样做
西伦敦大学毕业证学位证成绩单-怎么样做西伦敦大学毕业证学位证成绩单-怎么样做
西伦敦大学毕业证学位证成绩单-怎么样做j5bzwet6
 
南新罕布什尔大学毕业证学位证成绩单-学历认证
南新罕布什尔大学毕业证学位证成绩单-学历认证南新罕布什尔大学毕业证学位证成绩单-学历认证
南新罕布什尔大学毕业证学位证成绩单-学历认证kbdhl05e
 
办理西悉尼大学毕业证成绩单、制作假文凭
办理西悉尼大学毕业证成绩单、制作假文凭办理西悉尼大学毕业证成绩单、制作假文凭
办理西悉尼大学毕业证成绩单、制作假文凭o8wvnojp
 
Call Girls in Govindpuri Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Govindpuri Delhi 💯Call Us 🔝8264348440🔝Call Girls in Govindpuri Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Govindpuri Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Call Girls In Dwarka Sub City ☎️7838079806 ✅ 💯Call Girls In Delhi
Call Girls In Dwarka Sub City  ☎️7838079806 ✅ 💯Call Girls In DelhiCall Girls In Dwarka Sub City  ☎️7838079806 ✅ 💯Call Girls In Delhi
Call Girls In Dwarka Sub City ☎️7838079806 ✅ 💯Call Girls In DelhiSoniyaSingh
 
E J Waggoner against Kellogg's Pantheism 8.pptx
E J Waggoner against Kellogg's Pantheism 8.pptxE J Waggoner against Kellogg's Pantheism 8.pptx
E J Waggoner against Kellogg's Pantheism 8.pptxJackieSparrow3
 
Authentic No 1 Amil Baba In Pakistan Amil Baba In Faisalabad Amil Baba In Kar...
Authentic No 1 Amil Baba In Pakistan Amil Baba In Faisalabad Amil Baba In Kar...Authentic No 1 Amil Baba In Pakistan Amil Baba In Faisalabad Amil Baba In Kar...
Authentic No 1 Amil Baba In Pakistan Amil Baba In Faisalabad Amil Baba In Kar...Authentic No 1 Amil Baba In Pakistan
 
Call Girls In Karkardooma 83770 87607 Just-Dial Escorts Service 24X7 Avilable
Call Girls In Karkardooma 83770 87607 Just-Dial Escorts Service 24X7 AvilableCall Girls In Karkardooma 83770 87607 Just-Dial Escorts Service 24X7 Avilable
Call Girls In Karkardooma 83770 87607 Just-Dial Escorts Service 24X7 Avilabledollysharma2066
 

Recently uploaded (12)

(No.1)↠Young Call Girls in Sikanderpur (Gurgaon) ꧁❤ 9711911712 ❤꧂ Escorts
(No.1)↠Young Call Girls in Sikanderpur (Gurgaon) ꧁❤ 9711911712 ❤꧂ Escorts(No.1)↠Young Call Girls in Sikanderpur (Gurgaon) ꧁❤ 9711911712 ❤꧂ Escorts
(No.1)↠Young Call Girls in Sikanderpur (Gurgaon) ꧁❤ 9711911712 ❤꧂ Escorts
 
Inspiring Through Words Power of Inspiration.pptx
Inspiring Through Words Power of Inspiration.pptxInspiring Through Words Power of Inspiration.pptx
Inspiring Through Words Power of Inspiration.pptx
 
(南达科他州立大学毕业证学位证成绩单-永久存档)
(南达科他州立大学毕业证学位证成绩单-永久存档)(南达科他州立大学毕业证学位证成绩单-永久存档)
(南达科他州立大学毕业证学位证成绩单-永久存档)
 
西伦敦大学毕业证学位证成绩单-怎么样做
西伦敦大学毕业证学位证成绩单-怎么样做西伦敦大学毕业证学位证成绩单-怎么样做
西伦敦大学毕业证学位证成绩单-怎么样做
 
Model Call Girl in Lado Sarai Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Lado Sarai Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Lado Sarai Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Lado Sarai Delhi reach out to us at 🔝9953056974🔝
 
南新罕布什尔大学毕业证学位证成绩单-学历认证
南新罕布什尔大学毕业证学位证成绩单-学历认证南新罕布什尔大学毕业证学位证成绩单-学历认证
南新罕布什尔大学毕业证学位证成绩单-学历认证
 
办理西悉尼大学毕业证成绩单、制作假文凭
办理西悉尼大学毕业证成绩单、制作假文凭办理西悉尼大学毕业证成绩单、制作假文凭
办理西悉尼大学毕业证成绩单、制作假文凭
 
Call Girls in Govindpuri Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Govindpuri Delhi 💯Call Us 🔝8264348440🔝Call Girls in Govindpuri Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Govindpuri Delhi 💯Call Us 🔝8264348440🔝
 
Call Girls In Dwarka Sub City ☎️7838079806 ✅ 💯Call Girls In Delhi
Call Girls In Dwarka Sub City  ☎️7838079806 ✅ 💯Call Girls In DelhiCall Girls In Dwarka Sub City  ☎️7838079806 ✅ 💯Call Girls In Delhi
Call Girls In Dwarka Sub City ☎️7838079806 ✅ 💯Call Girls In Delhi
 
E J Waggoner against Kellogg's Pantheism 8.pptx
E J Waggoner against Kellogg's Pantheism 8.pptxE J Waggoner against Kellogg's Pantheism 8.pptx
E J Waggoner against Kellogg's Pantheism 8.pptx
 
Authentic No 1 Amil Baba In Pakistan Amil Baba In Faisalabad Amil Baba In Kar...
Authentic No 1 Amil Baba In Pakistan Amil Baba In Faisalabad Amil Baba In Kar...Authentic No 1 Amil Baba In Pakistan Amil Baba In Faisalabad Amil Baba In Kar...
Authentic No 1 Amil Baba In Pakistan Amil Baba In Faisalabad Amil Baba In Kar...
 
Call Girls In Karkardooma 83770 87607 Just-Dial Escorts Service 24X7 Avilable
Call Girls In Karkardooma 83770 87607 Just-Dial Escorts Service 24X7 AvilableCall Girls In Karkardooma 83770 87607 Just-Dial Escorts Service 24X7 Avilable
Call Girls In Karkardooma 83770 87607 Just-Dial Escorts Service 24X7 Avilable
 

TKO - Awesomeness using TypeScript with knockout.js

  • 1.
  • 2. TKO Knocking it out of the ball park with TypeScript and knockout.js Wekoslav Stefanovski Senior Developer, Seavus swekster@gmail.com
  • 3.
  • 4. Agenda A little bit of history A little bit of present Why is TypeScript needed? How is it used? Why is knockout needed? How is it used? Why are they great together? Bonus Topic: Surprise
  • 5. A little bit of history  What is this thing called Javascript???  Prototype-based dynamic scripting language  Build in Netscape in 1995, initially focused on non-professional developers.  Standardized as ECMAScript (in 1999)  Still the version most browsers / developers use.
  • 6. A little bit of history, part II  What is this thing called DOM???  Even worse consistency than javascript.  Latest specification is from 2004, a.k.a. Internet Prehistory  jQuery (and friends) to the rescue  Still, it’s not a traditional programming object model – Hard to manipulate – Hard to automate
  • 7. A little bit of present  The rise of the Single-Page Application  Heavy client logic, getting heavier  Stateless web is dead and more alive than ever  The attack of the APIs and services  Ongoing M/V separation
  • 8. Why is TypeScript needed  Javascript’s got 99 problems but types ain’t one – Variable hoisting – no implicit global variables in typescript – Truthy and falsy values – only booleans allowed in boolean checks – No explicit includes – has explicit references and dependencies – The this parameter can be actually that - lexical scoping  ECMAScript 6 standard specification is a long way off – TypeScript type definition syntax is aligned with ECMAScript 6
  • 9. Why is knockout.js needed?  Declarative bindings  Automatic UI updating  Dependency tracking  Templating  No (or very little) code mixed with html  No html mixed with code
  • 10. Why are they great together? Typescript generics add strictness to knockout Encourages correct usage Better sense of confidence in the code Improved readability Improved testability
  • 11.
  • 12.
  • 13. The Future of C# - C# 6.0 1. Primary Constructors Before After public class Point { private int x, y; public Point(int x, int y) { this.x = x; this.y = y; } } public class Point(int x, int y) { private int x, y; }
  • 14. The Future of C# - C# 6.0 2. Readonly auto properties Before After public readonly int x = 3; public int X { get { return x } } public int X {get; } = 3;
  • 15. The Future of C# - C# 6.0 3. Static type using statements Before public double A { get { return Math.Round(Math.Sqrt(Math.Abs(someValue))); } } After using System.Math; public double A { get { return Round(Sqrt(Abs(someValue))); } }
  • 16. The Future of C# - C# 6.0 4. Property Expressions Before public double Distance { get { return Math.Sqrt(X * X + Y * Y); } } After public double Distance => Math.Sqrt(X * X + Y * Y);
  • 17. The Future of C# - C# 6.0 5. Method Expressions Before public double MoveRight(int dx) { return new Point(X + dx, Y); } After public double MoveRight(int dx) => new Point(X + dx, Y);
  • 18. The Future of C# - C# 6.0 6. Params for enumerables Before Do(someEnumerable.ToArray()); ... public void Do(params int[] values) { ... } After Do(someEnum); ... public void Do(params IEnumerable<int> points) { ... }
  • 19. The Future of C# - C# 6.0 7. Inline declarations for out params Before After int x; int.TryParse("123", out x); int.TryParse("123", out int x);
  • 20. The Future of C# - C# 6.0 8. Monadic null checking Before if (points == null) return -1; var next = points.FirstOrDefault(); if ((next == null) || (next.X == null)) return -1; return next.X; After return points?.FirstOrDefault()?.X ?? -1;
  • 21. The Future of C# - C# 6.0 9. Constructor type parameter inference Before var x = MyClass.Create(1, "X"); ... public static MyClass { public MyClass<T1, T2> Create<T1, T2>(T1 a, T2 b) { return new MyClass<T1, T2>(a, b); } } After var x = new MyClass(1, "X");
  • 22.
  • 23. • Complete electronic evaluation forms on the computers in the hall and enter to win! – Infragistics Ultimate – Telerik DevCraft – JetBrains .NET tools – Semos training vouchers – Pluralsight subscriptions – and many more…