SlideShare a Scribd company logo
1 of 51
Download to read offline
Principles of PHP Package Design
Objectoriented design for packages
Matthias Noback - Noback's Office
DomCode, first monthly meeting - 7/28/2014
First monthly meeting of DomCode
2/52
Also: congratulations to SweetlakePHP
3/52
Matthias Noback
Noback's Office
PHP developer
Writer/speaker
Proud father
·
·
·
4/52
Blog
php-and-symfony.matthiasnoback.nl
5/52
A Year With Symfony
leanpub.com/a-year-with-symfony
6/52
Tight coupling
Coupling to a framework
7/52
Code
8/52
Squiggly lines
9/52
Code
10/52
Packages
There are many different kinds
11/52
Class design
12/52
Package design
Nothing?
butunclebob.com
13/52
Principles of PHP Package Design
leanpub.com/principles-of-php-package-design
14/52
Package design
Cohesion
15/52
Package design
Coupling
16/52
A - Cohesion principles
Perspective: the package in isolation
17/52
1 - The Release Reuse Equivalence Principle
The granule of reuse is the granule of release
18/52
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
-
-
-
·
19/52
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.
20/52
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.
21/52
2- The Common Reuse Principle
Smell: Feature strata
22/52
2- The Common Reuse Principle
Example of feature strata: the Symfony Security Component
23/52
2- The Common Reuse Principle
Smell: Classes with different dependencies
24/52
2- The Common Reuse Principle
Example of different dependencies: Gaufrette
25/52
2- The Common Reuse Principle
Different dependencies: Gaufrette
{
"name":"knplabs/gaufrette",
...
"suggest":{
"knplabs/knp-gaufrette-bundle":"tousewithSymfony2",
"dropbox-php/dropbox-php":"tousetheDropboxadapter",
"rackspace/php-opencloud":"touseOpencloudadapter",
"herzult/php-ssh":"touseSFtpadapter",
"phpseclib/phpseclib":"tousePhpseclibSftpadapter",
"aws/aws-sdk-php":"tousetheAmazonS3adapter",
"amazonwebservices/aws-sdk-for-php":"tousethelegacyAmazonS3adapters",
"doctrine/dbal":"tousetheDoctrineDBALadapter",
"microsoft/windowsazure":"touseMicrosoftAzureBlobStorageadapter",
"ext-zip":"tousetheZipadapter",
"ext-apc":"tousetheAPCadapter",
...
},
...
} 26/52
2 - The Common Reuse Principle
Leszek Prabucki's response
27/52
3 - The Common Closure Principle
Classes that change together are packaged together
28/52
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
...
·
·
·
·
·
29/52
3 - The Common Closure Principle
Smell: code for multiple application layers
Web User Interface
Command-line interface
Model
Infrastructure services
·
·
·
·
30/52
B - Coupling principles
Perspective: the package in relation to other packages
31/52
4 - The Acyclic Dependencies Principle
The dependency graph of packages must have no cycles
32/52
4 - The Acyclic Dependencies Principle
33/52
Stability
Something is stable if it's resistant to change.
34/52
5 - The Stable Dependencies Principle
An irresponsible package
35/52
5 - The Stable Dependencies Principle
A dependent package
36/52
5 - The Stable Dependencies Principle
An instable package: irresponsible and dependent
37/52
5 - The Stable Dependencies Principle
A responsible package
38/52
5 - The Stable Dependencies Principle
An independent package
39/52
5 - The Stable Dependencies Principle
A stable package: responsible and independent
40/52
5 - The Stable Dependencies Principle
Depend in the direction of stability
41/52
5 - The Stable Dependencies Principle
Counter example
42/52
6 - The Stable Abstractions Principle
What is more likely to change?
Something concrete or something abstract?
A class or an interface?
·
·
43/52
6 - The Stable Abstractions Principle
Abstractness should increase with stability
44/52
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.-
45/52
Word of advice
You can't maximize them all at the same time.
Keep them in mind while you are working on a package.
46/52
Principles of PHP Package Design
leanpub.com/principles-of-php-package-design
I'm impressed. — Robert C. Martin
47/52
Principles of PHP Package Design
Get a 10 dollar discount:
http://leanpub.com/principles-of-php-package-design/c/domcode
48/52
Questions?
feedback joind.in/11580
twitter @matthiasnoback
leanpub leanpub.com/principles-of-php-package-design
49/52
Image courtesy
Clean Coders
GitHub
BitBucket
Packagist
PoEAA
But Uncle Bob
Robert Martin
·
·
·
·
·
·
·
50/52
52/52

