SlideShare una empresa de Scribd logo
1 de 49
Descargar para leer sin conexión
Principles of PHP Package Design 
Object oriented design for packages 
Matthias Noback - Noback's Office 
Elcodi Community Day - 10/25/2014
Matthias Noback 
Noback's Office 
PHP developer, consultant 
Writer, speaker 
Proud father 
· 
· 
· 
2/50
Blog 
php-and-symfony.matthiasnoback.nl 
3/50
A Year With Symfony 
leanpub.com/a-year-with-symfony 
4/50
Tight coupling 
Coupling to a framework 
5/50
Code 
6/50
Squiggly lines 
7/50
Code 
8/50
Packages 
There are many different kinds 
9/50
Class design 
10/50
Package design 
Nothing? 
butunclebob.com 
11/50
Principles of PHP Package Design 
leanpub.com/principles-of-php-package-design 
12/50
Package design 
Cohesion 
13/50
Package design 
Coupling 
14/50
A - Cohesion principles 
Perspective: the package in isolation 
15/50
1 - The Release Reuse Equivalence Principle 
The granule of reuse is the granule of release 
16/50
1 - The Release Reuse Equivalence Principle 
Version control and hosting 
Composer package definition 
Meta-files 
Auto-loading 
· 
· 
· 
· 
Semantic versioning 
Quality control 
· 
Branches 
Tags 
Backward compatibility 
- 
- 
- 
· 
17/50
1 - The Release Reuse Equivalence Principle 
If you don't have the time to turn your reusable code into a proper package... 
Don't release it. 
18/50
2- The Common Reuse Principle 
Classes that are used together are packaged together 
If you use one class of a package, 
you will use all its other classes too. 
19/50
2- The Common Reuse Principle 
Smell: Feature strata 
20/50
2- The Common Reuse Principle 
Example of feature strata: the Symfony Security Component 
21/50
2- The Common Reuse Principle 
Smell: Classes with different dependencies 
22/50
2- The Common Reuse Principle 
Example of different dependencies: Gaufrette 
23/50
2- The Common Reuse Principle 
Different dependencies: Gaufrette 
{ 
"name": "knplabs/gaufrette", 
... 
"suggest": { 
"knplabs/knp-gaufrette-bundle": "to use with Symfony2", 
"dropbox-php/dropbox-php": "to use the Dropbox adapter", 
"rackspace/php-opencloud" : "to use Opencloud adapter", 
"herzult/php-ssh": "to use SFtp adapter", 
"phpseclib/phpseclib": "to use PhpseclibSftp adapter", 
"aws/aws-sdk-php": "to use the Amazon S3 adapter", 
"amazonwebservices/aws-sdk-for-php": "to use the legacy Amazon S3 adapters", 
"doctrine/dbal": "to use the Doctrine DBAL adapter", 
"microsoft/windowsazure": "to use Microsoft Azure Blob Storage adapter", 
"ext-zip": "to use the Zip adapter", 
"ext-apc": "to use the APC adapter", 
... 
}, 
... 
} 24/50
2 - The Common Reuse Principle 
Leszek Prabucki's response 
25/50
3 - The Common Closure Principle 
Classes that change together are packaged together 
26/50
3 - The Common Closure Principle 
Reasons for change 
The application's features change 
The business rules change 
The web framework's best practices change 
The persistence library's configuration changes 
... 
· 
· 
· 
· 
· 
27/50
3 - The Common Closure Principle 
Smell: code for multiple application layers 
Web User Interface 
Command-line interface 
Model 
Infrastructure services 
· 
· 
· 
· 
28/50
B - Coupling principles 
Perspective: the package in relation to other packages 
29/50
4 - The Acyclic Dependencies Principle 
The dependency graph of packages must have no cycles 
30/50
4 - The Acyclic Dependencies Principle 
31/50
Stability 
Something is stable if it's resistant to change. 
32/50
5 - The Stable Dependencies Principle 
An irresponsible package 
33/50
5 - The Stable Dependencies Principle 
A dependent package 
34/50
5 - The Stable Dependencies Principle 
An instable package: irresponsible and dependent 
35/50
5 - The Stable Dependencies Principle 
A responsible package 
36/50
5 - The Stable Dependencies Principle 
An independent package 
37/50
5 - The Stable Dependencies Principle 
A stable package: responsible and independent 
38/50
5 - The Stable Dependencies Principle 
Depend in the direction of stability 
39/50
5 - The Stable Dependencies Principle 
Counter example 
40/50
6 - The Stable Abstractions Principle 
What is more likely to change? 
Something concrete or something abstract? 
A class or an interface? 
· 
· 
41/50
6 - The Stable Abstractions Principle 
Abstractness should increase with stability 
42/50
Summary 
Reuse/release equivalence principle 
Common reuse principle 
Common closure principle 
Acyclic dependencies principle 
Stable dependencies principle 
Stable abstractions principle 
· 
Reuse only code that you can release - as a product. 
· 
- All code in a package is reused at the same time. 
· 
- Code in a package only changes for a few reasons. 
· 
- No cycles in the dependency graph. 
· 
- Only depend on more stable packages. 
· 
- More stable packages are also more abstract. 
43/50
Word of advice 
You can't maximize them all at the same time. 
Keep them in mind while you are working on a package. 
44/50
Principles of PHP Package Design 
leanpub.com/principles-of-php-package-design 
I'm impressed. — Robert C. Martin 
45/50
Principles of PHP Package Design 
Get a 10 dollar discount: 
http://leanpub.com/principles-of-php-package-design/c/symfony-barcelona 
46/50
Questions? 
twitter @matthiasnoback 
leanpub leanpub.com/principles-of-php-package-design 
47/50
Image courtesy 
Clean Coders 
GitHub 
BitBucket 
Packagist 
PoEAA 
But Uncle Bob 
Robert Martin 
· 
· 
· 
· 
· 
· 
· 
48/50
50/50

