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

Pro-bunfighting

Frances
March 31, 2010

 Pro-bunfighting

The process of API design in teams.
Web Standards Group, London.

Frances

March 31, 2010
Tweet

More Decks by Frances

Other Decks in Programming

Transcript

  1. A small and distributed problem There’s only 3 of us.

    2/3rds live in not-London. Build, support & learn.
  2. The unwrap() method “We need something that'll let us get

    a node and remove it from whatever it's in, and remove the parent, and then it needs to put the thing that's being unwrapped back in place. And then we'll give the user back what we put in. Any objections?”
  3. The unwrap() method “We need something that'll let us get

    a node and remove it from whatever it's in, and remove the parent, and then it needs to put the thing that's being unwrapped back in place. And then we'll give the user back what they put in. Any objections?”
  4. In JSDoc… @name glow.NodeList#unwrap @function @description Removes the parent of

    each item in the list @returns {glow.NodeList} The now unwrapped elements @example // Before: <div><p><span id="mySpan">Hello</span></p></div> // unwrap the given element glow("#mySpan").unwrap(); // After: <div><span id="mySpan">Hello</span></div>
  5. In JSDoc… @name glow.NodeList#unwrap @function @description Removes the parent of

    each item in the list @returns {glow.NodeList} The now unwrapped elements @example // Before: <div><p><span id="mySpan">Hello</span></p></div> // unwrap the given element glow("#mySpan").unwrap(); // After: <div><span id="mySpan">Hello</span></div>
  6. unwrap() test example module('glow.NodeList#unwrap', {setup:setup, teardown:teardown}); test('glow.dom.NodeList#unwrap multiple elements with

    same parent', 8, function() { var myNodeList = new glow.NodeList( byId('elmWithMixedNodes').childNodes ), returnNodeList; equal(typeof myNodeList.unwrap, 'function', 'glow.NodeList#unwrap is a function');
  7. unwrap() test example module('glow.NodeList#unwrap', {setup:setup, teardown:teardown}); test('glow.dom.NodeList#unwrap multiple elements with

    same parent', 8, function() { var myNodeList = new glow.NodeList( byId('elmWithMixedNodes').childNodes ), returnNodeList; equal(typeof myNodeList.unwrap, 'function', 'glow.NodeList#unwrap is a function'); returnNodeList = myNodeList.unwrap(); strictEqual(returnNodeList, myNodeList, 'Same nodelist returned'); myNodeList.each(function() { equal(this.parentNode.id, 'testElmsContainer', 'Node moved to parent'); }); equal(myNodeList.item(0).prev()[0].id, 'elmWithTextNodes', 'Node inserted in correct position');
  8. Run time How long does it take for this method

    to run 1000 times? woosh.addTests('glow2-src', { 'unwrap': new woosh.Test(1000, function() { // unwrap and keep count of unwraps performed }), }
  9. Over time How many times does this method run in

    a second? woosh.addTests('glow2-src', { 'unwrap': new woosh.TimeTest(1, function() { // unwrap and keep count of unwraps performed }), }
  10. The headlines • Treat documentation like code • There's no

    such thing as too many unit tests • Benchmark regularly if you want to get fast
  11. Roll credits Frances Berriman / @phae fberriman.com github.com/glow/glow2 Additional photos

    courtesy of: flickr.com/photos/stevec77/3870451388 flickr.com/photos/willsisti/4037142479 flickr.com/photos/jaffathecake/2835837370 flickr.com/photos/elson/3555981445