SlideShare una empresa de Scribd logo
1 de 52
Descargar para leer sin conexión
Conscious Decoupling
Building Software that Lasts
Ciaran McNulty at Lone Star PHP 2016
Me
Hi, I'm Ciaran and I'm a PHP developer
I am a consultant with Inviqa
I maintain PhpSpec and contribute to Behat
My early period: Write procedural
code!
My middle period: Decouple all the
things!
My late period: Decouple some of the
things!
What is coupling?
class TaxiDispatcher {
function dispatch (Car $car, $destination)
{
$this->chargeCustomer();
$car->goTo($destination);
}
}
Problems with dependencies
4 Changes to Car mean changes to Dispatcher
4 Can't reuse Dispatcher with new vehicles
interface Vehicle
{
public function goTo($destination);
}
class TaxiDispatcher {
function dispatch (Vehicle $vehicle, $destination)
{
$this->chargeCustomer();
$vehicle->goTo($destination);
}
}
Benefits of abstraction
4 Now we only need to rewrite Dispatcher and Car
when Vehicle changes
4 Vehicle can be very stable; it's just an interface
4 Can make new transportation types that implement
Vehicle
Defining abstractions
4 Start with the abstraction, not the detail
4 Contract should be a simple as possible
4 Contract should focus on resposibilities
4 Hide details of underlying APIs
Example - upgrade eligibility
Bad abstraction:
interface HttpClient
{
public function getData : array ($url, $parameters);
}
Example - upgrade eligibility
Better abstraction:
interface UpgradeEligibilityChecker
{
public function getContractId : int ($phoneNumber);
public function isEligibleForUpgrade : bool ($contractId);
}
Example - upgrade eligibility
Best abstraction:
interface UpgradeEligibilityChecker
{
public function isEligibleForUpgrade : bool ($phoneNumber);
}
Or, get on the bus
4 Migrate actions from method calls to objects
4 Depend on a bus rather than depending on contracts
4 Don't know anything about what handles the action
Events
Direct coupling:
$notifier->notifyLawyersAboutPurchase($id, $item, $cost);
Event style:
$eventBus->dispatch(
new ItemWasPurchased($id, $item, $cost);
);
Commands
Use case / service style:
$invoiceApprover->approveInvoice(1234);
Command style:
$commandBus->dispatch(
new ApproveInvoice(1234);
);
Advantages of decoupling via
abstractions
4 Cleaner APIs
4 Swappable components
4 Separation of concerns
4 Easier to test
4 No 'ripple effect' around changes
Disadvantages of decoupling via
abstractions
4 Makes execution flow harder to follow
4 Adds more complexity (more files in codebase)
4 Cognitive cost of thinking of good abstractions
Architectural boundaries
4 Abstractions are going to change when the use cases
change
4 Interfaces are more tightly coupled to code that
uses them
4 Interfaces 'belong' in the same architectural
boundary as the code that uses them.
Frameworks
Coupling to other people's code
Highly coupled frameworks
Some frameworks let you go really quickly by coupling
directly to them.
You probably won't be able to reuse your code without
considerable effort.
4 Drupal
4 Magento
4 Wordpress
More coupled framworks
Some frameworks let you go faster when you adopt their
conventions.
You can reuse your code with a fair amount of additional
effort.
4 Laravel
4 Symfony1
4 CakePHP
More decoupled frameworks
Some frameworks encourage decoupling so your code is
more reusable.
You will go a little slower because you need to explicitly
configure things
4 Symfony 2
4 Zend Framework 2
Very decoupled frameworks
Some frameworks are extremely decoupled so code is
almost entirely reusable.
You almost have to construct the entire framework
yourself from components - this can be hard!
4 D.I.Y.
4 Zend Expressive
Only decouple where you
need to
(wait, how do we know where that is?)
Coupled code get painful
when change happens
Decoupled code was
wasted effort when change
doesn't happen
Where does change come
from?
Where does change come from?
People!
Decouple your system to
respond to different
streams of change
Organizations which design
systems ... are constrained to
produce designs which are copies
of the communication structures
of these organizations
1
Melvin Conway, 1967
Context mapping
4 Identify subdomains
4 Identify which are:
4 Core subdomains
4 Supporting subdomains
4 Generic subdomains
4 Mirror the structure in your architecture
The bad news:
You will get it wrong
You only find out afterwards
The good news:
It's not just you
Things to check out
4 Context Mapping
4 Hexagonal Architecture
4 Modelling by Example
Thank you!
4 @ciaranmcnulty
4 Lead Maintainer of PhpSpec
4 SeniorTrainer at Inviqa
4 https://joind.in/talk/e20e3
Questions?

