45
Backwards Compatibility taking it seriously

Taking backwards compatibility seriously

Embed Size (px)

Citation preview

Backwards

Compatibilitytaking it seriously

What is it?

Not breaking thingsfrom version to version

Maintaining methodsmethod v1 still works with method v2

Keeping consistencydesign, database schema, markup, etc

Basic examples

PHP

function do_thi_thing() { }

version 1.0

function do_this_thing() { }

version 2.0

Fatal errorundefined function: do_thi_thing()

function do_thi_thing() { return do_this_thing(); }

Solution:

CSS / HTML

.entry { background: #f0f0f0 }

<div class=“entry”>

.entry { background: #f0f0f0 }

<div class=“post”>

No more #f0f0f0

Oops

<div class=“post entry”>

Solution:

Filenames

require_once ‘includes/class-authors.php’;

class-authors.php

require_once ‘includes/class-authors.php’;

class-vendors.php

Fatal errorfile not found

Metadataget_post_meta( $post_id, ‘city_name’, true );

value: New York

Metadataget_post_meta( $post_id, ‘city’, true );

value:

function pw_filter_old_meta( $check, $object_id, $meta_key, $single ) {

if( 'city_name' === $meta_key ) {

$check = get_post_meta( $object_id, 'city', $single );

}

return $check;

}

add_filter( 'get_post_metadata', 'pw_filter_old_meta', 10, 4 );

Solution:

Solution:get_post_meta( $post_id, ‘city’, true );

value: New York

get_post_meta( $post_id, ‘city_name’, true );

value: New York

So many more

How easy is it?

Why worry about it?

What’s the benefit?

Does it slow you

down?

Case Study

EDD Signed URLslongest outstanding issue for EDD, 12/19/2012

2.3 released 3 days ago - how’d we do?

Old Methodhttp://edd/index.php?download_key={key}&email={email}&file=fil

e}&price_id={price}&download_id={id}&expire={expire}

http://edd/index.php?download_key=7211cce2df06b572890934

752a4c0896&email=pippin%40pippinsplugins.com&file=1&price

_id=1&download_id=514&expire=MTQyNDE2NzcyOQ%3D%3D

New Methodhttp://edd/index.php?eddfile={file}&ttl={expre}&token={tok

en}

http://edd/index.php?eddfile=2231%3A514%3A0&ttl=142

4167604&token=4d0a86fb8f8be40cf9927222076a5ced

Potential Breakagelet’s consider the possibilities

40,000+ active sitesbasic assumptions:

40,000+ active sitesbasic assumptions:

50 customers per site

40,000+ active sitesbasic assumptions:

50 customers per site

1 sale per customer / 1 download link per customer

40,000+ active sitesbasic assumptions:

50 customers per site

1 sale per customer / 1 download link per customer

50*40,000 = 2,000,000 broken download links

40,000+ active sitesbasic assumptions:

50 customers per site

1 sale per customer / 1 download link per customer

50*40,000 = 2,000,000 broken download links

…..

40,000+ active sitesbasic assumptions:

50 customers per site

1 sale per customer / 1 download link per customer

50*40,000 = 2,000,000 broken download links

…..

probably vastly under exaggeration

Challenge acceptedprogramming is all about challenges

Make it a goal

Mentalitygreat development is more about how it is thought out

than how it is done

your attitude and dedication will go further than your

knowledge of syntax

“I will”

ThanksPippin Williamson

pippinsplugins.com - @pippinsplugins