SlideShare a Scribd company logo
Principles of Package Design
How to create cohesive, stable packages
Matthias Noback
Writing
A Year With Symfony
leanpub.com/a-year-with-symfony
Tight coupling
What we do
Packages
many different kinds
Class design
Package design
Nothing?
butunclebob.com
Principles of Package Design
leanpub.com/principles-of-package-design
Package design
Cohesion
Package design
Coupling
A - Cohesion principles
Perspective: the package in isolation
!
1 - The Release Reuse Equivalence Principle
The granule of reuse is the granule of release
1 - The Release Reuse Equivalence Principle
• Version control and hosting
• Composer package definition
• Meta-files
• Auto-loading
!
• Semantic versioning
• Branches
• Tags
• Backward compatibility
• Quality control
1 - The Release Reuse Equivalence Principle
The Rule of Three
blog.codinghorror.com/rule-of-three/
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.
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.
2- The Common Reuse Principle
Smell: Feature strata
2- The Common Reuse Principle
Example of feature strata: the Symfony
Security Component
2- The Common Reuse Principle
Smell: Classes with different
dependencies
2- The Common Reuse Principle
Example of different dependencies:
Gaufrette
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 S
"doctrine/dbal": "to use the Doctrine DBAL adapter",
"microsoft/windowsazure": "to use Microsoft Azure Blob Storage a
"ext-zip": "to use the Zip adapter",
"ext-apc": "to use the APC adapter",
...
},
2 - The Common Reuse Principle
Leszek Prabucki's response
3 - The Common Closure Principle
Classes that change together are
packaged together
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
• ...
3 - The Common Closure Principle
Smell: code for multiple application layers
• Web User Interface
• Command-line interface
• Model
• Infrastructure services
B - Coupling principles
Perspective: the package in relation to other
packages
4 - The Acyclic Dependencies Principle
The dependency graph of packages must
have no cycles
4 - The Acyclic Dependencies Principle
Stability
Something is stable if it's resistant to change.
5 - The Stable Dependencies
Principle
An irresponsible package
5 - The Stable Dependencies Principle
A dependent package
5 - The Stable Dependencies Principle
An instable package: irresponsible and
dependent
5 - The Stable Dependencies Principle
A responsible package
5 - The Stable Dependencies Principle
An independent package
5 - The Stable Dependencies Principle
A stable package: responsible and
independent
5 - The Stable Dependencies Principle
Depend in the direction of stability
5 - The Stable Dependencies Principle
Counter example
6 - The Stable Abstractions Principle
What is more likely to change?
!
• Something concrete or something abstract?
• A class or an interface?
6 - The Stable Abstractions Principle
Abstractness should increase with stability
Summary
Reuse/release equivalence principle
Reuse only code that you can release as a product.
Common reuse principle
All code in a package is reused at the same time.
Common closure principle
Code in a package only changes for a few reasons.
Acyclic dependencies principle
No cycles in the dependency graph.
Stable dependencies principle
Only depend on more stable packages.
Stable abstractions principle
More stable packages are also more abstract.
Word of advice
You can't maximize them all at
the same time.
!
Keep them in mind while you are
working on a package.
Principles of Package Design
leanpub.com/principles-of-package-design/c/phpconpl
Questions?
@matthiasnoback
joind.in/16212
Thank you!
Images
• http://cleancoders.com/
• https://github.com/
• https://bitbucket.org/
• https://packagist.org/
• http://martinfowler.com/eaaCatalog/
• http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod
• http://blog.8thlight.com/uncle-bob/2014/05/14/
TheLittleMocker.html

More Related Content

Viewers also liked (6)

PDF
PACKAGE DESIGN (Intro to GD, wk 12)
Shawn Calvert
 
PPTX
Research Methodology for Design
Vikki du Preez
 
PPTX
Packaging design ppt
Ishita Sachdeva
 
PPT
Packaging Design Conference 12-09
Paul Vickers
 
PPTX
Packaging ppt
Shraddha Kurdekar
 
