JS Code Kata: Linked List

JS Code Kata: Linked List

We use TDD and a simplified version of the Transformation Priority Premise to implement Linked List in JavaScript

Code: https://github.com/yitznewton/linked_list_js

References:

https://blog.8thlight.com/uncle-bob/2013/05/27/TheTransformationPriorityPremise.html

https://cleancoders.com/category/advanced-tdd

Ad742bd02b2b67ae4e5cad6c6a888d93?s=128

Yitz Schaffer

July 08, 2015
Tweet

Transcript

  1. 1.

    JS

  2. 4.

    Other useful JS libraries • eshint (code linter) • underscore

    (FP helpers) • q (async promises) • karma (test runner)
  3. 7.

    Linked List var first = { value: 12 }; var

    second = { value: 99 }; var third = { value: 37 }; first.next = second; second.next = third;
  4. 8.

    Linked List var list = new LinkedList(); list.append(12); list.append(99); list.append(37);

    list.each(function(v) { console.log(v); }); // log: 12 99 37
  5. 9.

    Object Behavior • Return a value • Send a message

    to another object • Change internal state When receiving a message:
  6. 10.

    Testing Object Behavior When receiving a message: • Return a

    value • Send a message to another object • Change internal state
  7. 11.

    Linked List var list = new LinkedList(); list.append(12); list.append(99); list.append(37);

    list.each(function(v) { console.log(v); }); // log: 12 99 37
  8. 12.

    TDD • No production code which does not make a

    failing test pass • Stop writing test code once there is enough to fail • No more production code than will make the test pass