SlideShare une entreprise Scribd logo
1  sur  45
Télécharger pour lire hors ligne
Principles of Package Design
Howtocreatecohesive,stablepackages
Matthias Noback - Noback's Office
FOSDEM - 1 Feb 2015
Writing
php-and-symfony.matthiasnoback.nl
2/46
A Year With Symfony
leanpub.com/a-year-with-symfony
3/46
Tight coupling
Coupling to a framework
4/46
Code
5/46
Packages
There are many different kinds
6/46
Class design
7/46
Package design
Nothing?
butunclebob.com
8/46
Principles of Package Design
leanpub.com/principles-of-package-design
9/46
Package design
Cohesion
10/46
Package design
Coupling
11/46
A - Cohesion principles
Perspective: the package in isolation
12/46
1 - The Release Reuse Equivalence Principle
The granule of reuse is the granule of release
13/46
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
-
-
-
·
14/46
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.
15/46
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.
16/46
2- The Common Reuse Principle
Smell: Feature strata
17/46
2- The Common Reuse Principle
Example of feature strata: the Symfony Security Component
18/46
2- The Common Reuse Principle
Smell: Classes with different dependencies
19/46
2- The Common Reuse Principle
Example of different dependencies: Gaufrette
20/46
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",
...
},
...
}
21/46
2 - The Common Reuse Principle
Leszek Prabucki's response
22/46
3 - The Common Closure Principle
Classes that change together are packaged together
23/46
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
...
·
·
·
·
·
24/46
3 - The Common Closure Principle
Smell: code for multiple application layers
Web User Interface
Command-line interface
Model
Infrastructure services
·
·
·
·
25/46
B - Coupling principles
Perspective: the package in relation to other packages
26/46
4 - The Acyclic Dependencies Principle
The dependency graph of packages must have no cycles
27/46
4 - The Acyclic Dependencies Principle
28/46
Stability
Something is stable if it's resistant to change.
29/46
5 - The Stable Dependencies Principle
An irresponsible package
30/46
5 - The Stable Dependencies Principle
A dependent package
31/46
5 - The Stable Dependencies Principle
An instable package: irresponsible and dependent
32/46
5 - The Stable Dependencies Principle
A responsible package
33/46
5 - The Stable Dependencies Principle
An independent package
34/46
5 - The Stable Dependencies Principle
A stable package: responsible and independent
35/46
5 - The Stable Dependencies Principle
Depend in the direction of stability
36/46
5 - The Stable Dependencies Principle
Counter example
37/46
6 - The Stable Abstractions Principle
What is more likely to change?
Something concrete or something abstract?
A class or an interface?
·
·
38/46
6 - The Stable Abstractions Principle
Abstractness should increase with stability
39/46
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.-
40/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.
41/46
Principles of Package Design
leanpub.com/principles-of-package-design
42/46
Questions?
twitter @matthiasnoback
feedback joind.in/13057
leanpub leanpub.com/principles-of-package-design
43/46
Image courtesy
Clean Coders
GitHub
BitBucket
Packagist
PoEAA
But Uncle Bob
Robert Martin
·
·
·
·
·
·
·
44/46
46/46

Contenu connexe

En vedette

Aseptic packaging
Aseptic packagingAseptic packaging
Aseptic packagingusman6789
 
Design Fundamentals for Developers
Design Fundamentals for DevelopersDesign Fundamentals for Developers
Design Fundamentals for Developerspaultrani
 
MODIFIED ATMOSPHERE AND INTELLIGENT PACKAGING OF FOOD
MODIFIED ATMOSPHERE AND INTELLIGENT PACKAGING OF FOODMODIFIED ATMOSPHERE AND INTELLIGENT PACKAGING OF FOOD
MODIFIED ATMOSPHERE AND INTELLIGENT PACKAGING OF FOODÜlger Ahmet
 
Aseptic packaging
Aseptic packagingAseptic packaging
Aseptic packagingmaggie_usm
 
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
 
Lean publishing "Principles of Package Design"
Lean publishing "Principles of Package Design"Lean publishing "Principles of Package Design"
Lean publishing "Principles of Package Design"Matthias Noback
 
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
 

En vedette (19)

Aseptic packaging
Aseptic packagingAseptic packaging
Aseptic packaging
 
Aseptic packaging
Aseptic packagingAseptic packaging
Aseptic packaging
 
Types of Folding Carton
Types of Folding CartonTypes of Folding Carton
Types of Folding Carton
 