Más contenido relacionado

La actualidad más candente

10 Groovy Little JavaScript Tips
10 Groovy Little JavaScript Tips10 Groovy Little JavaScript Tips
10 Groovy Little JavaScript TipsTroy Miles
 
BDD style Unit Testing
BDD style Unit TestingBDD style Unit Testing
BDD style Unit TestingWen-Tien Chang
 
Web development basics (Part-4)
Web development basics (Part-4)Web development basics (Part-4)
Web development basics (Part-4)Rajat Pratap Singh
 
Web development basics (Part-6)
Web development basics (Part-6)Web development basics (Part-6)
Web development basics (Part-6)Rajat Pratap Singh
 
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)James Titcumb
 
How Symfony Changed My Life
How Symfony Changed My LifeHow Symfony Changed My Life
How Symfony Changed My LifeMatthias Noback
 
Fundamental JavaScript [In Control 2009]
Fundamental JavaScript [In Control 2009]Fundamental JavaScript [In Control 2009]
Fundamental JavaScript [In Control 2009]Aaron Gustafson
 
Kicking off with Zend Expressive and Doctrine ORM (PHP South Africa 2018)
Kicking off with Zend Expressive and Doctrine ORM (PHP South Africa 2018)Kicking off with Zend Expressive and Doctrine ORM (PHP South Africa 2018)
Kicking off with Zend Expressive and Doctrine ORM (PHP South Africa 2018)James Titcumb
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An IntroductionManvendra Singh
 
JavaScript Essentials for Ember development
JavaScript Essentials for Ember developmentJavaScript Essentials for Ember development
JavaScript Essentials for Ember developmentLeo Hernandez
 
Server Scripting Language -PHP
Server Scripting Language -PHPServer Scripting Language -PHP
Server Scripting Language -PHPDeo Shao
 
php app development 1
php app development 1php app development 1
php app development 1barryavery
 
Web development basics (Part-5)
Web development basics (Part-5)Web development basics (Part-5)
Web development basics (Part-5)Rajat Pratap Singh
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy CodeRowan Merewood
 

La actualidad más candente (18)

10 Groovy Little JavaScript Tips
10 Groovy Little JavaScript Tips10 Groovy Little JavaScript Tips
10 Groovy Little JavaScript Tips
 
BDD style Unit Testing
BDD style Unit TestingBDD style Unit Testing
BDD style Unit Testing
 
Web development basics (Part-4)
Web development basics (Part-4)Web development basics (Part-4)
Web development basics (Part-4)
 
Prersentation
PrersentationPrersentation
Prersentation
 
vb script
vb scriptvb script
vb script
 
Web development basics (Part-6)
Web development basics (Part-6)Web development basics (Part-6)
Web development basics (Part-6)
 
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
 
Modern Perl
Modern PerlModern Perl
Modern Perl
 
How Symfony Changed My Life
How Symfony Changed My LifeHow Symfony Changed My Life
How Symfony Changed My Life
 
Fundamental JavaScript [In Control 2009]
Fundamental JavaScript [In Control 2009]Fundamental JavaScript [In Control 2009]
Fundamental JavaScript [In Control 2009]
 
Kicking off with Zend Expressive and Doctrine ORM (PHP South Africa 2018)
Kicking off with Zend Expressive and Doctrine ORM (PHP South Africa 2018)Kicking off with Zend Expressive and Doctrine ORM (PHP South Africa 2018)
Kicking off with Zend Expressive and Doctrine ORM (PHP South Africa 2018)
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An Introduction
 
JavaScript Essentials for Ember development
JavaScript Essentials for Ember developmentJavaScript Essentials for Ember development
JavaScript Essentials for Ember development
 
Server Scripting Language -PHP
Server Scripting Language -PHPServer Scripting Language -PHP
Server Scripting Language -PHP
 
Overview of CoffeeScript
Overview of CoffeeScriptOverview of CoffeeScript
Overview of CoffeeScript
 
php app development 1
php app development 1php app development 1
php app development 1
 
Web development basics (Part-5)
Web development basics (Part-5)Web development basics (Part-5)
Web development basics (Part-5)
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 

