Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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

Yitz Schaffer

July 08, 2015
Tweet

More Decks by Yitz Schaffer

Other Decks in Programming

Transcript

  1. JS

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

    (FP helpers) • q (async promises) • karma (test runner)
  3. Linked List var first = { value: 12 }; var

    second = { value: 99 }; var third = { value: 37 }; first.next = second; second.next = third;
  4. 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. Object Behavior • Return a value • Send a message

    to another object • Change internal state When receiving a message:
  6. Testing Object Behavior When receiving a message: • Return a

    value • Send a message to another object • Change internal state
  7. 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. 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