163

Click here to load reader

Beyond Frameworks

Embed Size (px)

DESCRIPTION

The slides from my PHPUK 2011 conference talk on how to use an application framework without becoming a hostage to it.

Citation preview

Page 1: Beyond Frameworks

[email protected] - http://blog.stuartherbert.com/php/

Stuart Herbert

Beyond Frameworks

Using Frameworks WithoutBecoming A Hostage To Them

Stuart Herbert

Page 2: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

About Stuart

• Head of Engineering, Gradwell.com

• Co-author, Zend Certification Study Guide for PHP 4

• Open-source Contributor Since 1994

Page 3: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

About Stuart

• Head of Engineering, Gradwell.com

• Co-author, Zend Certification Study Guide for PHP 4

• Open-source Contributor Since 1994

Page 4: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

About Stuart

• Head of Engineering, Gradwell.com

• Co-author, Zend Certification Study Guide for PHP 4

• Open-source Contributor Since 1994

Page 5: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Contents

1

How Frameworks Have Held Us Hostage

Page 6: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Contents

2

Our Layered Architecture For PHP Applications

Page 7: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Contents

3What Makes A Good Component?

Page 8: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Contents

4

How Components Are Helping Gradwell

Page 9: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Questions

At The End, Please

Page 10: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Questions

For The Audience ...

Page 11: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

http://flic.kr/p/R33dr

Beyond Frameworks

Who Uses A Framework?

Page 12: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

http://flic.kr/p/qq6F1

Beyond Frameworks

Who Develops Software Products?

Page 13: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

1: HostagesTo Frameworks

Page 14: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Stop Me If You’ve Heard This One Before ...

Page 15: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

http://flic.kr/p/7MmEiv

Beyond Frameworks

First generation apps are highly-coupled

Neat until you attempt to untangle them!

Page 16: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

http://flic.kr/p/7MmEiv

Beyond Frameworks

First generation apps are highly-coupled

Neat until you attempt to untangle them!

Page 17: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

http://flic.kr/p/4sK29V

Beyond Frameworks

Second generation app built on top of own framework

Developers enjoyed building it

But they hated completing it or maintaining it

Page 18: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

http://flic.kr/p/4sK29V

Beyond Frameworks

Second generation app built on top of own framework

Developers enjoyed building it

But they hated completing it or maintaining it

Page 19: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

http://flic.kr/p/4sK29V

Beyond Frameworks

Second generation app built on top of own framework

Developers enjoyed building it

But they hated completing it or maintaining it

Page 20: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

So We Used A Popular Framework ...

Page 21: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

... Or Two ...

Page 22: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

http://flic.kr/p/2k87DM

Beyond Frameworks

Third generation app easy to extend

... after the steep learning curve

Page 23: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

http://flic.kr/p/2k87DM

Beyond Frameworks

Third generation app easy to extend

... after the steep learning curve

Page 24: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

http://flic.kr/p/7132Wm

Beyond Frameworks

We couldn’t get the code out to re-use in other apps