Destacado

Administracion
AdministracionAdministracion
AdministracionSusygeo
 
Public health certificate
Public health certificatePublic health certificate
Public health certificateMonica McDaniel
 
Buscar imágenes en la web
Buscar imágenes en la web Buscar imágenes en la web
Buscar imágenes en la web TICS & Partners
 
How Can I Convert PIO Card into OCI Card?
How Can I Convert PIO Card into OCI Card?How Can I Convert PIO Card into OCI Card?
How Can I Convert PIO Card into OCI Card?Services 2 NRI
 
Diseño de una guía didáctica con imágenes
Diseño de una guía didáctica con imágenesDiseño de una guía didáctica con imágenes
Diseño de una guía didáctica con imágenesTICS & Partners
 
Վեբ 2.0՝ ի՞նչ է դա
Վեբ 2.0՝ ի՞նչ է դաՎեբ 2.0՝ ի՞նչ է դա
Վեբ 2.0՝ ի՞նչ է դաArtur Papyan
 
First aid certificate 2016
First aid certificate 2016First aid certificate 2016
First aid certificate 2016Ian Simpson
 
Social Media for the Federation of Small Businesses
Social Media for the Federation of Small BusinessesSocial Media for the Federation of Small Businesses
Social Media for the Federation of Small BusinessesThis Little Piggy
 
PHP Conference 2016
PHP Conference 2016PHP Conference 2016
PHP Conference 2016Edison Costa
 
Tutorial: cómo cargar un video a Edmodo desde Youtube
Tutorial: cómo cargar un video a Edmodo desde YoutubeTutorial: cómo cargar un video a Edmodo desde Youtube
Tutorial: cómo cargar un video a Edmodo desde YoutubeTICS & Partners
 
Recommendation for Maya Emilova
Recommendation for Maya EmilovaRecommendation for Maya Emilova
Recommendation for Maya EmilovaMMEEVV
 
Canada Mortgage and Housing Corporation's (CMHC) Municipal Infrastructure Len...
Canada Mortgage and Housing Corporation's (CMHC) Municipal Infrastructure Len...Canada Mortgage and Housing Corporation's (CMHC) Municipal Infrastructure Len...
Canada Mortgage and Housing Corporation's (CMHC) Municipal Infrastructure Len...MaRS Discovery District
 
Driving Design through Examples
Driving Design through ExamplesDriving Design through Examples
Driving Design through ExamplesCiaranMcNulty
 
The quest for global design principles (SymfonyLive Berlin 2015)
The quest for global design principles (SymfonyLive Berlin 2015)The quest for global design principles (SymfonyLive Berlin 2015)
The quest for global design principles (SymfonyLive Berlin 2015)Matthias Noback
 

Destacado (18)

Administracion
AdministracionAdministracion
Administracion
 
Public health certificate
Public health certificatePublic health certificate
Public health certificate
 
Buscar imágenes en la web
Buscar imágenes en la web Buscar imágenes en la web
Buscar imágenes en la web
 
How Can I Convert PIO Card into OCI Card?
How Can I Convert PIO Card into OCI Card?How Can I Convert PIO Card into OCI Card?
How Can I Convert PIO Card into OCI Card?
 
Diseño de una guía didáctica con imágenes
Diseño de una guía didáctica con imágenesDiseño de una guía didáctica con imágenes
Diseño de una guía didáctica con imágenes
 
Վեբ 2.0՝ ի՞նչ է դա
Վեբ 2.0՝ ի՞նչ է դաՎեբ 2.0՝ ի՞նչ է դա
Վեբ 2.0՝ ի՞նչ է դա
 
First aid certificate 2016
First aid certificate 2016First aid certificate 2016
First aid certificate 2016
 
Social Media for the Federation of Small Businesses
Social Media for the Federation of Small BusinessesSocial Media for the Federation of Small Businesses
Social Media for the Federation of Small Businesses
 
Merbromin 129-16-8-api
Merbromin 129-16-8-apiMerbromin 129-16-8-api
Merbromin 129-16-8-api
 
PHP Conference 2016
PHP Conference 2016PHP Conference 2016
PHP Conference 2016
 
WordCamp SP 2016
WordCamp SP 2016WordCamp SP 2016
WordCamp SP 2016
 
