langton-ant-dojo

Dojo : TDD Against the Time with React and Redux

This project is maintained by Bogala

Dojo : TDD Against the Time with React and Redux

What is the Langton’s Ant ?

Langton’s ant is a two-dimensional universal Turing machine with a very simple set of rules but complex emergent behavior. It was invented by Chris Langton in 1986 and runs on a square lattice of black and white cells. The universality of Langton’s ant was proven in 2000. The idea has been generalized in several different ways, such as turmites which add more colors and more states.

How it works ?

Squares on a plane are colored variously either black or white. We arbitrarily identify one square as the “ant”. The ant can travel in any of the four cardinal directions at each step it takes. The “ant” moves according to the rules below:

Langton’s ant can also be described as a cellular automaton, where the grid is colored black or white and the “ant” square has one of eight different colors assigned to encode the combination of black/white state and the current direction of motion of the ant.

Dojo’s rules

TDD

Test-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle: Requirements are turned into very specific test cases, then the software is improved to pass the new tests, only. This is opposed to software development that allows software to be added that is not proven to meet requirements. TDD Cycles 5 Steps to reproduce every cycle:

  1. Add a new test
  2. Run all tests and verify if the new test fails
  3. Write code to pass the new test to green
  4. Run all tests and verify all are green
  5. Refactor

For more informations, see Wikipedia

TDD Against the Time

In this type of sessions, we add one key constraint on the TDD cycle : Before each test, we launch a five minutes timer.

The five minute time constraint sounds fiendish doesn’t it? How can you possibly get anything done in five minutes? Well, you can, if you tackle something small enough. This exercise is designed to force you to think in small increments of functionality.

BDD

Behaviour-Driven Development (BDD) is a set of practices that aim to reduce some common wasteful activities in software development:

BDD aims to narrow the communication gaps between team members, foster better understanding of the customer and promote continuous communication with real world examples.

BDD

Example mapping

Example Mapping is a simple method to make this conversation short and very productive.

Concrete examples are a great way to help us explore and understand the problem domain. They are a great basis for our acceptance tests.

When discussing examples, other things might come up in the conversation that deserve to be captured too:

We can capture these different types of information on index cards, and arrange them in a map:

We keep going until the group is satisfied that the scope of the story is clear, or we run out of time.

Code coverage

All your code must be covered by unit tests. Our technology permit this : React, TypeScript, Jest and Enzyme.

Types

In this case, we’ll use Typescript to verify coherence between objects. We’ll avoid maximum any (implicit or not).

Steps

It is a six parts dojo, each part need previous (or previous solution) to be played :

  1. Create React Project
  2. A Grid and An Ant
  3. First rules and Component State
  4. From Component State to Redux
  5. Asynchronous logic with Redux
  6. Advanced Typescript and React Forms

Now we can begin the dojo with the first step : Create React App