More Related Content

Viewers also liked

Principles of Package Design FOSDEM 2015
Principles of Package Design FOSDEM 2015Principles of Package Design FOSDEM 2015
Principles of Package Design FOSDEM 2015Matthias Noback
 
Design Fundamentals for Developers
Design Fundamentals for DevelopersDesign Fundamentals for Developers
Design Fundamentals for Developerspaultrani
 
PACKAGE DESIGN (Intro to GD, wk 12)
PACKAGE DESIGN (Intro to GD, wk 12)PACKAGE DESIGN (Intro to GD, wk 12)
PACKAGE DESIGN (Intro to GD, wk 12)Shawn Calvert
 
Modified Atmosphere Packaging
Modified Atmosphere PackagingModified Atmosphere Packaging
Modified Atmosphere PackagingCynthia 郑永丽
 
Food Packaging (Food Processing Technology)
Food Packaging (Food Processing Technology)Food Packaging (Food Processing Technology)
Food Packaging (Food Processing Technology)Supta Sarkar
 
Blister & strip packaging
Blister & strip packaging Blister & strip packaging
Blister & strip packaging Anil Pethe
 
Fruit Juice Factory. How to Manufacture Fruit Juice
Fruit Juice Factory. How to Manufacture Fruit JuiceFruit Juice Factory. How to Manufacture Fruit Juice
Fruit Juice Factory. How to Manufacture Fruit JuiceAjjay Kumar Gupta
 

Viewers also liked (15)

Types of Folding Carton
Types of Folding CartonTypes of Folding Carton
Types of Folding Carton
 
Aseptic packaging
Aseptic packagingAseptic packaging
Aseptic packaging
 
Principles of Package Design FOSDEM 2015
Principles of Package Design FOSDEM 2015Principles of Package Design FOSDEM 2015
Principles of Package Design FOSDEM 2015
 
Design Fundamentals for Developers
Design Fundamentals for DevelopersDesign Fundamentals for Developers
Design Fundamentals for Developers
 
Aseptic packaging
Aseptic packagingAseptic packaging
Aseptic packaging
 
Map
MapMap
Map
 
PACKAGE DESIGN (Intro to GD, wk 12)
PACKAGE DESIGN (Intro to GD, wk 12)PACKAGE DESIGN (Intro to GD, wk 12)
PACKAGE DESIGN (Intro to GD, wk 12)
 
Aseptic packaging
Aseptic packagingAseptic packaging
Aseptic packaging
 
Modified Atmosphere Packaging
Modified Atmosphere PackagingModified Atmosphere Packaging
Modified Atmosphere Packaging
 
Closures ppt
Closures pptClosures ppt
Closures ppt
 
Can manufacturing
Can manufacturingCan manufacturing
Can manufacturing
 
Food Packaging (Food Processing Technology)
Food Packaging (Food Processing Technology)Food Packaging (Food Processing Technology)
Food Packaging (Food Processing Technology)
 
Canning ppt.
Canning ppt.Canning ppt.
Canning ppt.
 
Blister & strip packaging
Blister & strip packaging Blister & strip packaging
Blister & strip packaging
 
Fruit Juice Factory. How to Manufacture Fruit Juice
Fruit Juice Factory. How to Manufacture Fruit JuiceFruit Juice Factory. How to Manufacture Fruit Juice
Fruit Juice Factory. How to Manufacture Fruit Juice
 

Similar to Principles of PHP Package Design - DomCode, first monthly meeting

Principles of PHP Package Design - Dutch PHP Conference 2014
Principles of PHP Package Design - Dutch PHP Conference 2014Principles of PHP Package Design - Dutch PHP Conference 2014
Principles of PHP Package Design - Dutch PHP Conference 2014Matthias Noback
 