Tutorial: cómo cargar un video a Edmodo desde Youtube
Tutorial: cómo cargar un video a Edmodo desde YoutubeTutorial: cómo cargar un video a Edmodo desde Youtube
Tutorial: cómo cargar un video a Edmodo desde Youtube
 
Recommendation for Maya Emilova
Recommendation for Maya EmilovaRecommendation for Maya Emilova
Recommendation for Maya Emilova
 
Canada Mortgage and Housing Corporation's (CMHC) Municipal Infrastructure Len...
Canada Mortgage and Housing Corporation's (CMHC) Municipal Infrastructure Len...Canada Mortgage and Housing Corporation's (CMHC) Municipal Infrastructure Len...
Canada Mortgage and Housing Corporation's (CMHC) Municipal Infrastructure Len...
 
Performance-Analyse mit Bordmitteln
Performance-Analyse mit BordmittelnPerformance-Analyse mit Bordmitteln
Performance-Analyse mit Bordmitteln
 
Driving Design through Examples
Driving Design through ExamplesDriving Design through Examples
Driving Design through Examples
 
The quest for global design principles (SymfonyLive Berlin 2015)
The quest for global design principles (SymfonyLive Berlin 2015)The quest for global design principles (SymfonyLive Berlin 2015)
The quest for global design principles (SymfonyLive Berlin 2015)
 
"let ECMAScript = 6"
"let ECMAScript = 6" "let ECMAScript = 6"
"let ECMAScript = 6"
 

Similar a Conscious Decoupling - Lone Star PHP

Functional programming is not about complicated things
Functional programming is not about complicated thingsFunctional programming is not about complicated things
Functional programming is not about complicated thingsMichael Langford
 
Introduction to PHP - SDPHP
Introduction to PHP - SDPHPIntroduction to PHP - SDPHP
Introduction to PHP - SDPHPEric Johnson
 
Node.JS Vs PHP: Which Is The Top Server-Side Programming Language?
Node.JS Vs PHP: Which Is The Top Server-Side Programming Language?Node.JS Vs PHP: Which Is The Top Server-Side Programming Language?
Node.JS Vs PHP: Which Is The Top Server-Side Programming Language?Pixel Crayons
 
Outsourcing php india
Outsourcing php indiaOutsourcing php india
Outsourcing php indiataishaaben
 
Unleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ PlatformUnleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ PlatformSébastien Morel
 
Chap 4 PHP.pdf
Chap 4 PHP.pdfChap 4 PHP.pdf
Chap 4 PHP.pdfHASENSEID
 
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...Paul Jensen
 
Applied progressive decoupling weather.com, angular, and drupal
Applied progressive decoupling  weather.com, angular, and drupalApplied progressive decoupling  weather.com, angular, and drupal
Applied progressive decoupling weather.com, angular, and drupalAcquia
 
Introduction to PHP (SDPHP)
Introduction to PHP   (SDPHP)Introduction to PHP   (SDPHP)
Introduction to PHP (SDPHP)Eric Johnson
 
Laravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionLaravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionJoe Ferguson
 
ContainerDayVietnam2016: Become a Cloud-native Developer
ContainerDayVietnam2016: Become a Cloud-native DeveloperContainerDayVietnam2016: Become a Cloud-native Developer
ContainerDayVietnam2016: Become a Cloud-native DeveloperDocker-Hanoi
 
Digpen 7: Why choose Laravel?
Digpen 7: Why choose Laravel?Digpen 7: Why choose Laravel?
Digpen 7: Why choose Laravel?John Blackmore
 
2013 - Dustin whittle - Escalando PHP en la vida real
2013 - Dustin whittle - Escalando PHP en la vida real2013 - Dustin whittle - Escalando PHP en la vida real
2013 - Dustin whittle - Escalando PHP en la vida realPHP Conference Argentina
 
Top 10 php frameworks in 2021
Top 10 php frameworks in 2021Top 10 php frameworks in 2021
Top 10 php frameworks in 2021MaryamAnwar10
 
What’s New and Hot in .NET 4.0
What’s New and Hot in .NET 4.0What’s New and Hot in .NET 4.0
What’s New and Hot in .NET 4.0Jess Chadwick
 

Similar a Conscious Decoupling - Lone Star PHP (20)

Conscious Coupling
Conscious CouplingConscious Coupling
Conscious Coupling
 
Functional programming is not about complicated things
Functional programming is not about complicated thingsFunctional programming is not about complicated things
Functional programming is not about complicated things
 
