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

Harnessing the Power of UI Components (HTML5 De...

Harnessing the Power of UI Components (HTML5 Dev Conf)

Delivered at HTML5DevConf in SF, 20 Oct 2014.
Synopsis:

HTML5 apps are trending towards most (or all) of the behavioral logic running on the client. Because of this, we now need to think about architecting these UI's more like "native apps" than “pages”. While this dramatically increases the complexity on the client, it also opens new opportunities to tame that complexity through modern, modular UI component design.

Phil Cockfield will talk about practical approaches to writing clean, modular, reusable HTML5 UI components, and introduce a new concept of a "UI Harness" which brings together the flexibility of manual UI testing with the power of automatable unit tests.

Audience members will get an historical view of UI development on the web, showing how we got to where we are today, highlighting what is different in this new world of "native like," fully client-side UI development. The talk will illustrate this by delving into real-world examples of "UI Harnessing" in HTML5 for radically speeding up modular UI development using the Meteor framework.

http://uiharness.com
https://respond.ly

Phil Cockfield

October 20, 2014
Tweet

More Decks by Phil Cockfield

Other Decks in Programming

Transcript

  1. h1 h2 p Lorem ipsum dolor sit amet, consectetur adipisicing

    elit, sed do eiusmod tempor incididunt ut labore et. “page” “app” Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et. Lorem ip sit amet conse adipisi sed do eiusmod t. Lorem ipsum dolor Stateful Client Stateless Client
  2. 1970’s Alan Kay with an “Alto” at Xerox PARC SmallTalk,

    Objects, GUI, Overlapping Windows. http://cyborganthropology.com/File:Alan-kay.jpg
  3. 1984 ... Desktop apps: • Mac • Windows (Forms) •

    Java (Swing) Work done on the client.
  4. 1993 The Rails Logo - Copyright, MIT 2009 - http://commons.wikimedia.org/wiki/File:Ruby_on_Rails-logo.png

    “Page” paradigm. GET <html> <html> “Smart” Server “Dumb” Terminal HTTP
  5. 1993 The Rails Logo - Copyright, MIT 2009 - http://commons.wikimedia.org/wiki/File:Ruby_on_Rails-logo.png

    Mainframe GET <html> <html> “Smart” Server “Dumb” Terminal HTTP
  6. 2004 Dumb Client MVC The Rails Logo - Copyright, MIT

    2009 - http://commons.wikimedia.org/wiki/File:Ruby_on_Rails-logo.png The “smarts” are on the server. Model View <html> Controller GET/POST Page Redraw
  7. 2005 View AJAX REST End Point XMLHttpRequest <html> JS Some

    of the “smarts” move to the client. GET/POST Model Controller
  8. ~2012 Back to full MVC on the client. Controller View

    Model Updates Manipulates Sees Uses User HTML5 Thin Server
  9. 2014 <tmpl> JS <tmpl> JS Isomorphic Javascript Today: Realtime //

    Everywhere The “smarts” are everywhere. “Smart” Client JS DDP Real-time JS DDP Real-time MVC MVC
  10. Alto/Mac/Win Web 1.0/2.0 HTML5: RealTimeWeb Smarts on the client Smarts

    on the server Smarts on the client Mainframe Smarts on the server the new (old) way.
  11. h1 h2 p Lorem ipsum dolor sit amet, consectetur adipisicing

    elit, sed do eiusmod tempor incididunt ut labore et. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et. Lorem ip sit amet conse adipisi sed do eiusmod t. Lorem ipsum dolor What we now do looks a lot like native app development. Stateful Client
  12. Client/Server Client/Server + AJAX ! ! A ton of JS

    No JS Getting HARD! Complexity Difficulty Cloud Client Apps Hard Easy
  13. Client Complexity Client/Server Client/Server + AJAX ! ! A ton

    of JS No JS Opportunity! Cloud Client Apps Less Hard
  14. Hard when UI/MVC is split between client and server. Isolation

    and encapsulation. Model View <html> Controller GET/POST Page Redraw Server
  15. ©2007 L Hoffheins, some rights reserved. Lorem ipsum dolor sit

    amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et. Lorem ip sit amet conse adipisi sed do eiusmod t Lorem ipsum dolor Stateful Client App Isolation and encapsulation.
  16. ©2007 L Hoffheins, some rights reserved. Lorem ipsum dolor sit

    amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et Lorem ip sit amet conse adipisi sed do eiusmod t Lorem ipsum dolor Isolation and encapsulation. Easier on a stateful client.
  17. ©2007 L Hoffheins, some rights reserved. Isolation and encapsulation. Cell

    image: ©2013 BruceBlaus - http://bit.ly/1sSAEPO, Biological Cell
  18. ©2007 L Hoffheins, some rights reserved. Isolation and encapsulation. Cell

    image: ©2013 BruceBlaus - http://bit.ly/1sSAEPO, API • isPlaying • elapsedTime • trackLength • + play() • + stop() • ! changed Properties, methods, events. Internal implementation encapsulated and shielded from the world via an API.
  19. ©2007 L Hoffheins, some rights reserved. I, Curran Kelleher [GFDL

    (http://www.gnu.org/copyleft/fdl.html), CC-BY-SA-3.0 (http://creativecommons.org/licenses/by-sa/3.0/) or CC-BY-SA-2.5-2.0-1.0 (http://creativecommons.org/licenses/by-sa/2.5-2.0-1.0)], via Wikimedia Commons
  20. ©2007 L Hoffheins, some rights reserved. About eight complete mini

    “applications”. PopupPrompt (OK/Cancel) TextInput UserSelect UserSelectList UserSelectListItem Popup
  21. ©2007 L Hoffheins, some rights reserved. • focus() • clear()

    • caretToEnd() • isEnabled • isValid • isSpinning • multiLine • required • hoverEdit • selectOnFocus • maxLength • prefix • labelPosition • text • label • placeholder API Properties Methods • changed • focus • blur • keyDown • keyUp Events TextInput
  22. ©2007 L Hoffheins, some rights reserved. Why is this good?

    When we isolate our UI modules, we isolate our “problems.” I, Curran Kelleher [GFDL (http://www.gnu.org/copyleft/fdl.html), CC-BY-SA-3.0 (http://creativecommons.org/licenses/by-sa/3.0/) or CC-BY-SA-2.5-2.0-1.0 (http://creativecommons.org/licenses/by-sa/2.5-2.0-1.0)], via Wikimedia Commons
  23. ©2007 L Hoffheins, some rights reserved. HTML5 Components API Component

    JS <tmpl> CSS Example using: Meteor/Blaze Bower, Component, Ender, Jam, Volo, Meteor, Angular, Ember…Shadow Dom - Polymer, X-Tag etc.
  24. ©2007 L Hoffheins, some rights reserved. Typically we throw together

    some kind of ad hoc web page. Ctrl How do we build/test these?
  25. ©2007 L Hoffheins, some rights reserved. TextInput Ad hoc buttons

    with event handlers to exercise the API. The component under test. Simple HTML page.
  26. ©2007 L Hoffheins, some rights reserved. AD HOC SCAFFOLDING Highly

    flexible Manual manipulation of UI Programmatic manipulation of API Ad Hoc Scaffolding
  27. ©2007 L Hoffheins, some rights reserved. AD HOC SCAFFOLDING UNIT

    TESTS Describe behavior (design) Assertions (correctness) Automation (CI) Highly flexible Manual manipulation of UI Programmatic manipulation of API
  28. ©2007 L Hoffheins, some rights reserved. UNIT TESTS AD HOC

    SCAFFOLDING Highly flexible Manual manipulation of UI Programmatic manipulation of API UI Harness Describe behavior Assertions Automation
  29. ©2007 L Hoffheins, some rights reserved. UI Harness A principled

    way to isolate, test and document modular UI. www.uiharness.com Made for
  30. TextInput • focus() • clear() • caretToEnd() • isEnabled •

    isValid • isSpinning • multiLine • required • hoverEdit • selectOnFocus • maxLength • prefix • labelPosition • text • label • placeholder API Properties Methods • changed • focus • blur • keyDown • keyUp Events Demo
  31. www.uiharness.com I, Curran Kelleher [GFDL (http://www.gnu.org/copyleft/fdl.html), CC-BY-SA-3.0 (http://creativecommons.org/licenses/by-sa/3.0/) or CC-BY-SA-2.5-2.0-1.0

    (http://creativecommons.org/licenses/by-sa/2.5-2.0-1.0)], via Wikimedia Commons When we isolate our UI modules, we isolate our “problems.”
  32. More complex, less hard. Client Client/Server Client/Server + AJAX !

    ! A ton of JS No JS Cloud Client Apps Through clever architecture Hard Less Hard