reducing complexity with a component api

53
Reducing Complexity with a Component API Ian Feather

Upload: ianfeather

Post on 29-Nov-2014

1.683 views

Category:

Technology


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Reducing complexity with a Component API

Reducing Complexity with a Component API

Ian Feather

Page 2: Reducing complexity with a Component API

Complexity

Page 3: Reducing complexity with a Component API

High risk, high fear

Page 4: Reducing complexity with a Component API

Intertwined

Page 5: Reducing complexity with a Component API

Low reuse

Page 6: Reducing complexity with a Component API

Technical debt

Page 7: Reducing complexity with a Component API

!

Complexity at

" ";

Page 8: Reducing complexity with a Component API
Page 9: Reducing complexity with a Component API

This time we’ll nail it

Page 10: Reducing complexity with a Component API

HTML CSS JS

SHA

RED

SPEC

IFIC

HOTELS

The rebuild

Page 11: Reducing complexity with a Component API

HTML CSS JS

SHA

RED

SPEC

IFIC

High Reuse

Low ReuseHOTELS

The rebuild

Page 12: Reducing complexity with a Component API

HTML CSS JS

SHA

RED

SPEC

IFIC

High ReuseStrong Caching

Low ReuseWeak CachingHOTELS

The rebuild

Page 13: Reducing complexity with a Component API

HTML CSS JS

SHA

RED

SPEC

IFIC

High ReuseStrong CachingHigh Risk

Low ReuseWeak CachingLow Risk

HOTELS

The rebuild

Page 14: Reducing complexity with a Component API

HTML CSS JS

SHA

RED

SPEC

IFIC

HOTELS PLACES SEARCH THEME

High Reuse Strong CachingHigh Risk

Low Reuse Weak Caching Low Risk

The rebuild

Page 15: Reducing complexity with a Component API

HTML CSS JS

SHA

RED

SPEC

IFIC

HOTELS PLACES SEARCH THEME

High Reuse Strong CachingHigh Risk

Low Reuse Weak Caching Low Risk

The rebuild

Page 16: Reducing complexity with a Component API

HTML CSS JS

SHA

RED

SPEC

IFIC

HOTELS PLACES SEARCH THEME

High Reuse Strong CachingHigh Risk

Low Reuse Weak Caching Low Risk

The rebuild

Page 17: Reducing complexity with a Component API

This model doesn’t favourthe front end

Page 18: Reducing complexity with a Component API

We need a differentsolution

Page 19: Reducing complexity with a Component API
Page 20: Reducing complexity with a Component API

It should feel as easy asworking on a small site

Page 21: Reducing complexity with a Component API

A Style Guide wouldhelp, right?

Page 22: Reducing complexity with a Component API

/* Styleguide [Buttons] !<button class=“btn-primary”>Button</button> <button class=“btn-secondary”>Button</button> !*/ !.btn—primary { background: blue; } !.btn—secondary { background: red; }

Page 23: Reducing complexity with a Component API
Page 24: Reducing complexity with a Component API

A Style Guide isn’tthe mechanism

Page 25: Reducing complexity with a Component API

We need to decouple ourUI Layer from the application

Page 26: Reducing complexity with a Component API

Component Layer & API

Page 27: Reducing complexity with a Component API

What is a component?

Page 28: Reducing complexity with a Component API

Create an API to standardisefetching these components

Page 29: Reducing complexity with a Component API
Page 30: Reducing complexity with a Component API

= component(“form/search”, { label: search})

Page 31: Reducing complexity with a Component API

<form action="/search"> <label class="accessibility" for="search-q">Search</label> <input id="search-q" name="q" tabindex="1" type=“search"/> <button name="search-q-submit" type="submit">Search</button> </form>

= component(“form/search”, { label: search})

Page 32: Reducing complexity with a Component API
Page 33: Reducing complexity with a Component API

component(“input/search”, { label: search,

autocomplete: true})

Page 34: Reducing complexity with a Component API

<form action="/search"> <label class="accessibility" for="search-q">Search</label> <input class="js-autocomplete" id="search-q" name=“q" /> <button name="search-q-submit" type="submit">Search</button> <div class="js-autocomplete-container"></div> </form>

component(“input/search”, { label: search,

autocomplete: true})

Page 35: Reducing complexity with a Component API
Page 36: Reducing complexity with a Component API

component("cards/collection_card", { double?: true,

slug: "/top-things-to-do—in-paris",

title: "Top things to do in Paris",

image_url: "/assets/paris.jpg" })

Page 37: Reducing complexity with a Component API
Page 38: Reducing complexity with a Component API
Page 39: Reducing complexity with a Component API

SPEC

IFIC

Low RiskLow Reuse

HOTELS PLACES SEARCH THEME

HTML CSS JS

SHA

RED High Risk

High Reuse

Page 40: Reducing complexity with a Component API

SPEC

IFIC

Low RiskLow Reuse

HOTELS PLACES SEARCH THEME

HTML CSS JS

SHA

RED High Risk

High Reuse

Low RiskHigh ReuseComponent Layer & API

Page 41: Reducing complexity with a Component API

Rizzo !

Component Layer, API & Style Guide

Page 42: Reducing complexity with a Component API

Our Style Guide can be justanother data-driven application

Page 43: Reducing complexity with a Component API

A ready-made visual regression test suite

Page 44: Reducing complexity with a Component API

Enables Style Guide driven development

Page 45: Reducing complexity with a Component API
Page 46: Reducing complexity with a Component API
Page 47: Reducing complexity with a Component API

Why would youwant to use a

Component API?

Page 48: Reducing complexity with a Component API

You’ll havehappier developers

Page 49: Reducing complexity with a Component API

You’ll havevisual consistency

Page 50: Reducing complexity with a Component API

You’ll be able torefactor easily

Page 51: Reducing complexity with a Component API

You won’t have to tweak padding values

(as much)

Page 52: Reducing complexity with a Component API

It can feel like workingon a small site

Page 53: Reducing complexity with a Component API

Thank you

@ianfeather

http://rizzo.lonelyplanet.com