Zend Framework Workshop
Zend Framework WorkshopZend Framework Workshop
Zend Framework Workshop
 
Introduction to PHP - SDPHP
Introduction to PHP - SDPHPIntroduction to PHP - SDPHP
Introduction to PHP - SDPHP
 
Node.JS Vs PHP: Which Is The Top Server-Side Programming Language?
Node.JS Vs PHP: Which Is The Top Server-Side Programming Language?Node.JS Vs PHP: Which Is The Top Server-Side Programming Language?
Node.JS Vs PHP: Which Is The Top Server-Side Programming Language?
 
Outsourcing php india
Outsourcing php indiaOutsourcing php india
Outsourcing php india
 
Unleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ PlatformUnleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ Platform
 
Chap 4 PHP.pdf
Chap 4 PHP.pdfChap 4 PHP.pdf
Chap 4 PHP.pdf
 
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
 
Applied progressive decoupling weather.com, angular, and drupal
Applied progressive decoupling  weather.com, angular, and drupalApplied progressive decoupling  weather.com, angular, and drupal
Applied progressive decoupling weather.com, angular, and drupal
 
Introduction to PHP (SDPHP)
Introduction to PHP   (SDPHP)Introduction to PHP   (SDPHP)
Introduction to PHP (SDPHP)
 
Laravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionLaravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello Production
 
ContainerDayVietnam2016: Become a Cloud-native Developer
ContainerDayVietnam2016: Become a Cloud-native DeveloperContainerDayVietnam2016: Become a Cloud-native Developer
ContainerDayVietnam2016: Become a Cloud-native Developer
 
Digpen 7: Why choose Laravel?
Digpen 7: Why choose Laravel?Digpen 7: Why choose Laravel?
Digpen 7: Why choose Laravel?
 
Top 5 advanced php framework in 2018
Top 5 advanced php framework in 2018Top 5 advanced php framework in 2018
Top 5 advanced php framework in 2018
 
Introducing symfony
Introducing symfonyIntroducing symfony
Introducing symfony
 
2013 - Dustin whittle - Escalando PHP en la vida real
2013 - Dustin whittle - Escalando PHP en la vida real2013 - Dustin whittle - Escalando PHP en la vida real
2013 - Dustin whittle - Escalando PHP en la vida real
 
Top 10 php frameworks in 2021
Top 10 php frameworks in 2021Top 10 php frameworks in 2021
Top 10 php frameworks in 2021
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
 
What’s New and Hot in .NET 4.0
What’s New and Hot in .NET 4.0What’s New and Hot in .NET 4.0
What’s New and Hot in .NET 4.0
 

Más de CiaranMcNulty

Greener web development at PHP London
Greener web development at PHP LondonGreener web development at PHP London
Greener web development at PHP LondonCiaranMcNulty
 
Doodle Driven Development
Doodle Driven DevelopmentDoodle Driven Development
Doodle Driven DevelopmentCiaranMcNulty
 
Behat Best Practices with Symfony
Behat Best Practices with SymfonyBehat Best Practices with Symfony
Behat Best Practices with SymfonyCiaranMcNulty
 
Behat Best Practices
Behat Best PracticesBehat Best Practices
Behat Best PracticesCiaranMcNulty
 
Behat Best Practices with Symfony
Behat Best Practices with SymfonyBehat Best Practices with Symfony
Behat Best Practices with SymfonyCiaranMcNulty
 
Driving Design through Examples
Driving Design through ExamplesDriving Design through Examples
Driving Design through ExamplesCiaranMcNulty
 
Modelling by Example Workshop - PHPNW 2016
Modelling by Example Workshop - PHPNW 2016Modelling by Example Workshop - PHPNW 2016
Modelling by Example Workshop - PHPNW 2016CiaranMcNulty
 
Finding the Right Testing Tool for the Job
Finding the Right Testing Tool for the JobFinding the Right Testing Tool for the Job
Finding the Right Testing Tool for the JobCiaranMcNulty
 
Fly In Style (without splashing out)
Fly In Style (without splashing out)Fly In Style (without splashing out)
Fly In Style (without splashing out)CiaranMcNulty
 
Why Your Test Suite Sucks - PHPCon PL 2015
Why Your Test Suite Sucks - PHPCon PL 2015Why Your Test Suite Sucks - PHPCon PL 2015
Why Your Test Suite Sucks - PHPCon PL 2015CiaranMcNulty
 