Principles of PHP Package Design - Laracon Europe (Amsterdam) 2014
Principles of PHP Package Design - Laracon Europe (Amsterdam) 2014Principles of PHP Package Design - Laracon Europe (Amsterdam) 2014
Principles of PHP Package Design - Laracon Europe (Amsterdam) 2014Matthias Noback
 
Principles of PHP Package Design - Elcodi Community Day
Principles of PHP Package Design - Elcodi Community DayPrinciples of PHP Package Design - Elcodi Community Day
Principles of PHP Package Design - Elcodi Community DayMatthias Noback
 
Dutch Symfony Meetup - Principles of PHP Package Design
Dutch Symfony Meetup - Principles of PHP Package DesignDutch Symfony Meetup - Principles of PHP Package Design
Dutch Symfony Meetup - Principles of PHP Package DesignMatthias Noback
 
Principles of PHP Package Design (for AmsterdamPHP)
Principles of PHP Package Design (for AmsterdamPHP)Principles of PHP Package Design (for AmsterdamPHP)
Principles of PHP Package Design (for AmsterdamPHP)Matthias Noback
 
Principles of Package Design (PHPCon Poland 2015)
Principles of Package Design (PHPCon Poland 2015)Principles of Package Design (PHPCon Poland 2015)
Principles of Package Design (PHPCon Poland 2015)Matthias Noback
 

Similar to Principles of PHP Package Design - DomCode, first monthly meeting (6)

Principles of PHP Package Design - Dutch PHP Conference 2014
Principles of PHP Package Design - Dutch PHP Conference 2014Principles of PHP Package Design - Dutch PHP Conference 2014
Principles of PHP Package Design - Dutch PHP Conference 2014
 
Principles of PHP Package Design - Laracon Europe (Amsterdam) 2014
Principles of PHP Package Design - Laracon Europe (Amsterdam) 2014Principles of PHP Package Design - Laracon Europe (Amsterdam) 2014
Principles of PHP Package Design - Laracon Europe (Amsterdam) 2014
 
Principles of PHP Package Design - Elcodi Community Day
Principles of PHP Package Design - Elcodi Community DayPrinciples of PHP Package Design - Elcodi Community Day
Principles of PHP Package Design - Elcodi Community Day
 
Dutch Symfony Meetup - Principles of PHP Package Design
Dutch Symfony Meetup - Principles of PHP Package DesignDutch Symfony Meetup - Principles of PHP Package Design
Dutch Symfony Meetup - Principles of PHP Package Design
 
Principles of PHP Package Design (for AmsterdamPHP)
Principles of PHP Package Design (for AmsterdamPHP)Principles of PHP Package Design (for AmsterdamPHP)
Principles of PHP Package Design (for AmsterdamPHP)
 
Principles of Package Design (PHPCon Poland 2015)
Principles of Package Design (PHPCon Poland 2015)Principles of Package Design (PHPCon Poland 2015)
Principles of Package Design (PHPCon Poland 2015)
 

More from 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
 

More from 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
 

Recently uploaded

Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfRTS corp
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...OnePlan Solutions
 
Advantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxAdvantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxRTS corp
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfkalichargn70th171
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jNeo4j
 
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...kalichargn70th171
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdfSteve Caron
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxUnderstanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxSasikiranMarri
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 

Recently uploaded (20)

Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
 
Advantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxAdvantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptx
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
 
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxUnderstanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 

