1. 活字体カタ:テスト駆動開発
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
@ronniedrengen
http://ronniehegelund.blogspot.dk/
2. About me!
Ronnie Hegelund
Technical Lead, Widex A/S
http://ronniehegelund.blogspot.dk/
@ronniedrengen
Love all facets of software development from
Test driven development, Software Architecture, continuous delivery
Focus on
Web, 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
7. 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
8. What is TypeScript
Starts with JavaScript
All JavaScript code is TypeScript code, simply copy and paste
All JavaScript libraries work with TypeScript
Optional Static Types, Classes, Modules
Enable scalable application development and excellent tooling
Zero cost: Static types completely disappear at run-time
Ends with JavaScript
Compiles to idiomatic JavaScript
Runs in any browser or host, on any OS
9. What is TypeScript
Library Typings (.d.ts files)
DefinitelyTyped has > 326 community library typings projects
344 contributors
Tools and Build Integration
Rich IDEs: Visual Studio, Eclipse, WebStorm, Cloud9, Brackets
Text Editors: SublimeText, vi, Emacs, JSBin
Build Integration: ASP.NET, node.js, compile-in-client, Ruby, grunt
and more
Open Source
Active development on CodePlex
Thousands of issues/discussions, hundreds of participants
11. Test-Driven Development
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!
TDD In the simplest form
12. Solution, Testing vs TDD
Testing
Test-Driven Development
Design
Design
Test
Implement
Implement
Test
Test
13. How to do it
Design: figure out what you want
Test: write a test to express the design
It should FAIL
Implement: Write the code
Test againg:
It should PASS
14. Code Kata
Using Code Kata’s to become a better developer
Code kata is an exercise in programming that helps a programmer hone
their skills through practice and repetition.
A kata a day keeps the debugger away
Apply a Kata daily for at least 15 minutes, by coding, refactoring and test-first,.
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
15. Code Katas aren’t effective
Doing 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