Driving Design through Examples - PhpCon PL 2015
Driving Design through Examples - PhpCon PL 2015Driving Design through Examples - PhpCon PL 2015
Driving Design through Examples - PhpCon PL 2015CiaranMcNulty
 
Building a Pyramid: Symfony Testing Strategies
Building a Pyramid: Symfony Testing StrategiesBuilding a Pyramid: Symfony Testing Strategies
Building a Pyramid: Symfony Testing StrategiesCiaranMcNulty
 
Driving Design through Examples
Driving Design through ExamplesDriving Design through Examples
Driving Design through ExamplesCiaranMcNulty
 
Why Your Test Suite Sucks
Why Your Test Suite SucksWhy Your Test Suite Sucks
Why Your Test Suite SucksCiaranMcNulty
 
Using HttpKernelInterface for Painless Integration
Using HttpKernelInterface for Painless IntegrationUsing HttpKernelInterface for Painless Integration
Using HttpKernelInterface for Painless IntegrationCiaranMcNulty
 

Más de CiaranMcNulty (16)

Greener web development at PHP London
Greener web development at PHP LondonGreener web development at PHP London
Greener web development at PHP London
 
Doodle Driven Development
Doodle Driven DevelopmentDoodle Driven Development
Doodle Driven Development
 
Behat Best Practices with Symfony
Behat Best Practices with SymfonyBehat Best Practices with Symfony
Behat Best Practices with Symfony
 
Behat Best Practices
Behat Best PracticesBehat Best Practices
Behat Best Practices
 
Behat Best Practices with Symfony
Behat Best Practices with SymfonyBehat Best Practices with Symfony
Behat Best Practices with Symfony
 
Driving Design through Examples
Driving Design through ExamplesDriving Design through Examples
Driving Design through Examples
 
Modelling by Example Workshop - PHPNW 2016
Modelling by Example Workshop - PHPNW 2016Modelling by Example Workshop - PHPNW 2016
Modelling by Example Workshop - PHPNW 2016
 
Finding the Right Testing Tool for the Job
Finding the Right Testing Tool for the JobFinding the Right Testing Tool for the Job
Finding the Right Testing Tool for the Job
 
Fly In Style (without splashing out)
Fly In Style (without splashing out)Fly In Style (without splashing out)
Fly In Style (without splashing out)
 
Why Your Test Suite Sucks - PHPCon PL 2015
Why Your Test Suite Sucks - PHPCon PL 2015Why Your Test Suite Sucks - PHPCon PL 2015
Why Your Test Suite Sucks - PHPCon PL 2015
 
Driving Design through Examples - PhpCon PL 2015
Driving Design through Examples - PhpCon PL 2015Driving Design through Examples - PhpCon PL 2015
Driving Design through Examples - PhpCon PL 2015
 
Building a Pyramid: Symfony Testing Strategies
Building a Pyramid: Symfony Testing StrategiesBuilding a Pyramid: Symfony Testing Strategies
Building a Pyramid: Symfony Testing Strategies
 
TDD with PhpSpec
TDD with PhpSpecTDD with PhpSpec
TDD with PhpSpec
 
Driving Design through Examples
Driving Design through ExamplesDriving Design through Examples
Driving Design through Examples
 
Why Your Test Suite Sucks
Why Your Test Suite SucksWhy Your Test Suite Sucks
Why Your Test Suite Sucks
 
Using HttpKernelInterface for Painless Integration
Using HttpKernelInterface for Painless IntegrationUsing HttpKernelInterface for Painless Integration
Using HttpKernelInterface for Painless Integration
 

Último

AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...software pro Development
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 

Último (20)

AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 

