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

SIKP311 Sikolohiyang Pilipino - Ginhawa.pptx
SIKP311 Sikolohiyang Pilipino - Ginhawa.pptxSIKP311 Sikolohiyang Pilipino - Ginhawa.pptx
SIKP311 Sikolohiyang Pilipino - Ginhawa.pptxStephenMino
 
the Husband rolesBrown Aesthetic Cute Group Project Presentation
the Husband rolesBrown Aesthetic Cute Group Project Presentationthe Husband rolesBrown Aesthetic Cute Group Project Presentation
the Husband rolesBrown Aesthetic Cute Group Project Presentationbrynpueblos04
 
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...Cara Menggugurkan Kandungan 087776558899
 
2023 - Between Philosophy and Practice: Introducing Yoga
2023 - Between Philosophy and Practice: Introducing Yoga2023 - Between Philosophy and Practice: Introducing Yoga
2023 - Between Philosophy and Practice: Introducing YogaRaphaël Semeteys
 
Pokemon Go... Unraveling the Conspiracy Theory
Pokemon Go... Unraveling the Conspiracy TheoryPokemon Go... Unraveling the Conspiracy Theory
Pokemon Go... Unraveling the Conspiracy Theorydrae5
 
February 2024 Recommendations for newsletter
February 2024 Recommendations for newsletterFebruary 2024 Recommendations for newsletter
February 2024 Recommendations for newsletterssuserdfec6a
 
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...mitaliverma221
 
WOMEN EMPOWERMENT women empowerment.pptx
WOMEN EMPOWERMENT women empowerment.pptxWOMEN EMPOWERMENT women empowerment.pptx
WOMEN EMPOWERMENT women empowerment.pptxpadhand000
 
March 2023 Recommendations for newsletter
March 2023 Recommendations for newsletterMarch 2023 Recommendations for newsletter
March 2023 Recommendations for newsletterssuserdfec6a
 
Dadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Dadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot GirlsDadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Dadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot GirlsDeepika Singh
 

Recently uploaded (10)

SIKP311 Sikolohiyang Pilipino - Ginhawa.pptx
SIKP311 Sikolohiyang Pilipino - Ginhawa.pptxSIKP311 Sikolohiyang Pilipino - Ginhawa.pptx
SIKP311 Sikolohiyang Pilipino - Ginhawa.pptx
 
the Husband rolesBrown Aesthetic Cute Group Project Presentation
the Husband rolesBrown Aesthetic Cute Group Project Presentationthe Husband rolesBrown Aesthetic Cute Group Project Presentation
the Husband rolesBrown Aesthetic Cute Group Project Presentation
 
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...
 
2023 - Between Philosophy and Practice: Introducing Yoga
2023 - Between Philosophy and Practice: Introducing Yoga2023 - Between Philosophy and Practice: Introducing Yoga
2023 - Between Philosophy and Practice: Introducing Yoga
 
Pokemon Go... Unraveling the Conspiracy Theory
Pokemon Go... Unraveling the Conspiracy TheoryPokemon Go... Unraveling the Conspiracy Theory
Pokemon Go... Unraveling the Conspiracy Theory
 
February 2024 Recommendations for newsletter
February 2024 Recommendations for newsletterFebruary 2024 Recommendations for newsletter
February 2024 Recommendations for newsletter
 
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...
 
WOMEN EMPOWERMENT women empowerment.pptx
WOMEN EMPOWERMENT women empowerment.pptxWOMEN EMPOWERMENT women empowerment.pptx
WOMEN EMPOWERMENT women empowerment.pptx
 
March 2023 Recommendations for newsletter
March 2023 Recommendations for newsletterMarch 2023 Recommendations for newsletter
March 2023 Recommendations for newsletter
 
Dadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Dadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot GirlsDadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Dadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
 

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…