Más contenido relacionado

Similar a Principles of PHP Package Design - Elcodi Community Day

Continuing Evolution of Perl: Highlights of ActivePerl 5.14
Continuing Evolution of Perl: Highlights of ActivePerl 5.14Continuing Evolution of Perl: Highlights of ActivePerl 5.14
Continuing Evolution of Perl: Highlights of ActivePerl 5.14ActiveState
 
Workshop: Refactoring Legacy PHP: The Complete Guide
Workshop: Refactoring Legacy PHP: The Complete Guide Workshop: Refactoring Legacy PHP: The Complete Guide
Workshop: Refactoring Legacy PHP: The Complete Guide Junade Ali
 
WPSessions Composer for WordPress Plugin Development
WPSessions Composer for WordPress Plugin DevelopmentWPSessions Composer for WordPress Plugin Development
WPSessions Composer for WordPress Plugin DevelopmentCaldera Labs
 
Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13DanWooster1
 
Updating_PHP_on_OS_X_Server
Updating_PHP_on_OS_X_ServerUpdating_PHP_on_OS_X_Server
Updating_PHP_on_OS_X_Servertutorialsruby
 
Updating_PHP_on_OS_X_Server
Updating_PHP_on_OS_X_ServerUpdating_PHP_on_OS_X_Server
Updating_PHP_on_OS_X_Servertutorialsruby
 
<img src="../i/r_14.png" />
<img src="../i/r_14.png" /><img src="../i/r_14.png" />
<img src="../i/r_14.png" />tutorialsruby
 
Symfony HTTP Kernel for refactoring legacy apps: the eZ Publish case study - ...
Symfony HTTP Kernel for refactoring legacy apps: the eZ Publish case study - ...Symfony HTTP Kernel for refactoring legacy apps: the eZ Publish case study - ...
Symfony HTTP Kernel for refactoring legacy apps: the eZ Publish case study - ...Gaetano Giunta
 
Making the Most of Modern PHP in Drupal 7
Making the Most of Modern PHP in Drupal 7Making the Most of Modern PHP in Drupal 7
Making the Most of Modern PHP in Drupal 7Ryan Szrama
 
eZPublish meets Simfony2 - phpDay2013
eZPublish meets Simfony2  - phpDay2013eZPublish meets Simfony2  - phpDay2013
eZPublish meets Simfony2 - phpDay2013Gaetano Giunta
 
Php tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPhp tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPrinceGuru MS
 
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Dana Luther
 
