Typescript kata The TDD style 2 edition

17
TypeScript Kata The TDD style 2 edition Ronnie Hegelund Creator of AutoFixtureTS http://bit.ly/XYF0Gp Author of Enterprise development in TypeScript http://bit.ly/11WyKF8 http://ronniehegelund.blogspot.dk/ @ronniedrengen 活活 活活活 活活活活活活活 体:

description

Fundamental TypeScript, Test-Driven development and the concept of code kata's

Transcript of Typescript kata The TDD style 2 edition

Page 1: Typescript kata The TDD style 2 edition

TypeScript KataThe TDD style 2 edition

Ronnie HegelundCreator of AutoFixtureTShttp://bit.ly/XYF0Gp

Author of Enterprise development in TypeScripthttp://bit.ly/11WyKF8

http://ronniehegelund.blogspot.dk/

@ronniedrengen

活字体カタ:テスト駆動開発

Page 2: Typescript kata The TDD style 2 edition

About me!Ronnie HegelundTechnical Lead, Widex A/S

http://ronniehegelund.blogspot.dk/@ronniedrengen

Love all facets of software development fromTest driven development, Software Architecture, continuous delivery

Focus onWeb, C#, TypeScript and Developer/Team productivity

Latest projects• TypeScript BCL• TypeScript weekly• CommunitySnippets for VisualStudio• Writing a book. Enterprise development In TypeScript• Visual Studio Test project templates

Page 3: Typescript kata The TDD style 2 edition

Agenda

1. What is TypeScript2. Test Driven Development3. Concepts of Code kata’s4. Doing string calculator kata with

TypeScriptVisual StudioJasmine

Page 4: Typescript kata The TDD style 2 edition

What is TypeScript

TypeScript is a language for application scaleJavaScript development.

Page 5: Typescript kata The TDD style 2 edition

What is TypeScript

TypeScript is a typed superset of JavaScriptthat compiles to plain JavaScript.

Any browser. Any host. Any OS.

Open Source.

Page 6: Typescript kata The TDD style 2 edition

What is TypeScript

Page 7: Typescript kata The TDD style 2 edition

TypeScript?TypeScript is JavaScript with high-level language features.

Keyword Description

Modules Encapsulation for code and classes

Imports Import modules

Exports Export a member from module

Class Encapsulation for properties, variables and function members

Extends Extend a class. Used for inheritance

Implements Implements an interface

Interface Defines a contract of behavior when implemented by types

Constructor Provide initialization for classes

Public and Private Member visibillity modifier

=> Arrow syntax, also called lambda expressions, used with definitions and functions

: Seperator between the variable name and the variable type

... Rest syntax, the same as the C#’s method parameter params

<TypeName> Casting a type to another types

Generics <T> Encapsulate operations that are not specific to a particular type

Enum Used to quickly declare a range of constant or computed values

Page 8: Typescript kata The TDD style 2 edition

What is TypeScript

Starts with JavaScriptAll JavaScript code is TypeScript code, simply copy and pasteAll JavaScript libraries work with TypeScript

Optional Static Types, Classes, ModulesEnable scalable application development and excellent toolingZero cost: Static types completely disappear at run-time

Ends with JavaScriptCompiles to idiomatic JavaScriptRuns in any browser or host, on any OS

Page 9: Typescript kata The TDD style 2 edition

What is TypeScript

Library Typings (.d.ts files)DefinitelyTyped has > 326 community library typings projects344 contributors

Tools and Build IntegrationRich IDEs: Visual Studio, Eclipse, WebStorm, Cloud9, BracketsText Editors: SublimeText, vi, Emacs, JSBinBuild Integration: ASP.NET, node.js, compile-in-client, Ruby, grunt and more

Open SourceActive development on CodePlexThousands of issues/discussions, hundreds of participants

Page 10: Typescript kata The TDD style 2 edition

Who’s already using TypeScript

Page 11: Typescript kata The TDD style 2 edition

Test-Driven Development

TDD In the simplest form

We all know that we need to test our code, but do we do it? 9 out of 10 times we skip it over because we just think it's faster. My conclusion is that I am about 10% faster, and my code tested!

Page 12: Typescript kata The TDD style 2 edition

Solution, Testing vs TDD

Testing

Design Implement

Test

Test-Driven Development

Design TestImplemen

t Test

Page 13: Typescript kata The TDD style 2 edition

How to do it

Design: figure out what you wantTest: write a test to express the design

It should FAILImplement: Write the codeTest againg:

It should PASS

Page 14: Typescript kata The TDD style 2 edition

Code KataUsing Code Kata’s to become a better developer

A kata a day keeps the debugger awayApply a Kata daily for at least 15 minutes, by coding, refactoring and test-first,.

Code kata is an exercise in programming that helps a programmer hone their skills through practice and repetition.

Before you begin a Kata:

Try not to read ahead.

Do one task at a time. The trick is to learn to work incrementally.

Make sure you only test for correct inputs. there is no need to test for invalid inputs for this kata

Page 15: Typescript kata The TDD style 2 edition

Code Katas aren’t effectiveDoing the same thing over and over again doesn’t make us better at it

When we first learned from walking it was tuff, now it’s just a repetitive process

Page 16: Typescript kata The TDD style 2 edition

Lets do a string kata with

Page 17: Typescript kata The TDD style 2 edition

Diverse links

• TypeScript http://www.typescriptlang.org/

• Kata practices bit.ly/3sUjzK

• StringCalculator in different languages bit.ly/2wma3X

• Chutzpah – Javascript test runner bit.ly/qsazVS

• DefinitelyTyped repositories• Github bit.ly/Shdyzn• Nuget.org http://bit.ly/W0V3bD• nodeJS TSDPM bit.ly/VMo1LQ

• TypeScript Weekly http://paper.li/ronniedrengen/1386937876