SlideShare a Scribd company logo
1 of 33
Download to read offline
Principles of PHP Package Design
Object oriented design for packages
Matthias Noback - PHP developer and consultant
Dutch Symfony Meetup - 3/2/2014
Matthias Noback
Noback's Office
· PHP developer
· Consultancy, training, writing
· Clean code, TDD

2/33
A Year With Symfony

leanpub.com/a-year-with-symfony

3/33
Principles of PHP Package Design

leanpub.com/principles-of-php-package-design

4/33
Object oriented design

5/33
Class design
· Single Responsibility Principle
· Open Closed Principle
· Liskov Substitution Principle
· Interface Segregation Principle
· Dependency Inversion Principle

6/33
Package design
Cohesion

7/33
Package design
Coupling

8/33
Source: Robert Martin
Book: Agile Software Development, Principles, Patterns, and Practices
Articles: http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod

9/33
The Release Reuse Equivalency Principle
The granule of reuse is the granule of release

10/33
The Release Reuse Equivalency Principle
·
·
·
·

Version control and hosting
Composer package definition
Auto-loading
Semantic versioning
- Tags

- Backward compatibility
· Quality control

11/33
The Common Reuse Principle
Classes that are used together are packaged together
If you use a class inside a package, you will (most likely) use (all) other classes
inside it too.

12/33
The Common Reuse Principle
Violation: Feature strata

13/33
The Common Reuse Principle
Symfony Security Component
Has multiple parallel features that can be used separately:
· Authentication (HTTP)
· Authorization (ACL)
· Session (CSRF)
(Has been fixed now by the way)

14/33
The Common Reuse Principle
Violation: Classes with different dependencies

15/33
The Common Reuse Principle
Monolog
Many different logging handlers:
· Not (re-)used together
· Each with different dependencies

16/33
The Common Closure Principle
Classes that change together are packaged together

17/33
The Common Closure Principle
Classes that change together are packaged together
Which external changes would be able to force a change in the package?
· The web framework changes
· The persistence library changes
· The application's features change
· The business rules change
· ...

18/33
The Common Closure Principle
Violation: being highly sensitive for changes in a dependency
F S e t u d eand J S e i l z r
ORsBnl
MSraie

Discussion on GitHub
A s t cand its filters
sei

19/33
The Common Closure Principle
Violation: code for multiple application layers
FSsrude
OUeBnl:

· Model
· View
· Controller
· Services

20/33
The Common Closure Principle
We need packages that are closed against changes in:
· The framework
· The persistence layer

21/33
The Acyclic Dependencies Principle
The dependency graph of packages must have no cycles

22/33
The Acyclic Dependencies Principle
Composer
Composer can resolve cyclic dependencies
As a package maintainer you will be in trouble because of:
· Conflicting version requirements: inability to resolve versions
· Where do you start when you want to change the package?

23/33
The Stable Dependencies Principle
Instable package: irresponsible, dependent

24/33
The Stable Dependencies Principle
Stable package: responsible, independent

25/33
The Stable Dependencies Principle
Depend in the direction of stability
Packages with more dependencies depend on packages with less dependencies.
Those independent packages have to behave responsibly and not change all the
time.

26/33
The Stable Dependencies Principle
Depend in the direction of stability
"Stability" then equals "not easy to change" (versus volatility).
Hard to change packages should not depend on easy to change packages.

27/33
The Stable Abstractions Principle
Abstractness increases with stability
A package should be as abstract as it is stable.

28/33
The Stable Abstractions Principle
Abstractness increases with stability
A less stable package, should be also more concrete.
A more stable package, should also be more abstract.

29/33
The Stable Abstractions Principle
Abstractness increases with stability
The implementation details will change often
They belong in an unstable package.
The abstractions (interfaces mainly) will stay the same
They belong in a stable package.

30/33
The Stable Abstractions Principle
Violations: all over the place
Many packages offer both interfaces and implementations
It can be okay, but if you expect others to offer new implementations, you
should offer the interfaces separately.
E.g.:
· Assetic filters
· Monolog handlers

31/33
Summary
· Consider each package as a real product
· Put code in it that will all be reused at the same time
· Make sure it only needs to be changed for a small number of reasons
· Remove any cycles in the dependency graph
· Packages are only allowed to depend on more stable packages
· Stable packages are highly abstract, instable packages are highly concrete

32/33
Thank you
twitter
www
github
leanpub

@matthiasnoback
php-and-symfony.matthiasnoback.nl
github.com/matthiasnoback
leanpub.com/principles-of-php-package-design

More Related Content

Similar to Dutch Symfony Meetup - Principles of PHP Package Design

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
 
Inversion of Control
Inversion of ControlInversion of Control
Inversion of ControlShuhab Tariq
 
Software design principles
Software design principlesSoftware design principles
Software design principlesMd.Mojibul Hoque
 