Principles of PHP Package Design - DomCode, first monthly meeting

  • 1. Principles of PHP Package Design Objectoriented design for packages Matthias Noback - Noback's Office DomCode, first monthly meeting - 7/28/2014
  • 2. First monthly meeting of DomCode 2/52
  • 3. Also: congratulations to SweetlakePHP 3/52
  • 4. Matthias Noback Noback's Office PHP developer Writer/speaker Proud father · · · 4/52
  • 6. A Year With Symfony leanpub.com/a-year-with-symfony 6/52
  • 7. Tight coupling Coupling to a framework 7/52
  • 11. Packages There are many different kinds 11/52
  • 14. Principles of PHP Package Design leanpub.com/principles-of-php-package-design 14/52
  • 17. A - Cohesion principles Perspective: the package in isolation 17/52
  • 18. 1 - The Release Reuse Equivalence Principle The granule of reuse is the granule of release 18/52
  • 19. 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 - - - · 19/52
  • 20. 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. 20/52
  • 21. 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. 21/52
  • 22. 2- The Common Reuse Principle Smell: Feature strata 22/52
  • 23. 2- The Common Reuse Principle Example of feature strata: the Symfony Security Component 23/52
  • 24. 2- The Common Reuse Principle Smell: Classes with different dependencies 24/52
  • 25. 2- The Common Reuse Principle Example of different dependencies: Gaufrette 25/52
  • 26. 2- The Common Reuse Principle Different dependencies: Gaufrette { "name":"knplabs/gaufrette", ... "suggest":{ "knplabs/knp-gaufrette-bundle":"tousewithSymfony2", "dropbox-php/dropbox-php":"tousetheDropboxadapter", "rackspace/php-opencloud":"touseOpencloudadapter", "herzult/php-ssh":"touseSFtpadapter", "phpseclib/phpseclib":"tousePhpseclibSftpadapter", "aws/aws-sdk-php":"tousetheAmazonS3adapter", "amazonwebservices/aws-sdk-for-php":"tousethelegacyAmazonS3adapters", "doctrine/dbal":"tousetheDoctrineDBALadapter", "microsoft/windowsazure":"touseMicrosoftAzureBlobStorageadapter", "ext-zip":"tousetheZipadapter", "ext-apc":"tousetheAPCadapter", ... }, ... } 26/52
  • 27. 2 - The Common Reuse Principle Leszek Prabucki's response 27/52
  • 28. 3 - The Common Closure Principle Classes that change together are packaged together 28/52
  • 29. 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 ... · · · · · 29/52
  • 30. 3 - The Common Closure Principle Smell: code for multiple application layers Web User Interface Command-line interface Model Infrastructure services · · · · 30/52
  • 31. B - Coupling principles Perspective: the package in relation to other packages 31/52
  • 32. 4 - The Acyclic Dependencies Principle The dependency graph of packages must have no cycles 32/52
  • 33. 4 - The Acyclic Dependencies Principle 33/52
  • 34. Stability Something is stable if it's resistant to change. 34/52
  • 35. 5 - The Stable Dependencies Principle An irresponsible package 35/52
  • 36. 5 - The Stable Dependencies Principle A dependent package 36/52
  • 37. 5 - The Stable Dependencies Principle An instable package: irresponsible and dependent 37/52
  • 38. 5 - The Stable Dependencies Principle A responsible package 38/52
  • 39. 5 - The Stable Dependencies Principle An independent package 39/52
  • 40. 5 - The Stable Dependencies Principle A stable package: responsible and independent 40/52
  • 41. 5 - The Stable Dependencies Principle Depend in the direction of stability 41/52
  • 42. 5 - The Stable Dependencies Principle Counter example 42/52
  • 43. 6 - The Stable Abstractions Principle What is more likely to change? Something concrete or something abstract? A class or an interface? · · 43/52
  • 44. 6 - The Stable Abstractions Principle Abstractness should increase with stability 44/52
  • 45. 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.- 45/52
  • 46. Word of advice You can't maximize them all at the same time. Keep them in mind while you are working on a package. 46/52
  • 47. Principles of PHP Package Design leanpub.com/principles-of-php-package-design I'm impressed. — Robert C. Martin 47/52
  • 48. Principles of PHP Package Design Get a 10 dollar discount: http://leanpub.com/principles-of-php-package-design/c/domcode 48/52
  • 49. Questions? feedback joind.in/11580 twitter @matthiasnoback leanpub leanpub.com/principles-of-php-package-design 49/52
  • 50. Image courtesy Clean Coders GitHub BitBucket Packagist PoEAA But Uncle Bob Robert Martin · · · · · · · 50/52
  • 51. 52/52