PDF
State of the Word 2011
photomatt
 
PACKAGE DESIGN (Intro to GD, wk 12)
Shawn Calvert
 
Research Methodology for Design
Vikki du Preez
 
Packaging design ppt
Ishita Sachdeva
 
Packaging Design Conference 12-09
Paul Vickers
 
Packaging ppt
Shraddha Kurdekar
 
State of the Word 2011
photomatt
 

Similar to Principles of Package Design (PHPCon Poland 2015) (20)

PDF
Principles of PHP Package Design - DomCode, first monthly meeting
Matthias Noback
 
PDF
Principles of PHP Package Design - Laracon Europe (Amsterdam) 2014
Matthias Noback
 
PDF
Dutch Symfony Meetup - Principles of PHP Package Design
Matthias Noback
 
PPTX
2016-04-22: Beyond SOLID: The Package Principles
Christian Hujer
 
PPTX
Code Structural Analysis
Dmitry Buzdin
 
PDF
SOLID design principles applied in Java
Bucharest Java User Group
 
PPTX
¿Qué tan s.o.l.i.d. es tú código
Luis Alexander Aldazabal Gil
 
PDF
SOLID Design Principles applied in Java
Ionut Bilica
 
PPTX
Is your code solid
Nathan Gloyn
 
PDF
Effectively Reuse the Code Between PHP Projects
Andrew Yatsenko
 
PDF
Software design principles - jinal desai
jinaldesailive
 
PPT
Best practices for agile design
Igor Moochnick
 
PDF
Microservices and the Art of Taming the Dependency Hell Monster
C4Media
 
PPTX
Soild principles
Avidnyat Chiddarwar
 
ODP
Path dependent-development (PyCon India)
ncoghlan_dev
 
PDF
Ratpack and Grails 3
Lari Hotari
 
PDF
Ratpack and Grails 3
GR8Conf
 
PPTX
Software design principles
Md.Mojibul Hoque
 
PDF
Clean code-v2.2
Bình Trọng Án
 
ODP
The Bespoke Software Product Factory (2007)
Peter Antman
 
Principles of PHP Package Design - DomCode, first monthly meeting
Matthias Noback
 
Principles of PHP Package Design - Laracon Europe (Amsterdam) 2014
Matthias Noback
 
Dutch Symfony Meetup - Principles of PHP Package Design
Matthias Noback
 
2016-04-22: Beyond SOLID: The Package Principles
Christian Hujer
 
Code Structural Analysis
Dmitry Buzdin
 
SOLID design principles applied in Java
Bucharest Java User Group
 
¿Qué tan s.o.l.i.d. es tú código
Luis Alexander Aldazabal Gil
 
SOLID Design Principles applied in Java
Ionut Bilica
 
Is your code solid
Nathan Gloyn
 
Effectively Reuse the Code Between PHP Projects
Andrew Yatsenko
 
Software design principles - jinal desai
jinaldesailive
 
Best practices for agile design
Igor Moochnick
 
Microservices and the Art of Taming the Dependency Hell Monster
C4Media
 
Soild principles
Avidnyat Chiddarwar
 
Path dependent-development (PyCon India)
ncoghlan_dev
 
Ratpack and Grails 3
Lari Hotari
 
Ratpack and Grails 3
GR8Conf
 
Software design principles
Md.Mojibul Hoque
 
Clean code-v2.2
Bình Trọng Án
 
The Bespoke Software Product Factory (2007)
Peter Antman
 
Ad

More from Matthias Noback (20)

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

Recently uploaded (20)

PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PDF
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
PDF
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
PDF
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
PPTX
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PDF
Add Background Images to Charts in IBM SPSS Statistics Version 31.pdf
Version 1 Analytics
 
PDF
ERP Consulting Services and Solutions by Contetra Pvt Ltd
jayjani123
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Everything you need to know about pricing & licensing Microsoft 365 Copilot f...
Q-Advise
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PPTX
Customise Your Correlation Table in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
Add Background Images to Charts in IBM SPSS Statistics Version 31.pdf
Version 1 Analytics
 