Maksym Ked "Plug-In C++ Application Architecture"
Maksym Ked "Plug-In C++ Application Architecture"Maksym Ked "Plug-In C++ Application Architecture"
Maksym Ked "Plug-In C++ Application Architecture"LogeekNightUkraine
 
Refactoring_Rosenheim_2008_Workshop
Refactoring_Rosenheim_2008_WorkshopRefactoring_Rosenheim_2008_Workshop
Refactoring_Rosenheim_2008_WorkshopMax Kleiner
 
Feature-Oriented Software Evolution
Feature-Oriented Software EvolutionFeature-Oriented Software Evolution
Feature-Oriented Software EvolutionLeonardo Passos
 
Collaborative modeling with sirius
Collaborative modeling with siriusCollaborative modeling with sirius
Collaborative modeling with siriuspcdavid_
 
DesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsDesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsBasavaraj Patil
 
2016-04-22: Beyond SOLID: The Package Principles
2016-04-22: Beyond SOLID: The Package Principles2016-04-22: Beyond SOLID: The Package Principles
2016-04-22: Beyond SOLID: The Package PrinciplesChristian Hujer
 
Design Patterns
Design PatternsDesign Patterns
Design Patternsfrgo
 
SOLID principles-Present
SOLID principles-PresentSOLID principles-Present
SOLID principles-PresentQuang Nguyen
 
Clean Code .Net Cheetsheets
Clean Code .Net CheetsheetsClean Code .Net Cheetsheets
Clean Code .Net CheetsheetsNikitaGoncharuk1
 
Solid OO & Clean Coding is essential to successful Agile development
Solid OO & Clean Coding is essential to successful Agile developmentSolid OO & Clean Coding is essential to successful Agile development
Solid OO & Clean Coding is essential to successful Agile developmentSimon Gould
 
Concurrent Root Cut Loops to Exploit Random Performance Variability
Concurrent Root Cut Loops to Exploit Random Performance VariabilityConcurrent Root Cut Loops to Exploit Random Performance Variability
Concurrent Root Cut Loops to Exploit Random Performance VariabilityIBM Decision Optimization
 
Ratpack and Grails 3 (and Spring Boot) SpringOne 2GX 2014
Ratpack and Grails 3 (and Spring Boot) SpringOne 2GX 2014Ratpack and Grails 3 (and Spring Boot) SpringOne 2GX 2014
Ratpack and Grails 3 (and Spring Boot) SpringOne 2GX 2014Lari Hotari
 

Similar to Dutch Symfony Meetup - Principles of PHP Package Design (20)

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
 
Inversion of Control
Inversion of ControlInversion of Control
Inversion of Control
 
Software design principles
Software design principlesSoftware design principles
Software design principles
 
Maksym Ked "Plug-In C++ Application Architecture"
Maksym Ked "Plug-In C++ Application Architecture"Maksym Ked "Plug-In C++ Application Architecture"
Maksym Ked "Plug-In C++ Application Architecture"
 
Refactoring_Rosenheim_2008_Workshop
Refactoring_Rosenheim_2008_WorkshopRefactoring_Rosenheim_2008_Workshop
Refactoring_Rosenheim_2008_Workshop
 
Feature-Oriented Software Evolution
Feature-Oriented Software EvolutionFeature-Oriented Software Evolution
Feature-Oriented Software Evolution
 
Collaborative modeling with sirius
Collaborative modeling with siriusCollaborative modeling with sirius
Collaborative modeling with sirius
 
Ch06.ppt
Ch06.pptCh06.ppt
Ch06.ppt
 
DesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsDesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatterns
 
SPLC Presentation
SPLC PresentationSPLC Presentation
SPLC Presentation
 
2016-04-22: Beyond SOLID: The Package Principles
2016-04-22: Beyond SOLID: The Package Principles2016-04-22: Beyond SOLID: The Package Principles
2016-04-22: Beyond SOLID: The Package Principles
 
Soild principles
Soild principlesSoild principles
Soild principles
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
SOLID principles-Present
SOLID principles-PresentSOLID principles-Present
SOLID principles-Present
 
Clean Code .Net Cheetsheets
Clean Code .Net CheetsheetsClean Code .Net Cheetsheets
Clean Code .Net Cheetsheets
 
Solid OO & Clean Coding is essential to successful Agile development
Solid OO & Clean Coding is essential to successful Agile developmentSolid OO & Clean Coding is essential to successful Agile development
Solid OO & Clean Coding is essential to successful Agile development
 
Git basics
Git basicsGit basics
Git basics
 
Concurrent Root Cut Loops to Exploit Random Performance Variability
Concurrent Root Cut Loops to Exploit Random Performance VariabilityConcurrent Root Cut Loops to Exploit Random Performance Variability
Concurrent Root Cut Loops to Exploit Random Performance Variability
 
