Skip to content

Instantly share code, notes, and snippets.

View jon-acker's full-sized avatar

Jon Acker jon-acker

View GitHub Profile
@jon-acker
jon-acker / library.md
Created September 15, 2019 15:33
Library Lending System BDD/TDD Kata

Library Lending System

Objective: collaboratively come up with use-case examples and write executable specifications (Gherkin scenarios) for system that allows library members to borrow and return book, as well as charge the correct overdue fines.

Use the scenarios to drive the code to create a software model of the library lending process (the end product is a bunch of classes that can be instantiated and used to run business)

Identify the boundaries of the system (where infrastructure would be connected .e.g. apis or database) and use interfaces at these points. Provide fake implementations for the infrastructure in order to run the scenarios.

Identify the ubiquitous language of the library lending and fine charging domain and use the same language to write the scenarios in.

@jon-acker
jon-acker / tictactoe.md
Created September 15, 2019 15:15
Tic Tac Toe

Rules

  • A game starts with an empty 3x3 grid
  • Two players, one plays symbol X the other plays symbol O
  • player can place symbol in any square that's not taken
  • If player tried to place symbol in already taken squares, they are told "cannot play that position"
  • When all 9 squares are full - the game is over and ends with tie
  • The first player to have 3 of their symbols in a diagonal, row or column wins
@jon-acker
jon-acker / tennis.md
Last active September 18, 2019 21:26
Tennis TDD Kata

Tennis Game Kata

Rules:

  1. A game is won by the first player to have won at least four points in total and at least two points more than the opponent.

  2. The running score of each game is described in a manner peculiar to tennis: scores from zero to three points are described as “Love”, “Fifteen”, “Thirty”, and “Forty” respectively.

  3. If at least three points have been scored by each player, and the scores are equal, the score is a "Deuce"

@jon-acker
jon-acker / tennis_kata.md
Created September 15, 2019 15:08
Tennis Game Kata (gherkin style)

Tennis Game Kata

Rules:

  1. A game is won by the first player to have won at least four points in total and at least two points more than the opponent.

  2. The running score of each game is described in a manner peculiar to tennis: scores from zero to three points are described as “Love”, “Fifteen”, “Thirty”, and “Forty” respectively.

  3. If at least three points have been scored by each player, and the scores are equal, the score is “Deuce”.

@jon-acker
jon-acker / string_calculator.md
Last active September 15, 2019 15:17
String Calculator Kata

String Caluclator Kata

E.g., create a class a method called calc, which does the following:

It returns 0 for empty string It returns the bare number for a single number (e.g. '2' -> 2) It returns the sum of space-separated numbers (e.g. '1 2' -> 3) It returns the sum of any whitespace-separated numbers (e.g. "1 2\t3\n4" -> 10) It returns the sum of numbers separated by custom separator given as first char (e.g. '12' -> 3)

@jon-acker
jon-acker / fibbonanci.md
Last active September 15, 2019 15:17
Fibbonanci Kata

Fibonanci Sequence Kata

The function takes number of steps and returns the sequence

Returns [0] for 0 Returns [0,1] for 1 Returns [0,1,1] for 2 Returns [0,1,1,2] for 3 Returns [0,1,1,2,3] for 4 Try to develop the algorithm iteratively by writing just enough code to pass each step.

<html>
<style>
div {
float: left;
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
font-size: 14px;
}
@jon-acker
jon-acker / main.ts
Created October 3, 2017 15:07
Run Angular 4 app in NodeJS using jsdom instead of a real DOM
import 'zone.js';
import 'reflect-metadata';
import * as path from 'path';
import * as fs from 'fs';
// import { XMLHttpRequest } from 'xmlhttprequest';
import { JSDOM } from 'jsdom';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { ResourceLoader } from '@angular/compiler';
import { AppModule } from './app/app.module';