:(

Page 25: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Framework

Your Code Plugins

What The Architecture Should Look Like

Page 26: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Your Code Plugins

Framework

What Happened In Reality :(

Page 27: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

What Practical Challenges Does This Create?

Page 28: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

http://flic.kr/p/5Z6Arf

Beyond Frameworks

How long would it take to upgrade your app to the next major version of the framework?

Would you do the upgrade, or stick with the current framework version?

Page 29: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

http://flic.kr/p/5Z6Arf

Beyond Frameworks

How long would it take to upgrade your app to the next major version of the framework?

Would you do the upgrade, or stick with the current framework version?

Page 30: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

http://flic.kr/p/4Z8oZE

Beyond Frameworks

What would it take to switch your app to a different framework?

Could you port your code, or would you be forced to rewrite all or most of it?

Page 31: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

http://flic.kr/p/4Z8oZE

Beyond Frameworks

What would it take to switch your app to a different framework?

Could you port your code, or would you be forced to rewrite all or most of it?

Page 32: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

http://flic.kr/p/85jzRA

Beyond Frameworks

How would you re-use some of your app’s code in a different app?

Especially if the other app doesn’t use the same framework?

Page 33: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

http://flic.kr/p/85jzRA

Beyond Frameworks

How would you re-use some of your app’s code in a different app?

Especially if the other app doesn’t use the same framework?

Page 34: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

http://flic.kr/p/6GMfQc

Beyond Frameworks

How would you outsource some of your app development to teams around the world?

How would you accept the work delivered back to you?

Page 35: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

http://flic.kr/p/6GMfQc

Beyond Frameworks

How would you outsource some of your app development to teams around the world?

How would you accept the work delivered back to you?

Page 36: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Your Code Plugins

Framework

We Need To Change This ...

Page 37: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

To What ...?

Page 38: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

2: Layered Approach

Page 39: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Frameworks Your Code Plugins

Application

Let’s Take The Original Architecture ...

Page 40: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Frameworks App Code Plugins

Application

... And Make The App As Thin As Possible

Page 41: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Frameworks

Business Logic

App Code Plugins

Application

By Extracting Out ...

Page 42: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Frameworks

Business Logic Data Model

App Code Plugins

Application

By Extracting Out ...

Page 43: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Frameworks

Business Logic Data Model Utilities

App Code Plugins

Application

By Extracting Out ...

Page 44: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Frameworks

Business Logic Data Model Utilities

App Code Plugins

Application

Components

... Into Independent Libraries Of Code

Page 45: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Frameworks

Business Logic Data Model Utilities

App Code Plugins

Autoloader

Application

Components

Use An Autoloader To Pull In These New Components

Page 46: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Frameworks

Business Logic Data Model Utilities

App Code Plugins

Autoloader

Application

Components

This Gives You A Larger Set Of Reusable Code

Page 47: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

The Frameworked AppBecomes A Thin Layer

On Top Of Framework-agnostic

Reusable Components

Page 48: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Layered Architecture

Frameworks

Business Logic Data Model Utilities

App Code Plugins

Autoloader

Application

Components

Page 49: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Layered ArchitectureApplication

Components

Page 50: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Why Components?

Business Logic

Data Model

Utilities

• Completely independent of the framework

• Built & tested in isolation of your app code

• Can be built by different teams

• Don’t have to change when the framework changes

Page 51: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Why Components?

Business Logic

Data Model

Utilities

• Completely independent of the framework

• Built & tested in isolation of your app code

• Can be built by different teams

• Don’t have to change when the framework changes

Page 52: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Why Components?

Business Logic

Data Model

Utilities

• Completely independent of the framework

• Built & tested in isolation of your app code

• Can be built by different teams

• Don’t have to change when the framework changes

Page 53: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Why Components?

Business Logic

Data Model

Utilities

• Completely independent of the framework

• Built & tested in isolation of your app code

• Can be built by different teams

• Don’t have to change when the framework changes

Page 54: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Why Components?

Business Logic

Data Model

Utilities

• Reduces the Big Ball of String Syndrome

• Mindset change to light apps on top of rich service layer

• Improves development in parallel of apps & services

• Injects additional discipline into development teams

Page 55: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Why Components?

Business Logic

Data Model

Utilities

• Reduces the Big Ball of String Syndrome

• Mindset change to light apps on top of rich service layer

• Improves development in parallel of apps & services

• Injects additional discipline into development teams

Page 56: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Why Components?

Business Logic

Data Model

Utilities

• Reduces the Big Ball of String Syndrome

• Mindset change to light apps on top of rich service layer

• Improves development in parallel of apps & services

• Injects additional discipline into development teams

Page 57: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Why Components?

Business Logic

Data Model

Utilities

• Reduces the Big Ball of String Syndrome

• Mindset change to light apps on top of rich service layer

• Improves development in parallel of apps & services

• Injects additional discipline into development teams

Page 58: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Others Already Do This

Page 59: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

http://flic.kr/p/5oewwy

Beyond Frameworks

Perl Has CPAN Modules

Page 60: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

http://flic.kr/p/uyMuU

Beyond Frameworks

Ruby Has Gems

Page 61: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

What MakesA Good Component?

Page 62: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

3: Good Components

Page 63: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Component Standards

• Common standards

• Reusable by many

• Interoperable

• Trustable

Page 64: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Component Standards

• Common standards

• Reusable by many

• Interoperable

• Trustable

Page 65: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Component Standards

• Common standards

• Reusable by many

• Interoperable

• Trustable

Page 66: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Component Standards

• Common standards

• Reusable by many

• Interoperable

• Trustable

Page 67: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Good Components ...

• Autoload

• Are well tested

• Are well documented

• Are easy to install

• Don’t break backwards compatibility by surprise

Page 68: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Good Components ...

• Autoload

• Are well tested

• Are well documented

• Are easy to install

• Don’t break backwards compatibility by surprise

Page 69: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Good Components ...

• Autoload

• Are well tested

• Are well documented

• Are easy to install

• Don’t break backwards compatibility by surprise

Page 70: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Good Components ...

• Autoload

• Are well tested

• Are well documented

• Are easy to install

• Don’t break backwards compatibility by surprise

Page 71: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Good Components ...

• Autoload

• Are well tested

• Are well documented

• Are easy to install

• Don’t break backwards compatibility by surprise

Page 72: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Frameworks

Business Logic Data Model Utilities

App Code Plugins

Application

Components

Keep Components Outside Of Your App

Page 73: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Frameworks

Business Logic Data Model Utilities

App Code Plugins

Autoloader

Application

Components

Use An Autoloader To Pull In Components

Page 74: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Frameworks

Business Logic Data Model Utilities

App Code Plugins

Autoloader

Application

Components

Why Use An Autoloader?

Page 75: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Frameworks

Business Logic Data Model Utilities

App Code Plugins

Autoloader

Application

Components

Autoloading Makes Life Easy!

Page 76: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

• Who has heard of PSR0?

• http://groups.google.com/group/php-standards/web/psr-0-final-proposal

• Backed by leading names in the community

• Perfect for a component approach

One True Autoloader

Page 77: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

• Who has heard of PSR0?

• http://groups.google.com/group/php-standards/web/psr-0-final-proposal

• Backed by leading names in the community

• Perfect for a component approach

One True Autoloader

Page 78: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

• Who has heard of PSR0?

• http://groups.google.com/group/php-standards/web/psr-0-final-proposal

• Backed by leading names in the community

• Perfect for a component approach

One True Autoloader

Page 79: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

• Who has heard of PSR0?

• http://groups.google.com/group/php-standards/web/psr-0-final-proposal

• Backed by leading names in the community

• Perfect for a component approach

One True Autoloader

Page 80: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

• Namespace separators ‘\’ become DIRECTORY_SEPARATOR

• Underscore in class names ‘_’ become DIRECTORY_SEPARATOR

• Top namespace is your organisation

• Achieves 1:1 mapping from classname to filename on disk

PSR0 Autoloader

Page 81: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

• Namespace separators ‘\’ become DIRECTORY_SEPARATOR

• Underscore in class names ‘_’ become DIRECTORY_SEPARATOR

• Top namespace is your organisation

• Achieves 1:1 mapping from classname to filename on disk

PSR0 Autoloader

Page 82: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

• Namespace separators ‘\’ become DIRECTORY_SEPARATOR

• Underscore in class names ‘_’ become DIRECTORY_SEPARATOR

• Top namespace is your organisation

• Achieves 1:1 mapping from classname to filename on disk

PSR0 Autoloader

Page 83: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

• Namespace separators ‘\’ become DIRECTORY_SEPARATOR

• Underscore in class names ‘_’ become DIRECTORY_SEPARATOR

• Top namespace is your organisation

• Achieves 1:1 mapping from classname to filename on disk

PSR0 Autoloader

Page 84: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Autoloader Examples

• Phin_Project\ExtenderLib\FileLoader ->Phin_Project/ExtenderLib/FileLoader.php

• Phin_Project\Console\Std_Out ->Phin_Project/Console/Std/Out.php

Page 85: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Autoloader Examples

• Phin_Project\ExtenderLib\FileLoader ->Phin_Project/ExtenderLib/FileLoader.php

• Phin_Project\Console\Std_Out ->Phin_Project/Console/Std/Out.php

Page 86: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Autoloader Component

• pear channel-discover pear.gradwell.com

• pear install Gradwell/Autoloader

Page 87: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Autoloader Component

• pear channel-discover pear.gradwell.com

• pear install Gradwell/Autoloader

Page 88: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

http://flic.kr/p/3c2W8q

Beyond Frameworks

Testing

Page 89: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

PHPUnit

• De-facto standard for unit-testing PHP code

• Supported by leading IDEs

• Supported by CI environments

• Perfect for use with components

Page 90: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

PHPUnit

• De-facto standard for unit-testing PHP code

• Supported by leading IDEs

• Supported by CI environments

• Perfect for use with components

Page 91: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

PHPUnit

• De-facto standard for unit-testing PHP code

• Supported by leading IDEs

• Supported by CI environments

• Perfect for use with components

Page 92: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

PHPUnit

• De-facto standard for unit-testing PHP code

• Supported by leading IDEs

• Supported by CI environments

• Perfect for use with components

Page 93: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Good Tests ...

• Document supported behaviour

• Have separate tests for reported bugs

• Cover 100% of the component’s code

• Ship with the component

Page 94: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Good Tests ...

• Document supported behaviour

• Have separate tests for reported bugs

• Cover 100% of the component’s code

• Ship with the component

Page 95: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Good Tests ...

• Document supported behaviour

• Have separate tests for reported bugs

• Cover 100% of the component’s code

• Ship with the component

Page 96: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Good Tests ...

• Document supported behaviour

• Have separate tests for reported bugs

• Cover 100% of the component’s code

• Ship with the component

Page 97: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Getting PHPUnit

• Visit www.phpunit.de

Page 98: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

http://flic.kr/p/6wuB99

Beyond Frameworks

Documentation

Page 99: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

The PHP ManualIs One Of

PHP’s Killer Features

Page 100: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Make Your Documentation At Least As Good!

Page 101: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

• Explain how to load the component

• Describe how you intend it to be used

• Give several (non-trivial!) examples

• Capture notes / FAQs

Good Documentation

Page 102: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

• Explain how to load the component

• Describe how you intend it to be used

• Give several (non-trivial!) examples

• Capture notes / FAQs

Good Documentation

Page 103: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

• Explain how to load the component

• Describe how you intend it to be used

• Give several (non-trivial!) examples

• Capture notes / FAQs

Good Documentation

Page 104: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

• Explain how to load the component

• Describe how you intend it to be used

• Give several (non-trivial!) examples

• Capture notes / FAQs

Good Documentation

Page 105: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Write It Down ...

• ... so you don’t have to remember

• ... so you don’t have to keep explaining it to others

• ... so you don’t have to read the source

• ... so that others are more likely to reuse your efforts

Page 106: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Write It Down ...

• ... so you don’t have to remember

• ... so you don’t have to keep explaining it to others

• ... so you don’t have to read the source

• ... so that others are more likely to reuse your efforts

Page 107: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Write It Down ...

• ... so you don’t have to remember

• ... so you don’t have to keep explaining it to others

• ... so you don’t have to read the source

• ... so that others are more likely to reuse your efforts

Page 108: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Write It Down ...

• ... so you don’t have to remember

• ... so you don’t have to keep explaining it to others

• ... so you don’t have to read the source

• ... so that others are more likely to reuse your efforts

Page 109: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

www.phpunit.de/manual/3.5/en/

Beyond Frameworks

Docbook a la PHPUnit

Page 110: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

What About phpDoc?

• Useful for IDE code auto-completion

• Useful as a summary of a method’s purpose

• Reference documentation, not a manual

Page 111: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

What About phpDoc?

• Useful for IDE code auto-completion

• Useful as a summary of a method’s purpose

• Reference documentation, not a manual

Page 112: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

What About phpDoc?

• Useful for IDE code auto-completion

• Useful as a summary of a method’s purpose

• Reference documentation, not a manual

Page 113: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

http://flic.kr/p/41vMUJ

Beyond Frameworks

Packaging & Installation

Page 114: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

PEAR Installer

• Love it or hate it, PEAR package format is a community-created solution

• PEAR installer found on most computers

• Supports installing both system-wide and into a sandbox

• Simple to publish your own package repo

Page 115: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

PEAR Installer

• Love it or hate it, PEAR package format is a community-created solution

• PEAR installer found on most computers

• Supports installing both system-wide and into a sandbox

• Simple to publish your own package repo

Page 116: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

PEAR Installer

• Love it or hate it, PEAR package format is a community-created solution

• PEAR installer found on most computers

• Supports installing both system-wide and into a sandbox

• Simple to publish your own package repo

Page 117: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

PEAR Installer

• Love it or hate it, PEAR package format is a community-created solution

• PEAR installer found on most computers

• Supports installing both system-wide and into a sandbox

• Simple to publish your own package repo

Page 118: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

http://www.pirum-project.org/

Beyond Frameworks

Pirum

Page 119: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

pear channel-discover pear.gradwell.com

Beyond Frameworks

Your Own PEAR Channel

Page 120: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

github.com/Gradwell/phix

Beyond Frameworks

Phix For Making Components

Page 121: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/

http://flic.kr/p/5aK8jA

Beyond Frameworks

Backwards Compatible

Page 122: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Why It Matters

• Isolating code into components reduces amount of code that is affected by change

• Backwards-compatibility breaks immediately negate that advantage

• The more apps use a component, the worse the b/c breakage cost scales

Page 123: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Why It Matters

• Isolating code into components reduces amount of code that is affected by change

• Backwards-compatibility breaks immediately negate that advantage

• The more apps use a component, the worse the b/c breakage cost scales

Page 124: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Why It Matters

• Isolating code into components reduces amount of code that is affected by change

• Backwards-compatibility breaks immediately negate that advantage

• The more apps use a component, the worse the b/c breakage cost scales

Page 125: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Transparent Versions

• X.Y.Z scheme

• X == Major version / API / ABI version

• Y == Minor new features

• Z == Bug fixes

Page 126: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Transparent Versions

• X.Y.Z scheme

• X == Major version / API / ABI version

• Y == Minor new features

• Z == Bug fixes

Page 127: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Transparent Versions

• X.Y.Z scheme

• X == Major version / API / ABI version

• Y == Minor new features

• Z == Bug fixes

Page 128: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Transparent Versions

• X.Y.Z scheme

• X == Major version / API / ABI version

• Y == Minor new features

• Z == Bug fixes

Page 129: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

You Can Break B/C

• Just don’t do it by surprise!

• Don’t be afraid to increment X in X.Y.Z

• Google Chrome is already on 10.y.z ...

• ... and it hasn’t done it any harm

Page 130: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

You Can Break B/C

• Just don’t do it by surprise!

• Don’t be afraid to increment X in X.Y.Z

• Google Chrome is already on 10.y.z ...

• ... and it hasn’t done it any harm

Page 131: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

You Can Break B/C

• Just don’t do it by surprise!

• Don’t be afraid to increment X in X.Y.Z

• Google Chrome is already on 10.y.z ...

• ... and it hasn’t done it any harm

Page 132: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

You Can Break B/C

• Just don’t do it by surprise!

• Don’t be afraid to increment X in X.Y.Z

• Google Chrome is already on 10.y.z ...

• ... and it hasn’t done it any harm

Page 133: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

To Recap ...

Page 134: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Good Components ...

• Autoload

• Are well tested

• Are well documented

• Are easy to install

• Don’t break backwards compatibility by surprise

Page 135: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Good Components ...

• Autoload

• Are well tested

• Are well documented

• Are easy to install

• Don’t break backwards compatibility by surprise

Page 136: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Good Components ...

• Autoload

• Are well tested

• Are well documented

• Are easy to install

• Don’t break backwards compatibility by surprise

Page 137: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Good Components ...

• Autoload

• Are well tested

• Are well documented

• Are easy to install

• Don’t break backwards compatibility by surprise

Page 138: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Good Components ...

• Autoload

• Are well tested

• Are well documented

• Are easy to install

• Don’t break backwards compatibility by surprise

Page 139: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

... If They ...

• PSR0 - compliant autoloading

• PHPUnit tests

• Docbook manual

• Packages installed via PEAR installer

• Transparent version numbers

Page 140: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

... If They ...

• PSR0 - compliant autoloading

• PHPUnit tests

• Docbook manual

• Packages installed via PEAR installer

• Transparent version numbers

Page 141: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

... If They ...

• PSR0 - compliant autoloading

• PHPUnit tests

• Docbook manual

• Packages installed via PEAR installer

• Transparent version numbers

Page 142: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

... If They ...

• PSR0 - compliant autoloading

• PHPUnit tests

• Docbook manual

• Packages installed via PEAR installer

• Transparent version numbers

Page 143: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

... If They ...

• PSR0 - compliant autoloading

• PHPUnit tests

• Docbook manual

• Packages installed via PEAR installer

• Transparent version numbers

Page 144: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

4: An Example

Page 145: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Sales Pitch

Sales Website

Product Specs

AvailabilityChecker

We Sell Broadband Via Our Sales Website ...

Page 146: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Sales Pitch

Sales Website

Product Specs

AvailabilityChecker

Customer Account

Control Panel

Invoicing

AvailabilityChecker

And Our Customer Control Panel

Page 147: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Sales Pitch

Sales Website

Product Specs

AvailabilityChecker

Customer Account

Control Panel

Invoicing

AvailabilityChecker

iFrame

The Control Panel Holds The Code HostageThe Sales Site Relies On An iFrame

Page 148: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Sales Pitch

Sales Website

Product Specs

AvailabilityChecker

Customer Account

Control Panel

Invoicing

AvailabilityChecker

Provisioning

Third Party

Faults

AvailabilityChecker

... And The Control Panel TalksTo The Third Party Who Provides Our Broadband

SOAPiFrame

Page 149: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Sales Pitch

Sales Website

Product Specs

AvailabilityChecker

Customer Account

Control Panel

Invoicing

AvailabilityChecker

Provisioning

Third Party

Faults

AvailabilityChecker

We Wanted To Sell Exciting New Broadband ProductsFrom An Alternative Third Party As Well

SOAPiFrame

Page 150: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Sales Pitch

Sales Website

Product Specs

AvailabilityChecker

Customer Account

Control Panel

Invoicing

AvailabilityChecker

Provisioning

Third Party

Faults

AvailabilityChecker

Changing The Control PanelWas Going To Be Expensive ...

SOAPiFrame

Page 151: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Sales Pitch

Sales Website

Product Specs

AvailabilityChecker

Customer Account

Control Panel

Invoicing

AvailabilityChecker

Provisioning

Third Party

Faults

AvailabilityChecker

... But Was The Only WayTo Change The Sales Website

SOAPiFrame

Page 152: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Sales Pitch

Sales Website

Product Specs

AvailabilityChecker

Customer Account

Control Panel

Invoicing

AvailabilityChecker

Provisioning

Third Party

Faults

AvailabilityChecker

Problem Is ...We Are Due To Retire This Control Panel

Page 153: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Sales Pitch

Sales Website

Product Specs

AvailabilityChecker

AvailabilityChecker

Provisioning

Third Party

Faults

AvailabilityChecker

We Separated Out The Business LogicOf The Availability Checker

SOAP

Page 154: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Sales Pitch

Sales Website

Product Specs

AvailabilityChecker

Customer Account

Control Panel

Invoicing

AvailabilityChecker

Provisioning

Third Party

Faults

AvailabilityChecker

Sales Can Now Improve Their WebsiteWithout Having To Rely On Control Panel’s Roadmap

SOAP

Page 155: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Sales Pitch

Sales Website

Product Specs

AvailabilityChecker

Customer Account

Control Panel

Invoicing

AvailabilityChecker

Provisioning

Third Party

Faults

AvailabilityChecker

Allowing Engineering To RetireThis Version Of The Control Panel

Page 156: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

Sales Pitch

Sales Website

Product Specs

AvailabilityChecker

Customer Account

Control Panel 2

Invoicing

AvailabilityChecker

Provisioning

Third Party

Faults

AvailabilityChecker

And The New Control PanelWill Simply Re-use The Component Before Launch

Page 157: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

• Our customer profile has changed

• We have outgrown our old applications

• We are refactoring all of the needed logic from our old applications

• Allows Sales and Engineering roadmaps to move without major log jams

• Allows more features (especially internal ones)to be shared across more of our apps

Moving To Components

Page 158: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

• Our customer profile has changed

• We have outgrown our old applications

• We are refactoring all of the needed logic from our old applications

• Allows Sales and Engineering roadmaps to move without major log jams

• Allows more features (especially internal ones)to be shared across more of our apps

Moving To Components

Page 159: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

• Our customer profile has changed

• We have outgrown our old applications

• We are refactoring all of the needed logic from our old applications

• Allows Sales and Engineering roadmaps to move without major log jams

• Allows more features (especially internal ones)to be shared across more of our apps

Moving To Components

Page 160: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

• Our customer profile has changed

• We have outgrown our old applications

• We are refactoring all of the needed logic from our old applications

• Allows Sales and Engineering roadmaps to move without major log jams

• Allows more features (especially internal ones)to be shared across more of our apps

Moving To Components

Page 161: Beyond Frameworks

Stuart Herbert - http://blog.stuartherbert.com/php/Beyond Frameworks

• Our customer profile has changed

• We have outgrown our old applications

• We are refactoring all of the needed logic from our old applications

• Allows Sales and Engineering roadmaps to move without major log jams

• Allows more features (especially internal ones)to be shared across more of our apps

Moving To Components

Page 162: Beyond Frameworks

[email protected] - http://blog.stuartherbert.com/php/

Stuart Herbert

Thanks For Your Time

Feedback welcome!

I’d love to hear your stories