PURL and vers: The Mostly Universal Package URL and Version Ranges Identifier...
PURL and vers: The Mostly Universal Package URL and Version Ranges Identifier...PURL and vers: The Mostly Universal Package URL and Version Ranges Identifier...
PURL and vers: The Mostly Universal Package URL and Version Ranges Identifier...Michael Herzog
 
Puppet | Custom Modules & Using the Forge
Puppet | Custom Modules & Using the ForgePuppet | Custom Modules & Using the Forge
Puppet | Custom Modules & Using the ForgeAaron Bernstein
 
Functional Solid, Aleksandr Sugak
Functional Solid, Aleksandr SugakFunctional Solid, Aleksandr Sugak
Functional Solid, Aleksandr SugakSigma Software
 
How composer saved PHP
How composer saved PHPHow composer saved PHP
How composer saved PHPRyan Kilfedder
 

Similar a Principles of PHP Package Design - Elcodi Community Day (20)

Extending Perl Critic
Extending Perl CriticExtending Perl Critic
Extending Perl Critic
 
Oop principles
Oop principlesOop principles
Oop principles
 
Continuing Evolution of Perl: Highlights of ActivePerl 5.14
Continuing Evolution of Perl: Highlights of ActivePerl 5.14Continuing Evolution of Perl: Highlights of ActivePerl 5.14
Continuing Evolution of Perl: Highlights of ActivePerl 5.14
 
Workshop: Refactoring Legacy PHP: The Complete Guide
Workshop: Refactoring Legacy PHP: The Complete Guide Workshop: Refactoring Legacy PHP: The Complete Guide
Workshop: Refactoring Legacy PHP: The Complete Guide
 
WPSessions Composer for WordPress Plugin Development
WPSessions Composer for WordPress Plugin DevelopmentWPSessions Composer for WordPress Plugin Development
WPSessions Composer for WordPress Plugin Development
 
Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13
 
composer_talk_20160209
composer_talk_20160209composer_talk_20160209
composer_talk_20160209
 
Updating_PHP_on_OS_X_Server
Updating_PHP_on_OS_X_ServerUpdating_PHP_on_OS_X_Server
Updating_PHP_on_OS_X_Server
 
Updating_PHP_on_OS_X_Server
Updating_PHP_on_OS_X_ServerUpdating_PHP_on_OS_X_Server
Updating_PHP_on_OS_X_Server
 
<img src="../i/r_14.png" />
<img src="../i/r_14.png" /><img src="../i/r_14.png" />
<img src="../i/r_14.png" />
 
Symfony HTTP Kernel for refactoring legacy apps: the eZ Publish case study - ...
Symfony HTTP Kernel for refactoring legacy apps: the eZ Publish case study - ...Symfony HTTP Kernel for refactoring legacy apps: the eZ Publish case study - ...
Symfony HTTP Kernel for refactoring legacy apps: the eZ Publish case study - ...
 
Making the Most of Modern PHP in Drupal 7
Making the Most of Modern PHP in Drupal 7Making the Most of Modern PHP in Drupal 7
Making the Most of Modern PHP in Drupal 7
 
eZPublish meets Simfony2 - phpDay2013
eZPublish meets Simfony2  - phpDay2013eZPublish meets Simfony2  - phpDay2013
eZPublish meets Simfony2 - phpDay2013
 
Php tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPhp tutorial from_beginner_to_master
Php tutorial from_beginner_to_master
 
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
 
PURL and vers: The Mostly Universal Package URL and Version Ranges Identifier...
PURL and vers: The Mostly Universal Package URL and Version Ranges Identifier...PURL and vers: The Mostly Universal Package URL and Version Ranges Identifier...
PURL and vers: The Mostly Universal Package URL and Version Ranges Identifier...
 
Puppet | Custom Modules & Using the Forge
Puppet | Custom Modules & Using the ForgePuppet | Custom Modules & Using the Forge
Puppet | Custom Modules & Using the Forge
 
Functional Solid, Aleksandr Sugak
Functional Solid, Aleksandr SugakFunctional Solid, Aleksandr Sugak
Functional Solid, Aleksandr Sugak
 
Functional solid
Functional solidFunctional solid
Functional solid
 
How composer saved PHP
How composer saved PHPHow composer saved PHP
How composer saved PHP
 

