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

More Related Content

What's hot

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
 

What's hot (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
 

Viewers also liked

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
 

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

More from 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
 

More from 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
 

Recently uploaded

Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingShane Coughlan
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 

Recently uploaded (20)

Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 

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?