SlideShare a Scribd company logo
1 of 45
Download to read offline
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

More Related Content

Viewers also liked

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
 

Viewers also liked (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
 

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

React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialJoão Esperancinha
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...amber724300
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxAna-Maria Mihalceanu
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessWSO2
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Mark Simos
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 

Recently uploaded (20)

React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorial
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with Platformless
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 

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