Más de Matthias Noback

Rector fireside chat - PHPMiNDS meetup
Rector fireside chat - PHPMiNDS meetupRector fireside chat - PHPMiNDS meetup
Rector fireside chat - PHPMiNDS meetupMatthias Noback
 
Service abstractions - Part 1: Queries
Service abstractions - Part 1: QueriesService abstractions - Part 1: Queries
Service abstractions - Part 1: QueriesMatthias Noback
 
Hexagonal Symfony - SymfonyCon Amsterdam 2019
Hexagonal Symfony - SymfonyCon Amsterdam 2019Hexagonal Symfony - SymfonyCon Amsterdam 2019
Hexagonal Symfony - SymfonyCon Amsterdam 2019Matthias Noback
 
Advanced web application architecture - PHP Barcelona
Advanced web application architecture  - PHP BarcelonaAdvanced web application architecture  - PHP Barcelona
Advanced web application architecture - PHP BarcelonaMatthias Noback
 
A testing strategy for hexagonal applications
A testing strategy for hexagonal applicationsA testing strategy for hexagonal applications
A testing strategy for hexagonal applicationsMatthias Noback
 
Advanced web application architecture - Talk
Advanced web application architecture - TalkAdvanced web application architecture - Talk
Advanced web application architecture - TalkMatthias Noback
 
DPC 2019, Amsterdam: Beyond design patterns and principles - writing good OO ...
DPC 2019, Amsterdam: Beyond design patterns and principles - writing good OO ...DPC 2019, Amsterdam: Beyond design patterns and principles - writing good OO ...
DPC 2019, Amsterdam: Beyond design patterns and principles - writing good OO ...Matthias Noback
 
Layers, ports and adapters
Layers, ports and adaptersLayers, ports and adapters
Layers, ports and adaptersMatthias Noback
 
Beyond design principles and patterns (muCon 2019 edition)
Beyond design principles and patterns (muCon 2019 edition)Beyond design principles and patterns (muCon 2019 edition)
Beyond design principles and patterns (muCon 2019 edition)Matthias Noback
 
Brutal refactoring, lying code, the Churn, and other emotional stories from L...
Brutal refactoring, lying code, the Churn, and other emotional stories from L...Brutal refactoring, lying code, the Churn, and other emotional stories from L...
Brutal refactoring, lying code, the Churn, and other emotional stories from L...Matthias Noback
 
Advanced web application architecture Way2Web
Advanced web application architecture Way2WebAdvanced web application architecture Way2Web
Advanced web application architecture Way2WebMatthias Noback
 
Brutal refactoring, lying code, the Churn, and other emotional stories from L...
Brutal refactoring, lying code, the Churn, and other emotional stories from L...Brutal refactoring, lying code, the Churn, and other emotional stories from L...
Brutal refactoring, lying code, the Churn, and other emotional stories from L...Matthias Noback
 
Beyond Design Principles and Patterns
Beyond Design Principles and PatternsBeyond Design Principles and Patterns
Beyond Design Principles and PatternsMatthias Noback
 
Building Autonomous Services
Building Autonomous ServicesBuilding Autonomous Services
Building Autonomous ServicesMatthias Noback
 
Advanced Application Architecture Symfony Live Berlin 2018
Advanced Application Architecture Symfony Live Berlin 2018Advanced Application Architecture Symfony Live Berlin 2018
Advanced Application Architecture Symfony Live Berlin 2018Matthias Noback
 
Building autonomous services
Building autonomous servicesBuilding autonomous services
Building autonomous servicesMatthias Noback
 

Más de Matthias Noback (20)

Rector fireside chat - PHPMiNDS meetup
Rector fireside chat - PHPMiNDS meetupRector fireside chat - PHPMiNDS meetup
Rector fireside chat - PHPMiNDS meetup
 
Service abstractions - Part 1: Queries
Service abstractions - Part 1: QueriesService abstractions - Part 1: Queries
Service abstractions - Part 1: Queries
 
Hexagonal Symfony - SymfonyCon Amsterdam 2019
Hexagonal Symfony - SymfonyCon Amsterdam 2019Hexagonal Symfony - SymfonyCon Amsterdam 2019
Hexagonal Symfony - SymfonyCon Amsterdam 2019
 