Conscious Decoupling - Lone Star PHP

  • 1. Conscious Decoupling Building Software that Lasts Ciaran McNulty at Lone Star PHP 2016
  • 2. Me Hi, I'm Ciaran and I'm a PHP developer I am a consultant with Inviqa I maintain PhpSpec and contribute to Behat
  • 3. My early period: Write procedural code!
  • 4. My middle period: Decouple all the things!
  • 5. My late period: Decouple some of the things!
  • 7. class TaxiDispatcher { function dispatch (Car $car, $destination) { $this->chargeCustomer(); $car->goTo($destination); } }
  • 8.
  • 9.
  • 10.
  • 11. Problems with dependencies 4 Changes to Car mean changes to Dispatcher 4 Can't reuse Dispatcher with new vehicles
  • 12. interface Vehicle { public function goTo($destination); } class TaxiDispatcher { function dispatch (Vehicle $vehicle, $destination) { $this->chargeCustomer(); $vehicle->goTo($destination); } }
  • 13.
  • 14.
  • 15.
  • 16.
  • 17. Benefits of abstraction 4 Now we only need to rewrite Dispatcher and Car when Vehicle changes 4 Vehicle can be very stable; it's just an interface 4 Can make new transportation types that implement Vehicle
  • 18. Defining abstractions 4 Start with the abstraction, not the detail 4 Contract should be a simple as possible 4 Contract should focus on resposibilities 4 Hide details of underlying APIs
  • 19. Example - upgrade eligibility Bad abstraction: interface HttpClient { public function getData : array ($url, $parameters); }
  • 20. Example - upgrade eligibility Better abstraction: interface UpgradeEligibilityChecker { public function getContractId : int ($phoneNumber); public function isEligibleForUpgrade : bool ($contractId); }
  • 21. Example - upgrade eligibility Best abstraction: interface UpgradeEligibilityChecker { public function isEligibleForUpgrade : bool ($phoneNumber); }
  • 22. Or, get on the bus 4 Migrate actions from method calls to objects 4 Depend on a bus rather than depending on contracts 4 Don't know anything about what handles the action
  • 23. Events Direct coupling: $notifier->notifyLawyersAboutPurchase($id, $item, $cost); Event style: $eventBus->dispatch( new ItemWasPurchased($id, $item, $cost); );
  • 24. Commands Use case / service style: $invoiceApprover->approveInvoice(1234); Command style: $commandBus->dispatch( new ApproveInvoice(1234); );
  • 25. Advantages of decoupling via abstractions 4 Cleaner APIs 4 Swappable components 4 Separation of concerns 4 Easier to test 4 No 'ripple effect' around changes
  • 26. Disadvantages of decoupling via abstractions 4 Makes execution flow harder to follow 4 Adds more complexity (more files in codebase) 4 Cognitive cost of thinking of good abstractions
  • 27. Architectural boundaries 4 Abstractions are going to change when the use cases change 4 Interfaces are more tightly coupled to code that uses them 4 Interfaces 'belong' in the same architectural boundary as the code that uses them.
  • 28.
  • 29.
  • 30.
  • 32. Highly coupled frameworks Some frameworks let you go really quickly by coupling directly to them. You probably won't be able to reuse your code without considerable effort. 4 Drupal 4 Magento 4 Wordpress
  • 33. More coupled framworks Some frameworks let you go faster when you adopt their conventions. You can reuse your code with a fair amount of additional effort. 4 Laravel 4 Symfony1 4 CakePHP
  • 34. More decoupled frameworks Some frameworks encourage decoupling so your code is more reusable. You will go a little slower because you need to explicitly configure things 4 Symfony 2 4 Zend Framework 2
  • 35. Very decoupled frameworks Some frameworks are extremely decoupled so code is almost entirely reusable. You almost have to construct the entire framework yourself from components - this can be hard! 4 D.I.Y. 4 Zend Expressive
  • 36. Only decouple where you need to (wait, how do we know where that is?)
  • 37. Coupled code get painful when change happens Decoupled code was wasted effort when change doesn't happen
  • 38. Where does change come from?
  • 39. Where does change come from? People!
  • 40.
  • 41.
  • 42.
  • 43.
  • 44. Decouple your system to respond to different streams of change
  • 45.
  • 46.
  • 47. Organizations which design systems ... are constrained to produce designs which are copies of the communication structures of these organizations 1 Melvin Conway, 1967
  • 48. Context mapping 4 Identify subdomains 4 Identify which are: 4 Core subdomains 4 Supporting subdomains 4 Generic subdomains 4 Mirror the structure in your architecture
  • 49. The bad news: You will get it wrong You only find out afterwards
  • 50. The good news: It's not just you
  • 51. Things to check out 4 Context Mapping 4 Hexagonal Architecture 4 Modelling by Example
  • 52. Thank you! 4 @ciaranmcnulty 4 Lead Maintainer of PhpSpec 4 SeniorTrainer at Inviqa 4 https://joind.in/talk/e20e3 Questions?