Ratpack and Grails 3 (and Spring Boot) SpringOne 2GX 2014
Ratpack and Grails 3 (and Spring Boot) SpringOne 2GX 2014Ratpack and Grails 3 (and Spring Boot) SpringOne 2GX 2014
Ratpack and Grails 3 (and Spring Boot) SpringOne 2GX 2014
 
Why Concurrency is hard ?
Why Concurrency is hard ?Why Concurrency is hard ?
Why Concurrency is hard ?
 

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

From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

Dutch Symfony Meetup - Principles of PHP Package Design

  • 1. Principles of PHP Package Design Object oriented design for packages Matthias Noback - PHP developer and consultant Dutch Symfony Meetup - 3/2/2014
  • 2. Matthias Noback Noback's Office · PHP developer · Consultancy, training, writing · Clean code, TDD 2/33
  • 3. A Year With Symfony leanpub.com/a-year-with-symfony 3/33
  • 4. Principles of PHP Package Design leanpub.com/principles-of-php-package-design 4/33
  • 6. Class design · Single Responsibility Principle · Open Closed Principle · Liskov Substitution Principle · Interface Segregation Principle · Dependency Inversion Principle 6/33
  • 9. Source: Robert Martin Book: Agile Software Development, Principles, Patterns, and Practices Articles: http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod 9/33
  • 10. The Release Reuse Equivalency Principle The granule of reuse is the granule of release 10/33
  • 11. The Release Reuse Equivalency Principle · · · · Version control and hosting Composer package definition Auto-loading Semantic versioning - Tags - Backward compatibility · Quality control 11/33
  • 12. The Common Reuse Principle Classes that are used together are packaged together If you use a class inside a package, you will (most likely) use (all) other classes inside it too. 12/33
  • 13. The Common Reuse Principle Violation: Feature strata 13/33
  • 14. The Common Reuse Principle Symfony Security Component Has multiple parallel features that can be used separately: · Authentication (HTTP) · Authorization (ACL) · Session (CSRF) (Has been fixed now by the way) 14/33
  • 15. The Common Reuse Principle Violation: Classes with different dependencies 15/33
  • 16. The Common Reuse Principle Monolog Many different logging handlers: · Not (re-)used together · Each with different dependencies 16/33
  • 17. The Common Closure Principle Classes that change together are packaged together 17/33
  • 18. The Common Closure Principle Classes that change together are packaged together Which external changes would be able to force a change in the package? · The web framework changes · The persistence library changes · The application's features change · The business rules change · ... 18/33
  • 19. The Common Closure Principle Violation: being highly sensitive for changes in a dependency F S e t u d eand J S e i l z r ORsBnl MSraie Discussion on GitHub A s t cand its filters sei 19/33
  • 20. The Common Closure Principle Violation: code for multiple application layers FSsrude OUeBnl: · Model · View · Controller · Services 20/33
  • 21. The Common Closure Principle We need packages that are closed against changes in: · The framework · The persistence layer 21/33
  • 22. The Acyclic Dependencies Principle The dependency graph of packages must have no cycles 22/33
  • 23. The Acyclic Dependencies Principle Composer Composer can resolve cyclic dependencies As a package maintainer you will be in trouble because of: · Conflicting version requirements: inability to resolve versions · Where do you start when you want to change the package? 23/33
  • 24. The Stable Dependencies Principle Instable package: irresponsible, dependent 24/33
  • 25. The Stable Dependencies Principle Stable package: responsible, independent 25/33
  • 26. The Stable Dependencies Principle Depend in the direction of stability Packages with more dependencies depend on packages with less dependencies. Those independent packages have to behave responsibly and not change all the time. 26/33
  • 27. The Stable Dependencies Principle Depend in the direction of stability "Stability" then equals "not easy to change" (versus volatility). Hard to change packages should not depend on easy to change packages. 27/33
  • 28. The Stable Abstractions Principle Abstractness increases with stability A package should be as abstract as it is stable. 28/33
  • 29. The Stable Abstractions Principle Abstractness increases with stability A less stable package, should be also more concrete. A more stable package, should also be more abstract. 29/33
  • 30. The Stable Abstractions Principle Abstractness increases with stability The implementation details will change often They belong in an unstable package. The abstractions (interfaces mainly) will stay the same They belong in a stable package. 30/33
  • 31. The Stable Abstractions Principle Violations: all over the place Many packages offer both interfaces and implementations It can be okay, but if you expect others to offer new implementations, you should offer the interfaces separately. E.g.: · Assetic filters · Monolog handlers 31/33
  • 32. Summary · Consider each package as a real product · Put code in it that will all be reused at the same time · Make sure it only needs to be changed for a small number of reasons · Remove any cycles in the dependency graph · Packages are only allowed to depend on more stable packages · Stable packages are highly abstract, instable packages are highly concrete 32/33