ERP Consulting Services and Solutions by Contetra Pvt Ltd
jayjani123
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Everything you need to know about pricing & licensing Microsoft 365 Copilot f...
Q-Advise
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Customise Your Correlation Table in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 

Principles of Package Design (PHPCon Poland 2015)

  • 1. Principles of Package Design How to create cohesive, stable packages Matthias Noback
  • 3. A Year With Symfony leanpub.com/a-year-with-symfony
  • 9. Principles of Package Design leanpub.com/principles-of-package-design
  • 12. A - Cohesion principles Perspective: the package in isolation
  • 13. ! 1 - The Release Reuse Equivalence Principle The granule of reuse is the granule of release
  • 14. 1 - The Release Reuse Equivalence Principle • Version control and hosting • Composer package definition • Meta-files • Auto-loading ! • Semantic versioning • Branches • Tags • Backward compatibility • Quality control
  • 15. 1 - The Release Reuse Equivalence Principle The Rule of Three blog.codinghorror.com/rule-of-three/
  • 16. 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.
  • 17. 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.
  • 18. 2- The Common Reuse Principle Smell: Feature strata
  • 19. 2- The Common Reuse Principle Example of feature strata: the Symfony Security Component
  • 20. 2- The Common Reuse Principle Smell: Classes with different dependencies
  • 21. 2- The Common Reuse Principle Example of different dependencies: Gaufrette
  • 22. 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 S "doctrine/dbal": "to use the Doctrine DBAL adapter", "microsoft/windowsazure": "to use Microsoft Azure Blob Storage a "ext-zip": "to use the Zip adapter", "ext-apc": "to use the APC adapter", ... },
  • 23. 2 - The Common Reuse Principle Leszek Prabucki's response
  • 24. 3 - The Common Closure Principle Classes that change together are packaged together
  • 25. 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 • ...
  • 26. 3 - The Common Closure Principle Smell: code for multiple application layers • Web User Interface • Command-line interface • Model • Infrastructure services
  • 27. B - Coupling principles Perspective: the package in relation to other packages
  • 28. 4 - The Acyclic Dependencies Principle The dependency graph of packages must have no cycles
  • 29. 4 - The Acyclic Dependencies Principle
  • 30. Stability Something is stable if it's resistant to change.
  • 31. 5 - The Stable Dependencies Principle An irresponsible package
  • 32. 5 - The Stable Dependencies Principle A dependent package
  • 33. 5 - The Stable Dependencies Principle An instable package: irresponsible and dependent
  • 34. 5 - The Stable Dependencies Principle A responsible package
  • 35. 5 - The Stable Dependencies Principle An independent package
  • 36. 5 - The Stable Dependencies Principle A stable package: responsible and independent
  • 37. 5 - The Stable Dependencies Principle Depend in the direction of stability
  • 38. 5 - The Stable Dependencies Principle Counter example
  • 39. 6 - The Stable Abstractions Principle What is more likely to change? ! • Something concrete or something abstract? • A class or an interface?
  • 40. 6 - The Stable Abstractions Principle Abstractness should increase with stability
  • 41. Summary Reuse/release equivalence principle Reuse only code that you can release as a product. Common reuse principle All code in a package is reused at the same time. Common closure principle Code in a package only changes for a few reasons. Acyclic dependencies principle No cycles in the dependency graph. Stable dependencies principle Only depend on more stable packages. Stable abstractions principle More stable packages are also more abstract.
  • 42. Word of advice You can't maximize them all at the same time. ! Keep them in mind while you are working on a package.
  • 43. Principles of Package Design leanpub.com/principles-of-package-design/c/phpconpl
  • 45. Images • http://cleancoders.com/ • https://github.com/ • https://bitbucket.org/ • https://packagist.org/ • http://martinfowler.com/eaaCatalog/ • http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod • http://blog.8thlight.com/uncle-bob/2014/05/14/ TheLittleMocker.html