Advanced web application architecture - PHP Barcelona
Advanced web application architecture  - PHP BarcelonaAdvanced web application architecture  - PHP Barcelona
Advanced web application architecture - PHP Barcelona
 
A testing strategy for hexagonal applications
A testing strategy for hexagonal applicationsA testing strategy for hexagonal applications
A testing strategy for hexagonal applications
 
Advanced web application architecture - Talk
Advanced web application architecture - TalkAdvanced web application architecture - Talk
Advanced web application architecture - Talk
 
DPC 2019, Amsterdam: Beyond design patterns and principles - writing good OO ...
DPC 2019, Amsterdam: Beyond design patterns and principles - writing good OO ...DPC 2019, Amsterdam: Beyond design patterns and principles - writing good OO ...
DPC 2019, Amsterdam: Beyond design patterns and principles - writing good OO ...
 
Layers, ports and adapters
Layers, ports and adaptersLayers, ports and adapters
Layers, ports and adapters
 
Beyond design principles and patterns (muCon 2019 edition)
Beyond design principles and patterns (muCon 2019 edition)Beyond design principles and patterns (muCon 2019 edition)
Beyond design principles and patterns (muCon 2019 edition)
 
Brutal refactoring, lying code, the Churn, and other emotional stories from L...
Brutal refactoring, lying code, the Churn, and other emotional stories from L...Brutal refactoring, lying code, the Churn, and other emotional stories from L...
Brutal refactoring, lying code, the Churn, and other emotional stories from L...
 
Advanced web application architecture Way2Web
Advanced web application architecture Way2WebAdvanced web application architecture Way2Web
Advanced web application architecture Way2Web
 
Brutal refactoring, lying code, the Churn, and other emotional stories from L...
Brutal refactoring, lying code, the Churn, and other emotional stories from L...Brutal refactoring, lying code, the Churn, and other emotional stories from L...
Brutal refactoring, lying code, the Churn, and other emotional stories from L...
 
Beyond Design Principles and Patterns
Beyond Design Principles and PatternsBeyond Design Principles and Patterns
Beyond Design Principles and Patterns
 
Building Autonomous Services
Building Autonomous ServicesBuilding Autonomous Services
Building Autonomous Services
 
Advanced Application Architecture Symfony Live Berlin 2018
Advanced Application Architecture Symfony Live Berlin 2018Advanced Application Architecture Symfony Live Berlin 2018
Advanced Application Architecture Symfony Live Berlin 2018
 
Designing for Autonomy
Designing for AutonomyDesigning for Autonomy
Designing for Autonomy
 
Docker workshop
Docker workshopDocker workshop
Docker workshop
 
Docker swarm workshop
Docker swarm workshopDocker swarm workshop
Docker swarm workshop
 
Docker compose workshop
Docker compose workshopDocker compose workshop
Docker compose workshop
 
Building autonomous services
Building autonomous servicesBuilding autonomous services
Building autonomous services
 

Último

Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 

Último (20)

Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 