MAP
MAPMAP
MAP
 
Design Fundamentals for Developers
Design Fundamentals for DevelopersDesign Fundamentals for Developers
Design Fundamentals for Developers
 
Map
MapMap
Map
 
Aseptic packaging
Aseptic packagingAseptic packaging
Aseptic packaging
 
MODIFIED ATMOSPHERE AND INTELLIGENT PACKAGING OF FOOD
MODIFIED ATMOSPHERE AND INTELLIGENT PACKAGING OF FOODMODIFIED ATMOSPHERE AND INTELLIGENT PACKAGING OF FOOD
MODIFIED ATMOSPHERE AND INTELLIGENT PACKAGING OF FOOD
 
Aseptic packaging
Aseptic packagingAseptic packaging
Aseptic packaging
 
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)
 
Lean publishing "Principles of Package Design"
Lean publishing "Principles of Package Design"Lean publishing "Principles of Package Design"
Lean publishing "Principles of Package Design"
 
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
 

Plus 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
 

Plus 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
 

Dernier

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
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
 
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
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
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
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Dernier (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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...
 
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
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
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...
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

Principles of Package Design FOSDEM 2015

  • 1. Principles of Package Design Howtocreatecohesive,stablepackages Matthias Noback - Noback's Office FOSDEM - 1 Feb 2015
  • 3. A Year With Symfony leanpub.com/a-year-with-symfony 3/46
  • 4. Tight coupling Coupling to a framework 4/46
  • 6. Packages There are many different kinds 6/46
  • 9. Principles of Package Design leanpub.com/principles-of-package-design 9/46
  • 12. A - Cohesion principles Perspective: the package in isolation 12/46
  • 13. 1 - The Release Reuse Equivalence Principle The granule of reuse is the granule of release 13/46
  • 14. 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 - - - · 14/46
  • 15. 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. 15/46
  • 16. 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. 16/46
  • 17. 2- The Common Reuse Principle Smell: Feature strata 17/46
  • 18. 2- The Common Reuse Principle Example of feature strata: the Symfony Security Component 18/46
  • 19. 2- The Common Reuse Principle Smell: Classes with different dependencies 19/46
  • 20. 2- The Common Reuse Principle Example of different dependencies: Gaufrette 20/46
  • 21. 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", ... }, ... } 21/46
  • 22. 2 - The Common Reuse Principle Leszek Prabucki's response 22/46
  • 23. 3 - The Common Closure Principle Classes that change together are packaged together 23/46
  • 24. 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 ... · · · · · 24/46
  • 25. 3 - The Common Closure Principle Smell: code for multiple application layers Web User Interface Command-line interface Model Infrastructure services · · · · 25/46
  • 26. B - Coupling principles Perspective: the package in relation to other packages 26/46
  • 27. 4 - The Acyclic Dependencies Principle The dependency graph of packages must have no cycles 27/46
  • 28. 4 - The Acyclic Dependencies Principle 28/46
  • 29. Stability Something is stable if it's resistant to change. 29/46
  • 30. 5 - The Stable Dependencies Principle An irresponsible package 30/46
  • 31. 5 - The Stable Dependencies Principle A dependent package 31/46
  • 32. 5 - The Stable Dependencies Principle An instable package: irresponsible and dependent 32/46
  • 33. 5 - The Stable Dependencies Principle A responsible package 33/46
  • 34. 5 - The Stable Dependencies Principle An independent package 34/46
  • 35. 5 - The Stable Dependencies Principle A stable package: responsible and independent 35/46
  • 36. 5 - The Stable Dependencies Principle Depend in the direction of stability 36/46
  • 37. 5 - The Stable Dependencies Principle Counter example 37/46
  • 38. 6 - The Stable Abstractions Principle What is more likely to change? Something concrete or something abstract? A class or an interface? · · 38/46
  • 39. 6 - The Stable Abstractions Principle Abstractness should increase with stability 39/46
  • 40. 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.- 40/46
  • 41. Word of advice You can't maximize them all at the same time. Keep them in mind while you are working on a package. 41/46
  • 42. Principles of Package Design leanpub.com/principles-of-package-design 42/46
  • 43. Questions? twitter @matthiasnoback feedback joind.in/13057 leanpub leanpub.com/principles-of-package-design 43/46
  • 44. Image courtesy Clean Coders GitHub BitBucket Packagist PoEAA But Uncle Bob Robert Martin · · · · · · · 44/46
  • 45. 46/46