Principles of PHP Package Design - Elcodi Community Day

  • 1. Principles of PHP Package Design Object oriented design for packages Matthias Noback - Noback's Office Elcodi Community Day - 10/25/2014
  • 2. Matthias Noback Noback's Office PHP developer, consultant Writer, speaker Proud father · · · 2/50
  • 4. A Year With Symfony leanpub.com/a-year-with-symfony 4/50
  • 5. Tight coupling Coupling to a framework 5/50
  • 9. Packages There are many different kinds 9/50
  • 11. Package design Nothing? butunclebob.com 11/50
  • 12. Principles of PHP Package Design leanpub.com/principles-of-php-package-design 12/50
  • 15. A - Cohesion principles Perspective: the package in isolation 15/50
  • 16. 1 - The Release Reuse Equivalence Principle The granule of reuse is the granule of release 16/50
  • 17. 1 - The Release Reuse Equivalence Principle Version control and hosting Composer package definition Meta-files Auto-loading · · · · Semantic versioning Quality control · Branches Tags Backward compatibility - - - · 17/50
  • 18. 1 - The Release Reuse Equivalence Principle If you don't have the time to turn your reusable code into a proper package... Don't release it. 18/50
  • 19. 2- The Common Reuse Principle Classes that are used together are packaged together If you use one class of a package, you will use all its other classes too. 19/50
  • 20. 2- The Common Reuse Principle Smell: Feature strata 20/50
  • 21. 2- The Common Reuse Principle Example of feature strata: the Symfony Security Component 21/50
  • 22. 2- The Common Reuse Principle Smell: Classes with different dependencies 22/50
  • 23. 2- The Common Reuse Principle Example of different dependencies: Gaufrette 23/50
  • 24. 2- The Common Reuse Principle Different dependencies: Gaufrette { "name": "knplabs/gaufrette", ... "suggest": { "knplabs/knp-gaufrette-bundle": "to use with Symfony2", "dropbox-php/dropbox-php": "to use the Dropbox adapter", "rackspace/php-opencloud" : "to use Opencloud adapter", "herzult/php-ssh": "to use SFtp adapter", "phpseclib/phpseclib": "to use PhpseclibSftp adapter", "aws/aws-sdk-php": "to use the Amazon S3 adapter", "amazonwebservices/aws-sdk-for-php": "to use the legacy Amazon S3 adapters", "doctrine/dbal": "to use the Doctrine DBAL adapter", "microsoft/windowsazure": "to use Microsoft Azure Blob Storage adapter", "ext-zip": "to use the Zip adapter", "ext-apc": "to use the APC adapter", ... }, ... } 24/50
  • 25. 2 - The Common Reuse Principle Leszek Prabucki's response 25/50
  • 26. 3 - The Common Closure Principle Classes that change together are packaged together 26/50
  • 27. 3 - The Common Closure Principle Reasons for change The application's features change The business rules change The web framework's best practices change The persistence library's configuration changes ... · · · · · 27/50
  • 28. 3 - The Common Closure Principle Smell: code for multiple application layers Web User Interface Command-line interface Model Infrastructure services · · · · 28/50
  • 29. B - Coupling principles Perspective: the package in relation to other packages 29/50
  • 30. 4 - The Acyclic Dependencies Principle The dependency graph of packages must have no cycles 30/50
  • 31. 4 - The Acyclic Dependencies Principle 31/50
  • 32. Stability Something is stable if it's resistant to change. 32/50
  • 33. 5 - The Stable Dependencies Principle An irresponsible package 33/50
  • 34. 5 - The Stable Dependencies Principle A dependent package 34/50
  • 35. 5 - The Stable Dependencies Principle An instable package: irresponsible and dependent 35/50
  • 36. 5 - The Stable Dependencies Principle A responsible package 36/50
  • 37. 5 - The Stable Dependencies Principle An independent package 37/50
  • 38. 5 - The Stable Dependencies Principle A stable package: responsible and independent 38/50
  • 39. 5 - The Stable Dependencies Principle Depend in the direction of stability 39/50
  • 40. 5 - The Stable Dependencies Principle Counter example 40/50
  • 41. 6 - The Stable Abstractions Principle What is more likely to change? Something concrete or something abstract? A class or an interface? · · 41/50
  • 42. 6 - The Stable Abstractions Principle Abstractness should increase with stability 42/50
  • 43. Summary Reuse/release equivalence principle Common reuse principle Common closure principle Acyclic dependencies principle Stable dependencies principle Stable abstractions principle · Reuse only code that you can release - as a product. · - All code in a package is reused at the same time. · - Code in a package only changes for a few reasons. · - No cycles in the dependency graph. · - Only depend on more stable packages. · - More stable packages are also more abstract. 43/50
  • 44. Word of advice You can't maximize them all at the same time. Keep them in mind while you are working on a package. 44/50
  • 45. Principles of PHP Package Design leanpub.com/principles-of-php-package-design I'm impressed. — Robert C. Martin 45/50
  • 46. Principles of PHP Package Design Get a 10 dollar discount: http://leanpub.com/principles-of-php-package-design/c/symfony-barcelona 46/50
  • 47. Questions? twitter @matthiasnoback leanpub leanpub.com/principles-of-php-package-design 47/50
  • 48. Image courtesy Clean Coders GitHub BitBucket Packagist PoEAA But Uncle Bob Robert Martin · · · · · · · 48/50
  • 49. 50/50