SlideShare uma empresa Scribd logo
1 de 64
Baixar para ler offline
OOP is More Than Cars
and Dogs
Chris	
  Tankersley	
  
MadisonPHP	
  2015	
  
MadisonPHP	
  2015	
   1	
  
Who Am I
•  PHP	
  Programmer	
  for	
  over	
  10	
  years	
  
•  Work/know	
  a	
  lot	
  of	
  different	
  
languages,	
  even	
  COBOL	
  
•  Primarily	
  do	
  Zend	
  Framework	
  2	
  
•  hGps://github.com/dragonmantank	
  
MadisonPHP	
  2015	
   2	
  
Quick Vocabulary Lesson
•  Class	
  –	
  DefiniPon	
  of	
  code	
  
•  Object	
  –	
  InstanPaPon	
  of	
  a	
  Class	
  
•  Member	
  –	
  Variable	
  belonging	
  to	
  a	
  class	
  
•  Method	
  –	
  FuncPon	
  belonging	
  to	
  a	
  class	
  
There	
  will	
  be	
  more	
  as	
  we	
  go	
  along	
  
MadisonPHP	
  2015	
   3	
  
MadisonPHP	
  2015	
   4	
  
Class
class Employee {
protected $name; // This is a member
protected $number;
// This is a Method
public function setData($data) {
$this->name = $data['name'];
$this->number = $data['number'];
}
public function viewData() {
echo <<<ENDTEXT
Name: {$this->name}
Number: {$this->number}
ENDTEXT;
}
}
Object
<?php!
!
$manager= new Manager();!
// ^!
// |!
// `--- This is the Object	
  
MadisonPHP	
  2015	
   5	
  
Why are we using OOP?
MadisonPHP	
  2015	
   6	
  
Let’s count the reasons
•  Because	
  we’re	
  told	
  to,	
  procedural	
  programming	
  leads	
  to	
  spagheX	
  
code	
  
•  We	
  deal	
  with	
  objects	
  every	
  day,	
  so	
  it	
  shouldn’t	
  be	
  too	
  hard	
  
•  We	
  want	
  to	
  allow	
  for	
  code	
  re-­‐use	
  
•  We	
  want	
  to	
  group	
  like	
  code	
  together	
  
•  We	
  want	
  to	
  easily	
  extend	
  our	
  code	
  
•  We	
  want	
  to	
  be	
  able	
  to	
  easily	
  test	
  our	
  code	
  
MadisonPHP	
  2015	
   7	
  
Getting OOP Right is Complicated
MadisonPHP	
  2015	
   8	
  
MadisonPHP	
  2015	
   9	
  
MadisonPHP	
  2015	
   10	
  
MadisonPHP	
  2015	
   11	
  
MadisonPHP	
  2015	
   12	
  
MadisonPHP	
  2015	
   13	
  
MadisonPHP	
  2015	
   14	
  
Can a Dog have Wheels?
MadisonPHP	
  2015	
   15	
  
Inheritance
MadisonPHP	
  2015	
   16	
  
What we’re all taught
•  Classes	
  are	
  “things”	
  in	
  the	
  real	
  world	
  
•  We	
  should	
  construct	
  class	
  members	
  based	
  on	
  AGributes	
  
•  Number	
  of	
  wheels	
  
•  Sound	
  it	
  makes	
  
•  We	
  should	
  construct	
  class	
  methods	
  based	
  on	
  “AcPons”	
  
•  Running	
  
•  Speaking	
  
•  Jumping	
  
MadisonPHP	
  2015	
   17	
  
New Vocabulary
•  Parent	
  Class	
  –	
  Class	
  that	
  is	
  extended	
  
•  Child	
  Class	
  –	
  Class	
  that	
  is	
  extending	
  another	
  class	
  
In	
  PHP,	
  a	
  class	
  can	
  be	
  both	
  a	
  Child	
  and	
  a	
  Parent	
  at	
  the	
  same	
  Pme	
  
MadisonPHP	
  2015	
   18	
  
Where I Learned It
MadisonPHP	
  2015	
   19	
  
Our Structure
MadisonPHP	
  2015	
   20	
  
Employee	
  
Manager	
   ScienPst	
   Laborer	
  
The Employee Class
MadisonPHP	
  2015	
   21	
  
abstract class Employee {
protected $name; // Employee Name
protected $number; // Employee Number
public function setData($data) {
$this->name = $data['name'];
$this->number = $data['number'];
}
public function viewData() {
echo <<<ENDTEXT
Name: {$this->name}
Number: {$this->number}
ENDTEXT;
}
}
The Manager Class
MadisonPHP	
  2015	
   22	
  
class Manager extends Employee {
protected $title; // Employee Title
protected $dues; // Golf Dues
public function setData($data) {
parent::setData($data);
$this->title = $data['title'];
$this->dues = $data['dues'];
}
public function viewData() {
parent::viewData();
echo <<<ENDTEXT
Title: {$this->title}
Golf Dues: {$this->dues}
ENDTEXT;
}
}
The Scientist Class
MadisonPHP	
  2015	
   23	
  
class Scientist extends Employee {
protected $pubs; // Number of Publications
public function setData($data) {
parent::setData($data);
$this->pubs = $data['pubs'];
}
public function viewData() {
parent::viewData();
echo <<<ENDTEXT
Publications: {$this->pubs}
ENDTEXT;
}
}
The Laborer Class
MadisonPHP	
  2015	
   24	
  
class Laborer extends Employee {
}
What does this teach us?
•  Inheritance	
  
•  Makes	
  it	
  easier	
  to	
  group	
  code	
  together	
  and	
  share	
  it	
  amongst	
  classes	
  
•  Allows	
  us	
  to	
  extend	
  code	
  as	
  needed	
  
•  PHP	
  allows	
  Single	
  inheritance	
  
MadisonPHP	
  2015	
   25	
  
We use it all the time
namespace ApplicationController;!
!
use ZendMvcControllerAbstractActionController;!
use ZendViewModelViewModel;!
!
Class IndexController extends AbstractActionController {!
public function indexAction() {!
/** @var VendorVendorService $vendor */!
$vendor = $this->serviceLocator->get('VendorVendorService');!
!
$view = new ViewModel();!
return $view;!
}!
}	
   MadisonPHP	
  2015	
   26	
  
Why it Works (Most of the time, Kinda)
•  Allows	
  us	
  to	
  extend	
  things	
  we	
  didn’t	
  necessarily	
  create	
  
•  Encourages	
  code	
  re-­‐use	
  
•  Allows	
  developers	
  to	
  abstract	
  away	
  things	
  
MadisonPHP	
  2015	
   27	
  
How to use it
•  Understand	
  the	
  difference	
  between	
  Public,	
  Protected,	
  and	
  Private	
  
•  Public	
  –	
  Anyone	
  can	
  use	
  this,	
  even	
  children	
  
•  Protected	
  –	
  Anything	
  internal	
  can	
  use	
  this,	
  even	
  children	
  
•  Private	
  –	
  This	
  is	
  mine,	
  hands	
  off	
  
•  Abstract	
  vs	
  Concrete	
  Classes	
  
•  Abstract	
  classes	
  cannot	
  be	
  instanPated	
  directly,	
  they	
  must	
  be	
  extended	
  
MadisonPHP	
  2015	
   28	
  
The Employee Class
MadisonPHP	
  2015	
   29	
  
abstract class Employee {
protected $name; // Employee Name
protected $number; // Employee Number
public function setData($data) {
$this->name = $data['name'];
$this->number = $data['number'];
}
public function viewData() {
echo <<<ENDTEXT
Name: {$this->name}
Number: {$this->number}
ENDTEXT;
}
}
The Manager Class
MadisonPHP	
  2015	
   30	
  
class Manager extends Employee {
protected $title; // Employee Title
protected $dues; // Golf Dues
public function setData($data) {
parent::setData($data);
$this->title = $data['title'];
$this->dues = $data['dues'];
}
public function viewData() {
parent::viewData();
echo <<<ENDTEXT
Title: {$this->title}
Golf Dues: {$this->dues}
ENDTEXT;
}
}
An Example
// Fatal error: Cannot instantiate abstract class Employee!
$employee = new Employee(); !
!
// We can do this though!!
$manager = new Manager(); !
!
// Fatal error: Cannot access protected property Manager::$name!
$manager->name = 'Bob McManager’;!
!
// setData is public, so we can use that!
$manager->setData(['name' => 'Bob McManager’,'number' => 1]);!
!
// We can also view the data, since it's public!
$manager->viewData();	
  
MadisonPHP	
  2015	
   31	
  
Why can Inheritance Be Bad
•  PHP	
  only	
  allows	
  Single	
  Inheritance	
  on	
  an	
  Class	
  
•  You	
  can	
  have	
  a	
  series	
  of	
  Inheritance	
  though,	
  for	
  example	
  CEO	
  extends	
  
Manager,	
  Manager	
  extends	
  Employee	
  
•  Long	
  inheritance	
  chains	
  can	
  be	
  a	
  code	
  smell	
  
•  Private	
  members	
  and	
  methods	
  cannot	
  be	
  used	
  by	
  Child	
  classes	
  
•  Single	
  Inheritance	
  can	
  make	
  it	
  hard	
  to	
  ‘bolt	
  on’	
  new	
  funcPonality	
  
between	
  disparate	
  classes	
  
MadisonPHP	
  2015	
   32	
  
Composition over Inheritance
MadisonPHP	
  2015	
   33	
  
The General Idea
•  Classes	
  contain	
  other	
  classes	
  to	
  do	
  work	
  and	
  extend	
  that	
  way,	
  instead	
  
of	
  through	
  Inheritance	
  
•  Interfaces	
  define	
  “contracts”	
  that	
  objects	
  will	
  adhere	
  to	
  
•  Your	
  classes	
  implement	
  interfaces	
  to	
  add	
  needed	
  funcPonality	
  
MadisonPHP	
  2015	
   34	
  
Interfaces
interface EmployeeInterface {!
protected $name;!
protected $number;!
!
public function getName();!
public function setName($name);!
public function getNumber();!
public function setNumber($number);!
}!
!
interface ManagerInterface {!
protected $golfHandicap;!
!
public function getHandicap();!
public function setHandicap($handicap);!
}	
  
MadisonPHP	
  2015	
   35	
  
Interface Implementation
class Employee implements EmployeeInterface {!
public function getName() {!
return $this->name;!
}!
public function setName($name) {!
$this->name = $name;!
}!
}!
class Manager implements EmployeeInterface, ManagerInterface {!
// defines the employee getters/setters as well!
public function getHandicap() {!
return $this->handicap; !
}!
public function setHandicap($handicap) {!
$this->handicap = $handicap;!
}!
}	
  
MadisonPHP	
  2015	
   36	
  
This is Good and Bad
•  “HAS-­‐A”	
  is	
  tends	
  to	
  be	
  more	
  flexible	
  than	
  “IS-­‐A”	
  
•  Somewhat	
  easier	
  to	
  understand,	
  since	
  there	
  isn’t	
  a	
  hierarchy	
  you	
  
have	
  to	
  backtrack	
  	
  
•  Each	
  class	
  must	
  provide	
  their	
  own	
  ImplementaPon,	
  so	
  can	
  lead	
  to	
  
code	
  duplicaPon	
  
MadisonPHP	
  2015	
   37	
  
Traits
•  Allows	
  small	
  blocks	
  of	
  code	
  to	
  be	
  defined	
  that	
  can	
  be	
  used	
  by	
  many	
  
classes	
  
•  Useful	
  when	
  abstract	
  classes/inheritance	
  would	
  be	
  cumbersome	
  
•  My	
  Posts	
  and	
  Pages	
  classes	
  shouldn’t	
  need	
  to	
  extend	
  a	
  Slugger	
  class	
  just	
  to	
  
generate	
  slugs.	
  	
  
MadisonPHP	
  2015	
   38	
  
Avoid Code-Duplication with Traits
trait EmployeeTrait {!
public function getName() {!
return $this->name;!
}!
public function setName($name) {!
$this->name = $name;!
}!
}!
class Employee implements EmployeeInterface {!
use EmployeeTrait;!
}!
class Manager implements EmployeeInterface, ManagerInterface {!
use EmployeeTrait;!
use ManagerTrait;!
}	
  
MadisonPHP	
  2015	
   39	
  
Taking Advantage of OOP
MadisonPHP	
  2015	
   40	
  
Coupling
MadisonPHP	
  2015	
   41	
  
What is Coupling?
•  Coupling	
  is	
  how	
  dependent	
  your	
  code	
  is	
  on	
  another	
  class	
  
•  The	
  more	
  classes	
  you	
  are	
  coupled	
  to,	
  the	
  more	
  changes	
  affect	
  your	
  
class	
  
MadisonPHP	
  2015	
   42	
  
namespace ApplicationController;!
!
use ZendMvcControllerAbstractActionController;!
use ZendViewModelViewModel;!
!
class MapController extends AbstractActionController!
{!
public function indexAction()!
{!
// Position is an array with a Latitude and Longitude object!
$position = $this->getServiceLocator()->get('MapService’)!
->getLatLong('123 Main Street', 'Defiance', 'OH');!
echo $position->latitude->getPoint();!
}!
}	
  
MadisonPHP	
  2015	
   43	
  
Law of Demeter
MadisonPHP	
  2015	
   44	
  
Dependency Injection
MadisonPHP	
  2015	
   45	
  
What is Dependency Injection?
•  InjecPng	
  dependencies	
  into	
  classes,	
  instead	
  of	
  having	
  the	
  class	
  create	
  
it	
  
•  Allows	
  for	
  much	
  easier	
  tesPng	
  
•  Allows	
  for	
  a	
  much	
  easier	
  Pme	
  swapping	
  out	
  code	
  
•  Reduces	
  the	
  coupling	
  that	
  happens	
  between	
  classes	
  
MadisonPHP	
  2015	
   46	
  
Method Injection
class MapService {!
public function getLatLong(GoogleMaps $map, $street, $city, $state) {!
return $map->getLatLong($street . ' ' . $city . ' ' . $state);!
}!
!
public function getAddress(GoogleMaps $map, $lat, $long) {!
return $map->getAddress($lat, $long);!
}!
}	
  
MadisonPHP	
  2015	
   47	
  
Constructor Injection
class MapService {!
protected $map;!
public function __construct(GoogleMaps $map) {!
$this->map = $map;!
}!
public function getLatLong($street, $city, $state) {!
return $this!
->map!
->getLatLong($street . ' ' . $city . ' ' . $state);!
}!
}!
!
	
  
MadisonPHP	
  2015	
   48	
  
Setter Injection
class MapService {!
protected $map;!
!
public function setMap(GoogleMaps $map) {!
$this->map = $map;!
}!
public function getMap() {!
return $this->map;!
}!
public function getLatLong($street, $city, $state) {!
return $this->getMap()->getLatLong($street . ' ' . $city . ' ' . $state);!
}!
}!
	
  
MadisonPHP	
  2015	
   49	
  
Single Responsibility Principle
MadisonPHP	
  2015	
   50	
  
Single Responsibility Principle
•  Every	
  class	
  should	
  have	
  a	
  single	
  responsibility,	
  and	
  that	
  responsibility	
  
should	
  be	
  encapsulated	
  in	
  that	
  class	
  
MadisonPHP	
  2015	
   51	
  
What is a Responsibility?
•  Responsibility	
  is	
  a	
  “Reason	
  To	
  Change”	
  –	
  Robert	
  C.	
  MarPn	
  
•  By	
  having	
  more	
  than	
  one	
  “Reason	
  to	
  Change”,	
  code	
  is	
  harder	
  to	
  
maintain	
  and	
  becomes	
  coupled	
  
•  Since	
  the	
  class	
  is	
  coupled	
  to	
  mulPple	
  responsibiliPes,	
  it	
  becomes	
  
harder	
  for	
  the	
  class	
  to	
  adapt	
  to	
  any	
  one	
  responsibility	
  
	
  
MadisonPHP	
  2015	
   52	
  
An Example
/**
* Create a new invoice instance.
*
* @param LaravelCashierContractsBillable $billable
* @param object
* @return void
*/
public function __construct(BillableContract $billable, $invoice)
{
$this->billable = $billable;
$this->files = new Filesystem;
$this->stripeInvoice = $invoice;
}
/**
* Create an invoice download response.
*
* @param array $data
* @param string $storagePath
* @return SymfonyComponentHttpFoundationResponse
*/
public function download(array $data, $storagePath = null)
{
$filename = $this->getDownloadFilename($data['product']);
$document = $this->writeInvoice($data, $storagePath);
$response = new Response($this->files->get($document), 200, [
'Content-Description' => 'File Transfer',
'Content-Disposition' => 'attachment; filename="'.$filename.'"',
'Content-Transfer-Encoding' => 'binary',
'Content-Type' => 'application/pdf',
]);
$this->files->delete($document);
return $response;
}
MadisonPHP	
  2015	
   53	
  
hGps://github.com/laravel/cashier/blob/master/src/Laravel/Cashier/Invoice.php	
  
Why is this Bad?
•  This	
  single	
  class	
  has	
  the	
  following	
  responsibiliPes:	
  
•  GeneraPng	
  totals	
  for	
  the	
  invoice	
  (including	
  discounts/coupons)	
  
•  GeneraPng	
  an	
  HTML	
  View	
  of	
  the	
  invoice	
  (Invoice::view())	
  
•  GeneraPng	
  a	
  PDF	
  download	
  of	
  the	
  invoice(Invoice::download())	
  
•  This	
  is	
  coupled	
  to	
  a	
  shell	
  script	
  as	
  well	
  
•  Two	
  different	
  displays	
  handled	
  by	
  the	
  class.	
  Adding	
  more	
  means	
  
more	
  responsibility	
  
•  Coupled	
  to	
  a	
  specific	
  HTML	
  template,	
  the	
  filesystem,	
  the	
  Laravel	
  
Views	
  system,	
  and	
  PhantomJS	
  via	
  the	
  shell	
  script	
  
MadisonPHP	
  2015	
   54	
  
How to Improve
•  Change	
  responsibility	
  to	
  just	
  building	
  the	
  invoice	
  data	
  
•  Move	
  the	
  ‘output’	
  stuff	
  to	
  other	
  classes	
  
MadisonPHP	
  2015	
   55	
  
Unit Testing
MadisonPHP	
  2015	
   56	
  
[Could	
  not	
  afford	
  licensing	
  fee	
  for	
  Grumpy	
  TesPng	
  Picture]	
  
MadisonPHP	
  2015	
   57	
  
This is not a testing talk
•  Using	
  Interfaces	
  makes	
  it	
  easier	
  to	
  mock	
  objects	
  
•  Reducing	
  coupling	
  and	
  following	
  Demeter’s	
  Law	
  makes	
  you	
  have	
  to	
  
mock	
  less	
  objects	
  
•  Dependency	
  InjecPon	
  means	
  you	
  only	
  mock	
  what	
  you	
  need	
  for	
  that	
  
test	
  
•  Single	
  Responsibility	
  means	
  your	
  test	
  should	
  be	
  short	
  and	
  sweet	
  
•  Easier	
  tesPng	
  leads	
  to	
  more	
  tesPng	
  
MadisonPHP	
  2015	
   58	
  
Final Thoughts
MadisonPHP	
  2015	
   59	
  
We can make a dog with wheels!
•  Abstract	
  class	
  for	
  Animal	
  
•  Class	
  for	
  Dog	
  that	
  extends	
  Animal	
  
•  Trait	
  for	
  Wheels	
  
•  With	
  the	
  write	
  methodology,	
  we	
  could	
  even	
  unit	
  test	
  this	
  
In	
  the	
  real	
  world,	
  we	
  can	
  now	
  represent	
  a	
  crippled	
  dog	
  
MadisonPHP	
  2015	
   60	
  
Here’s a cute dog instead
MadisonPHP	
  2015	
   61	
  
Additional Resources
•  Clean	
  Code	
  –	
  Robert	
  C.	
  MarPn	
  
•  PHP	
  Objects,	
  PaGerns,	
  and	
  PracPce	
  –	
  MaG	
  Zandstra	
  
MadisonPHP	
  2015	
   62	
  
Thank You!
hGp://ctankersley.com	
  
chris@ctankersley.com	
  
@dragonmantank	
  
	
  
hGps://joind.in/16010	
  
MadisonPHP	
  2015	
   63	
  
Photos
•  Slide	
  9	
  -­‐	
  hGp://bit.ly/1dkaoxS	
  
•  Slide	
  10	
  -­‐	
  hGp://bit.ly/1c4Gc8z	
  
•  Slide	
  11	
  -­‐	
  hGp://bit.ly/1R3isBp	
  
•  Slide	
  12	
  -­‐	
  hGp://bit.ly/1ScEWRZ	
  
•  Slide	
  13	
  -­‐	
  hGp://bit.ly/1Bc0qUv	
  
•  Slide	
  14	
  -­‐	
  hGp://bit.ly/1ILhfNV	
  
•  Slide	
  15	
  -­‐	
  hGp://bit.ly/1SeekA7	
  
	
  
MadisonPHP	
  2015	
   64	
  

Mais conteúdo relacionado

Mais procurados

Towards Functional Programming through Hexagonal Architecture
Towards Functional Programming through Hexagonal ArchitectureTowards Functional Programming through Hexagonal Architecture
Towards Functional Programming through Hexagonal ArchitectureCodelyTV
 
Identify Literate Code
Identify Literate CodeIdentify Literate Code
Identify Literate Codenatedavisolds
 
Domain-driven Design in PHP and Symfony - Drupal Camp Wroclaw!
Domain-driven Design in PHP and Symfony - Drupal Camp Wroclaw!Domain-driven Design in PHP and Symfony - Drupal Camp Wroclaw!
Domain-driven Design in PHP and Symfony - Drupal Camp Wroclaw!Kacper Gunia
 
WordPress Plugin development
WordPress Plugin developmentWordPress Plugin development
WordPress Plugin developmentMostafa Soufi
 
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)Michael Wales
 
Php 7 errors messages
Php 7 errors messagesPhp 7 errors messages
Php 7 errors messagesDamien Seguy
 
Making Sense of Twig
Making Sense of TwigMaking Sense of Twig
Making Sense of TwigBrandon Kelly
 
Caldera Learn - LoopConf WP API + Angular FTW Workshop
Caldera Learn - LoopConf WP API + Angular FTW WorkshopCaldera Learn - LoopConf WP API + Angular FTW Workshop
Caldera Learn - LoopConf WP API + Angular FTW WorkshopCalderaLearn
 
Gearman jobqueue
Gearman jobqueueGearman jobqueue
Gearman jobqueueMagento Dev
 
Laravel 5 In Depth
Laravel 5 In DepthLaravel 5 In Depth
Laravel 5 In DepthKirk Bushell
 
Diving into HHVM Extensions (PHPNW Conference 2015)
Diving into HHVM Extensions (PHPNW Conference 2015)Diving into HHVM Extensions (PHPNW Conference 2015)
Diving into HHVM Extensions (PHPNW Conference 2015)James Titcumb
 
PHP Conference Asia 2016
PHP Conference Asia 2016PHP Conference Asia 2016
PHP Conference Asia 2016Britta Alex
 
PHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4DevelopersPHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4DevelopersKacper Gunia
 
Laravel5 Introduction and essentials
Laravel5 Introduction and essentialsLaravel5 Introduction and essentials
Laravel5 Introduction and essentialsPramod Kadam
 
Keeping the frontend under control with Symfony and Webpack
Keeping the frontend under control with Symfony and WebpackKeeping the frontend under control with Symfony and Webpack
Keeping the frontend under control with Symfony and WebpackIgnacio Martín
 

Mais procurados (20)

Towards Functional Programming through Hexagonal Architecture
Towards Functional Programming through Hexagonal ArchitectureTowards Functional Programming through Hexagonal Architecture
Towards Functional Programming through Hexagonal Architecture
 
Identify Literate Code
Identify Literate CodeIdentify Literate Code
Identify Literate Code
 
Domain-driven Design in PHP and Symfony - Drupal Camp Wroclaw!
Domain-driven Design in PHP and Symfony - Drupal Camp Wroclaw!Domain-driven Design in PHP and Symfony - Drupal Camp Wroclaw!
Domain-driven Design in PHP and Symfony - Drupal Camp Wroclaw!
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
WordPress Plugin development
WordPress Plugin developmentWordPress Plugin development
WordPress Plugin development
 
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
 
Php 7 errors messages
Php 7 errors messagesPhp 7 errors messages
Php 7 errors messages
 
Php + my sql
Php + my sqlPhp + my sql
Php + my sql
 
OOP
OOPOOP
OOP
 
Making Sense of Twig
Making Sense of TwigMaking Sense of Twig
Making Sense of Twig
 
Caldera Learn - LoopConf WP API + Angular FTW Workshop
Caldera Learn - LoopConf WP API + Angular FTW WorkshopCaldera Learn - LoopConf WP API + Angular FTW Workshop
Caldera Learn - LoopConf WP API + Angular FTW Workshop
 
Gearman jobqueue
Gearman jobqueueGearman jobqueue
Gearman jobqueue
 
Laravel 5 In Depth
Laravel 5 In DepthLaravel 5 In Depth
Laravel 5 In Depth
 
Diving into HHVM Extensions (PHPNW Conference 2015)
Diving into HHVM Extensions (PHPNW Conference 2015)Diving into HHVM Extensions (PHPNW Conference 2015)
Diving into HHVM Extensions (PHPNW Conference 2015)
 
PHP Conference Asia 2016
PHP Conference Asia 2016PHP Conference Asia 2016
PHP Conference Asia 2016
 
PHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4DevelopersPHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4Developers
 
errors in php 7
errors in php 7errors in php 7
errors in php 7
 
Laravel5 Introduction and essentials
Laravel5 Introduction and essentialsLaravel5 Introduction and essentials
Laravel5 Introduction and essentials
 
Keeping the frontend under control with Symfony and Webpack
Keeping the frontend under control with Symfony and WebpackKeeping the frontend under control with Symfony and Webpack
Keeping the frontend under control with Symfony and Webpack
 
SEO for Developers
SEO for DevelopersSEO for Developers
SEO for Developers
 

Destaque

Contact Activity Visualization for Seniors
Contact Activity Visualization for SeniorsContact Activity Visualization for Seniors
Contact Activity Visualization for SeniorsJoaquim Jorge
 
Winzerla 07 08_11-1
Winzerla 07 08_11-1Winzerla 07 08_11-1
Winzerla 07 08_11-1Jenapolis
 
Mensaje persuasivo. Clubs en la escuela
Mensaje persuasivo. Clubs en la escuelaMensaje persuasivo. Clubs en la escuela
Mensaje persuasivo. Clubs en la escuelaAna Guillen
 
To learn and create among the treasures
To learn and create among the treasuresTo learn and create among the treasures
To learn and create among the treasuresVera Boneva
 
Catálogo 1B "Secret Love La Pareja Perfecta".
Catálogo 1B "Secret Love La Pareja Perfecta".Catálogo 1B "Secret Love La Pareja Perfecta".
Catálogo 1B "Secret Love La Pareja Perfecta".Paty Cj
 
¿Quien mato la innovación?
¿Quien mato la innovación?¿Quien mato la innovación?
¿Quien mato la innovación?Coneklab
 
Career: A Shorex Career - a Visual Review 2015
Career: A Shorex Career - a Visual Review 2015Career: A Shorex Career - a Visual Review 2015
Career: A Shorex Career - a Visual Review 2015Jacob Lyngsøe
 
Els plecs i les falles
Els plecs i les fallesEls plecs i les falles
Els plecs i les fallesguilliriera
 
09.09 09.10.2009 - Presentation of Pré-sal E&P Executive Manager, José Mira...
09.09   09.10.2009 - Presentation of Pré-sal E&P Executive Manager, José Mira...09.09   09.10.2009 - Presentation of Pré-sal E&P Executive Manager, José Mira...
09.09 09.10.2009 - Presentation of Pré-sal E&P Executive Manager, José Mira...Petrobras
 
Using WordPress Blogging Features to Build a Website
Using WordPress Blogging Features to Build a WebsiteUsing WordPress Blogging Features to Build a Website
Using WordPress Blogging Features to Build a WebsiteEileen Weinberg
 
Sitio web exitoso para Ventas por Internet
Sitio web exitoso para Ventas por InternetSitio web exitoso para Ventas por Internet
Sitio web exitoso para Ventas por InternetCoral
 
Tutorial bitstrips
Tutorial bitstripsTutorial bitstrips
Tutorial bitstripsaportics
 
Reglamento futbol events
Reglamento futbol eventsReglamento futbol events
Reglamento futbol eventsJorge Sabán
 

Destaque (20)

Contact Activity Visualization for Seniors
Contact Activity Visualization for SeniorsContact Activity Visualization for Seniors
Contact Activity Visualization for Seniors
 
Winzerla 07 08_11-1
Winzerla 07 08_11-1Winzerla 07 08_11-1
Winzerla 07 08_11-1
 
Mensaje persuasivo. Clubs en la escuela
Mensaje persuasivo. Clubs en la escuelaMensaje persuasivo. Clubs en la escuela
Mensaje persuasivo. Clubs en la escuela
 
Latinismo
LatinismoLatinismo
Latinismo
 
To learn and create among the treasures
To learn and create among the treasuresTo learn and create among the treasures
To learn and create among the treasures
 
Maschera antigas Fornid - Drager X-Plore 550
Maschera antigas Fornid - Drager X-Plore 550Maschera antigas Fornid - Drager X-Plore 550
Maschera antigas Fornid - Drager X-Plore 550
 
Catálogo 1B "Secret Love La Pareja Perfecta".
Catálogo 1B "Secret Love La Pareja Perfecta".Catálogo 1B "Secret Love La Pareja Perfecta".
Catálogo 1B "Secret Love La Pareja Perfecta".
 
Roberto fernández bugna
Roberto fernández bugnaRoberto fernández bugna
Roberto fernández bugna
 
Proyecto emprendenred
Proyecto emprendenredProyecto emprendenred
Proyecto emprendenred
 
Diplomado medicina farmaceutica aplicada
Diplomado medicina farmaceutica aplicada Diplomado medicina farmaceutica aplicada
Diplomado medicina farmaceutica aplicada
 
¿Quien mato la innovación?
¿Quien mato la innovación?¿Quien mato la innovación?
¿Quien mato la innovación?
 
Career: A Shorex Career - a Visual Review 2015
Career: A Shorex Career - a Visual Review 2015Career: A Shorex Career - a Visual Review 2015
Career: A Shorex Career - a Visual Review 2015
 
Camara indiscreta del norte julio 2015
Camara indiscreta del norte julio 2015Camara indiscreta del norte julio 2015
Camara indiscreta del norte julio 2015
 
Els plecs i les falles
Els plecs i les fallesEls plecs i les falles
Els plecs i les falles
 
09.09 09.10.2009 - Presentation of Pré-sal E&P Executive Manager, José Mira...
09.09   09.10.2009 - Presentation of Pré-sal E&P Executive Manager, José Mira...09.09   09.10.2009 - Presentation of Pré-sal E&P Executive Manager, José Mira...
09.09 09.10.2009 - Presentation of Pré-sal E&P Executive Manager, José Mira...
 
Conceptos..
Conceptos..Conceptos..
Conceptos..
 
Using WordPress Blogging Features to Build a Website
Using WordPress Blogging Features to Build a WebsiteUsing WordPress Blogging Features to Build a Website
Using WordPress Blogging Features to Build a Website
 
Sitio web exitoso para Ventas por Internet
Sitio web exitoso para Ventas por InternetSitio web exitoso para Ventas por Internet
Sitio web exitoso para Ventas por Internet
 
Tutorial bitstrips
Tutorial bitstripsTutorial bitstrips
Tutorial bitstrips
 
Reglamento futbol events
Reglamento futbol eventsReglamento futbol events
Reglamento futbol events
 

Semelhante a OOP Is More Than Cars and Dogs

Coming to Terms with OOP In Drupal - php[world] 2016
Coming to Terms with OOP In Drupal - php[world] 2016Coming to Terms with OOP In Drupal - php[world] 2016
Coming to Terms with OOP In Drupal - php[world] 2016Chris Tankersley
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)arcware
 
Be pragmatic, be SOLID (at Boiling Frogs, Wrocław)
Be pragmatic, be SOLID (at Boiling Frogs, Wrocław)Be pragmatic, be SOLID (at Boiling Frogs, Wrocław)
Be pragmatic, be SOLID (at Boiling Frogs, Wrocław)Krzysztof Menżyk
 
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Mike Schinkel
 
PHP 5.3 Overview
PHP 5.3 OverviewPHP 5.3 Overview
PHP 5.3 Overviewjsmith92
 
DDD on example of Symfony (Webcamp Odessa 2014)
DDD on example of Symfony (Webcamp Odessa 2014)DDD on example of Symfony (Webcamp Odessa 2014)
DDD on example of Symfony (Webcamp Odessa 2014)Oleg Zinchenko
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5Darren Craig
 
4Developers 2015: Be pragmatic, be SOLID - Krzysztof Menżyk
4Developers 2015: Be pragmatic, be SOLID - Krzysztof Menżyk4Developers 2015: Be pragmatic, be SOLID - Krzysztof Menżyk
4Developers 2015: Be pragmatic, be SOLID - Krzysztof MenżykPROIDEA
 
Clean code for WordPress
Clean code for WordPressClean code for WordPress
Clean code for WordPressmtoppa
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For BeginnersJonathan Wage
 
Drupal 8 simple page: Mi primer proyecto en Drupal 8.
Drupal 8 simple page: Mi primer proyecto en Drupal 8.Drupal 8 simple page: Mi primer proyecto en Drupal 8.
Drupal 8 simple page: Mi primer proyecto en Drupal 8.Samuel Solís Fuentes
 
Save time by applying clean code principles
Save time by applying clean code principlesSave time by applying clean code principles
Save time by applying clean code principlesEdorian
 
Iterators & generators: practical uses in memory management
Iterators & generators: practical uses in memory managementIterators & generators: practical uses in memory management
Iterators & generators: practical uses in memory managementAdrian Cardenas
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐいHisateru Tanaka
 
PHPID online Learning #6 Migration from procedural to OOP
PHPID online Learning #6 Migration from procedural to OOPPHPID online Learning #6 Migration from procedural to OOP
PHPID online Learning #6 Migration from procedural to OOPAchmad Mardiansyah
 
PHP: 4 Design Patterns to Make Better Code
PHP: 4 Design Patterns to Make Better CodePHP: 4 Design Patterns to Make Better Code
PHP: 4 Design Patterns to Make Better CodeSWIFTotter Solutions
 
Migration from Procedural to OOP
Migration from Procedural to OOP Migration from Procedural to OOP
Migration from Procedural to OOP GLC Networks
 

Semelhante a OOP Is More Than Cars and Dogs (20)

Coming to Terms with OOP In Drupal - php[world] 2016
Coming to Terms with OOP In Drupal - php[world] 2016Coming to Terms with OOP In Drupal - php[world] 2016
Coming to Terms with OOP In Drupal - php[world] 2016
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
 
Be pragmatic, be SOLID (at Boiling Frogs, Wrocław)
Be pragmatic, be SOLID (at Boiling Frogs, Wrocław)Be pragmatic, be SOLID (at Boiling Frogs, Wrocław)
Be pragmatic, be SOLID (at Boiling Frogs, Wrocław)
 
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
 
PHP 5.3 Overview
PHP 5.3 OverviewPHP 5.3 Overview
PHP 5.3 Overview
 
DDD on example of Symfony (Webcamp Odessa 2014)
DDD on example of Symfony (Webcamp Odessa 2014)DDD on example of Symfony (Webcamp Odessa 2014)
DDD on example of Symfony (Webcamp Odessa 2014)
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5
 
4Developers 2015: Be pragmatic, be SOLID - Krzysztof Menżyk
4Developers 2015: Be pragmatic, be SOLID - Krzysztof Menżyk4Developers 2015: Be pragmatic, be SOLID - Krzysztof Menżyk
4Developers 2015: Be pragmatic, be SOLID - Krzysztof Menżyk
 
Be pragmatic, be SOLID
Be pragmatic, be SOLIDBe pragmatic, be SOLID
Be pragmatic, be SOLID
 
Fatc
FatcFatc
Fatc
 
Clean code for WordPress
Clean code for WordPressClean code for WordPress
Clean code for WordPress
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For Beginners
 
Drupal 8 simple page: Mi primer proyecto en Drupal 8.
Drupal 8 simple page: Mi primer proyecto en Drupal 8.Drupal 8 simple page: Mi primer proyecto en Drupal 8.
Drupal 8 simple page: Mi primer proyecto en Drupal 8.
 
Save time by applying clean code principles
Save time by applying clean code principlesSave time by applying clean code principles
Save time by applying clean code principles
 
Iterators & generators: practical uses in memory management
Iterators & generators: practical uses in memory managementIterators & generators: practical uses in memory management
Iterators & generators: practical uses in memory management
 
Modern php
Modern phpModern php
Modern php
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
PHPID online Learning #6 Migration from procedural to OOP
PHPID online Learning #6 Migration from procedural to OOPPHPID online Learning #6 Migration from procedural to OOP
PHPID online Learning #6 Migration from procedural to OOP
 
PHP: 4 Design Patterns to Make Better Code
PHP: 4 Design Patterns to Make Better CodePHP: 4 Design Patterns to Make Better Code
PHP: 4 Design Patterns to Make Better Code
 
Migration from Procedural to OOP
Migration from Procedural to OOP Migration from Procedural to OOP
Migration from Procedural to OOP
 

Mais de Chris Tankersley

Docker is Dead: Long Live Containers
Docker is Dead: Long Live ContainersDocker is Dead: Long Live Containers
Docker is Dead: Long Live ContainersChris Tankersley
 
Bend time to your will with git
Bend time to your will with gitBend time to your will with git
Bend time to your will with gitChris Tankersley
 
Using PHP Functions! (Not those functions, Google Cloud Functions)
Using PHP Functions! (Not those functions, Google Cloud Functions)Using PHP Functions! (Not those functions, Google Cloud Functions)
Using PHP Functions! (Not those functions, Google Cloud Functions)Chris Tankersley
 
Dead Simple APIs with OpenAPI
Dead Simple APIs with OpenAPIDead Simple APIs with OpenAPI
Dead Simple APIs with OpenAPIChris Tankersley
 
Killer Docker Workflows for Development
Killer Docker Workflows for DevelopmentKiller Docker Workflows for Development
Killer Docker Workflows for DevelopmentChris Tankersley
 
Docker for Developers - PHP Detroit 2018
Docker for Developers - PHP Detroit 2018Docker for Developers - PHP Detroit 2018
Docker for Developers - PHP Detroit 2018Chris Tankersley
 
BASHing at the CLI - Midwest PHP 2018
BASHing at the CLI - Midwest PHP 2018BASHing at the CLI - Midwest PHP 2018
BASHing at the CLI - Midwest PHP 2018Chris Tankersley
 
You Were Lied To About Optimization
You Were Lied To About OptimizationYou Were Lied To About Optimization
You Were Lied To About OptimizationChris Tankersley
 
Docker for PHP Developers - php[world] 2017
Docker for PHP Developers - php[world] 2017Docker for PHP Developers - php[world] 2017
Docker for PHP Developers - php[world] 2017Chris Tankersley
 
Docker for PHP Developers - Madison PHP 2017
Docker for PHP Developers - Madison PHP 2017Docker for PHP Developers - Madison PHP 2017
Docker for PHP Developers - Madison PHP 2017Chris Tankersley
 
Docker for Developers - php[tek] 2017
Docker for Developers - php[tek] 2017Docker for Developers - php[tek] 2017
Docker for Developers - php[tek] 2017Chris Tankersley
 
Why Docker? Dayton PHP, April 2017
Why Docker? Dayton PHP, April 2017Why Docker? Dayton PHP, April 2017
Why Docker? Dayton PHP, April 2017Chris Tankersley
 
From Docker to Production - SunshinePHP 2017
From Docker to Production - SunshinePHP 2017From Docker to Production - SunshinePHP 2017
From Docker to Production - SunshinePHP 2017Chris Tankersley
 
Docker for Developers - Sunshine PHP
Docker for Developers - Sunshine PHPDocker for Developers - Sunshine PHP
Docker for Developers - Sunshine PHPChris Tankersley
 
How We Got Here: A Brief History of Open Source
How We Got Here: A Brief History of Open SourceHow We Got Here: A Brief History of Open Source
How We Got Here: A Brief History of Open SourceChris Tankersley
 
Docker for PHP Developers - ZendCon 2016
Docker for PHP Developers - ZendCon 2016Docker for PHP Developers - ZendCon 2016
Docker for PHP Developers - ZendCon 2016Chris Tankersley
 
From Docker to Production - ZendCon 2016
From Docker to Production - ZendCon 2016From Docker to Production - ZendCon 2016
From Docker to Production - ZendCon 2016Chris Tankersley
 

Mais de Chris Tankersley (20)

Docker is Dead: Long Live Containers
Docker is Dead: Long Live ContainersDocker is Dead: Long Live Containers
Docker is Dead: Long Live Containers
 
Bend time to your will with git
Bend time to your will with gitBend time to your will with git
Bend time to your will with git
 
Using PHP Functions! (Not those functions, Google Cloud Functions)
Using PHP Functions! (Not those functions, Google Cloud Functions)Using PHP Functions! (Not those functions, Google Cloud Functions)
Using PHP Functions! (Not those functions, Google Cloud Functions)
 
Dead Simple APIs with OpenAPI
Dead Simple APIs with OpenAPIDead Simple APIs with OpenAPI
Dead Simple APIs with OpenAPI
 
Killer Docker Workflows for Development
Killer Docker Workflows for DevelopmentKiller Docker Workflows for Development
Killer Docker Workflows for Development
 
You Got Async in my PHP!
You Got Async in my PHP!You Got Async in my PHP!
You Got Async in my PHP!
 
Docker for Developers - PHP Detroit 2018
Docker for Developers - PHP Detroit 2018Docker for Developers - PHP Detroit 2018
Docker for Developers - PHP Detroit 2018
 
Docker for Developers
Docker for DevelopersDocker for Developers
Docker for Developers
 
They are Watching You
They are Watching YouThey are Watching You
They are Watching You
 
BASHing at the CLI - Midwest PHP 2018
BASHing at the CLI - Midwest PHP 2018BASHing at the CLI - Midwest PHP 2018
BASHing at the CLI - Midwest PHP 2018
 
You Were Lied To About Optimization
You Were Lied To About OptimizationYou Were Lied To About Optimization
You Were Lied To About Optimization
 
Docker for PHP Developers - php[world] 2017
Docker for PHP Developers - php[world] 2017Docker for PHP Developers - php[world] 2017
Docker for PHP Developers - php[world] 2017
 
Docker for PHP Developers - Madison PHP 2017
Docker for PHP Developers - Madison PHP 2017Docker for PHP Developers - Madison PHP 2017
Docker for PHP Developers - Madison PHP 2017
 
Docker for Developers - php[tek] 2017
Docker for Developers - php[tek] 2017Docker for Developers - php[tek] 2017
Docker for Developers - php[tek] 2017
 
Why Docker? Dayton PHP, April 2017
Why Docker? Dayton PHP, April 2017Why Docker? Dayton PHP, April 2017
Why Docker? Dayton PHP, April 2017
 
From Docker to Production - SunshinePHP 2017
From Docker to Production - SunshinePHP 2017From Docker to Production - SunshinePHP 2017
From Docker to Production - SunshinePHP 2017
 
Docker for Developers - Sunshine PHP
Docker for Developers - Sunshine PHPDocker for Developers - Sunshine PHP
Docker for Developers - Sunshine PHP
 
How We Got Here: A Brief History of Open Source
How We Got Here: A Brief History of Open SourceHow We Got Here: A Brief History of Open Source
How We Got Here: A Brief History of Open Source
 
Docker for PHP Developers - ZendCon 2016
Docker for PHP Developers - ZendCon 2016Docker for PHP Developers - ZendCon 2016
Docker for PHP Developers - ZendCon 2016
 
From Docker to Production - ZendCon 2016
From Docker to Production - ZendCon 2016From Docker to Production - ZendCon 2016
From Docker to Production - ZendCon 2016
 

Último

Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 

Último (20)

Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

OOP Is More Than Cars and Dogs

  • 1. OOP is More Than Cars and Dogs Chris  Tankersley   MadisonPHP  2015   MadisonPHP  2015   1  
  • 2. Who Am I •  PHP  Programmer  for  over  10  years   •  Work/know  a  lot  of  different   languages,  even  COBOL   •  Primarily  do  Zend  Framework  2   •  hGps://github.com/dragonmantank   MadisonPHP  2015   2  
  • 3. Quick Vocabulary Lesson •  Class  –  DefiniPon  of  code   •  Object  –  InstanPaPon  of  a  Class   •  Member  –  Variable  belonging  to  a  class   •  Method  –  FuncPon  belonging  to  a  class   There  will  be  more  as  we  go  along   MadisonPHP  2015   3  
  • 4. MadisonPHP  2015   4   Class class Employee { protected $name; // This is a member protected $number; // This is a Method public function setData($data) { $this->name = $data['name']; $this->number = $data['number']; } public function viewData() { echo <<<ENDTEXT Name: {$this->name} Number: {$this->number} ENDTEXT; } }
  • 5. Object <?php! ! $manager= new Manager();! // ^! // |! // `--- This is the Object   MadisonPHP  2015   5  
  • 6. Why are we using OOP? MadisonPHP  2015   6  
  • 7. Let’s count the reasons •  Because  we’re  told  to,  procedural  programming  leads  to  spagheX   code   •  We  deal  with  objects  every  day,  so  it  shouldn’t  be  too  hard   •  We  want  to  allow  for  code  re-­‐use   •  We  want  to  group  like  code  together   •  We  want  to  easily  extend  our  code   •  We  want  to  be  able  to  easily  test  our  code   MadisonPHP  2015   7  
  • 8. Getting OOP Right is Complicated MadisonPHP  2015   8  
  • 15. Can a Dog have Wheels? MadisonPHP  2015   15  
  • 17. What we’re all taught •  Classes  are  “things”  in  the  real  world   •  We  should  construct  class  members  based  on  AGributes   •  Number  of  wheels   •  Sound  it  makes   •  We  should  construct  class  methods  based  on  “AcPons”   •  Running   •  Speaking   •  Jumping   MadisonPHP  2015   17  
  • 18. New Vocabulary •  Parent  Class  –  Class  that  is  extended   •  Child  Class  –  Class  that  is  extending  another  class   In  PHP,  a  class  can  be  both  a  Child  and  a  Parent  at  the  same  Pme   MadisonPHP  2015   18  
  • 19. Where I Learned It MadisonPHP  2015   19  
  • 20. Our Structure MadisonPHP  2015   20   Employee   Manager   ScienPst   Laborer  
  • 21. The Employee Class MadisonPHP  2015   21   abstract class Employee { protected $name; // Employee Name protected $number; // Employee Number public function setData($data) { $this->name = $data['name']; $this->number = $data['number']; } public function viewData() { echo <<<ENDTEXT Name: {$this->name} Number: {$this->number} ENDTEXT; } }
  • 22. The Manager Class MadisonPHP  2015   22   class Manager extends Employee { protected $title; // Employee Title protected $dues; // Golf Dues public function setData($data) { parent::setData($data); $this->title = $data['title']; $this->dues = $data['dues']; } public function viewData() { parent::viewData(); echo <<<ENDTEXT Title: {$this->title} Golf Dues: {$this->dues} ENDTEXT; } }
  • 23. The Scientist Class MadisonPHP  2015   23   class Scientist extends Employee { protected $pubs; // Number of Publications public function setData($data) { parent::setData($data); $this->pubs = $data['pubs']; } public function viewData() { parent::viewData(); echo <<<ENDTEXT Publications: {$this->pubs} ENDTEXT; } }
  • 24. The Laborer Class MadisonPHP  2015   24   class Laborer extends Employee { }
  • 25. What does this teach us? •  Inheritance   •  Makes  it  easier  to  group  code  together  and  share  it  amongst  classes   •  Allows  us  to  extend  code  as  needed   •  PHP  allows  Single  inheritance   MadisonPHP  2015   25  
  • 26. We use it all the time namespace ApplicationController;! ! use ZendMvcControllerAbstractActionController;! use ZendViewModelViewModel;! ! Class IndexController extends AbstractActionController {! public function indexAction() {! /** @var VendorVendorService $vendor */! $vendor = $this->serviceLocator->get('VendorVendorService');! ! $view = new ViewModel();! return $view;! }! }   MadisonPHP  2015   26  
  • 27. Why it Works (Most of the time, Kinda) •  Allows  us  to  extend  things  we  didn’t  necessarily  create   •  Encourages  code  re-­‐use   •  Allows  developers  to  abstract  away  things   MadisonPHP  2015   27  
  • 28. How to use it •  Understand  the  difference  between  Public,  Protected,  and  Private   •  Public  –  Anyone  can  use  this,  even  children   •  Protected  –  Anything  internal  can  use  this,  even  children   •  Private  –  This  is  mine,  hands  off   •  Abstract  vs  Concrete  Classes   •  Abstract  classes  cannot  be  instanPated  directly,  they  must  be  extended   MadisonPHP  2015   28  
  • 29. The Employee Class MadisonPHP  2015   29   abstract class Employee { protected $name; // Employee Name protected $number; // Employee Number public function setData($data) { $this->name = $data['name']; $this->number = $data['number']; } public function viewData() { echo <<<ENDTEXT Name: {$this->name} Number: {$this->number} ENDTEXT; } }
  • 30. The Manager Class MadisonPHP  2015   30   class Manager extends Employee { protected $title; // Employee Title protected $dues; // Golf Dues public function setData($data) { parent::setData($data); $this->title = $data['title']; $this->dues = $data['dues']; } public function viewData() { parent::viewData(); echo <<<ENDTEXT Title: {$this->title} Golf Dues: {$this->dues} ENDTEXT; } }
  • 31. An Example // Fatal error: Cannot instantiate abstract class Employee! $employee = new Employee(); ! ! // We can do this though!! $manager = new Manager(); ! ! // Fatal error: Cannot access protected property Manager::$name! $manager->name = 'Bob McManager’;! ! // setData is public, so we can use that! $manager->setData(['name' => 'Bob McManager’,'number' => 1]);! ! // We can also view the data, since it's public! $manager->viewData();   MadisonPHP  2015   31  
  • 32. Why can Inheritance Be Bad •  PHP  only  allows  Single  Inheritance  on  an  Class   •  You  can  have  a  series  of  Inheritance  though,  for  example  CEO  extends   Manager,  Manager  extends  Employee   •  Long  inheritance  chains  can  be  a  code  smell   •  Private  members  and  methods  cannot  be  used  by  Child  classes   •  Single  Inheritance  can  make  it  hard  to  ‘bolt  on’  new  funcPonality   between  disparate  classes   MadisonPHP  2015   32  
  • 34. The General Idea •  Classes  contain  other  classes  to  do  work  and  extend  that  way,  instead   of  through  Inheritance   •  Interfaces  define  “contracts”  that  objects  will  adhere  to   •  Your  classes  implement  interfaces  to  add  needed  funcPonality   MadisonPHP  2015   34  
  • 35. Interfaces interface EmployeeInterface {! protected $name;! protected $number;! ! public function getName();! public function setName($name);! public function getNumber();! public function setNumber($number);! }! ! interface ManagerInterface {! protected $golfHandicap;! ! public function getHandicap();! public function setHandicap($handicap);! }   MadisonPHP  2015   35  
  • 36. Interface Implementation class Employee implements EmployeeInterface {! public function getName() {! return $this->name;! }! public function setName($name) {! $this->name = $name;! }! }! class Manager implements EmployeeInterface, ManagerInterface {! // defines the employee getters/setters as well! public function getHandicap() {! return $this->handicap; ! }! public function setHandicap($handicap) {! $this->handicap = $handicap;! }! }   MadisonPHP  2015   36  
  • 37. This is Good and Bad •  “HAS-­‐A”  is  tends  to  be  more  flexible  than  “IS-­‐A”   •  Somewhat  easier  to  understand,  since  there  isn’t  a  hierarchy  you   have  to  backtrack     •  Each  class  must  provide  their  own  ImplementaPon,  so  can  lead  to   code  duplicaPon   MadisonPHP  2015   37  
  • 38. Traits •  Allows  small  blocks  of  code  to  be  defined  that  can  be  used  by  many   classes   •  Useful  when  abstract  classes/inheritance  would  be  cumbersome   •  My  Posts  and  Pages  classes  shouldn’t  need  to  extend  a  Slugger  class  just  to   generate  slugs.     MadisonPHP  2015   38  
  • 39. Avoid Code-Duplication with Traits trait EmployeeTrait {! public function getName() {! return $this->name;! }! public function setName($name) {! $this->name = $name;! }! }! class Employee implements EmployeeInterface {! use EmployeeTrait;! }! class Manager implements EmployeeInterface, ManagerInterface {! use EmployeeTrait;! use ManagerTrait;! }   MadisonPHP  2015   39  
  • 40. Taking Advantage of OOP MadisonPHP  2015   40  
  • 42. What is Coupling? •  Coupling  is  how  dependent  your  code  is  on  another  class   •  The  more  classes  you  are  coupled  to,  the  more  changes  affect  your   class   MadisonPHP  2015   42  
  • 43. namespace ApplicationController;! ! use ZendMvcControllerAbstractActionController;! use ZendViewModelViewModel;! ! class MapController extends AbstractActionController! {! public function indexAction()! {! // Position is an array with a Latitude and Longitude object! $position = $this->getServiceLocator()->get('MapService’)! ->getLatLong('123 Main Street', 'Defiance', 'OH');! echo $position->latitude->getPoint();! }! }   MadisonPHP  2015   43  
  • 44. Law of Demeter MadisonPHP  2015   44  
  • 46. What is Dependency Injection? •  InjecPng  dependencies  into  classes,  instead  of  having  the  class  create   it   •  Allows  for  much  easier  tesPng   •  Allows  for  a  much  easier  Pme  swapping  out  code   •  Reduces  the  coupling  that  happens  between  classes   MadisonPHP  2015   46  
  • 47. Method Injection class MapService {! public function getLatLong(GoogleMaps $map, $street, $city, $state) {! return $map->getLatLong($street . ' ' . $city . ' ' . $state);! }! ! public function getAddress(GoogleMaps $map, $lat, $long) {! return $map->getAddress($lat, $long);! }! }   MadisonPHP  2015   47  
  • 48. Constructor Injection class MapService {! protected $map;! public function __construct(GoogleMaps $map) {! $this->map = $map;! }! public function getLatLong($street, $city, $state) {! return $this! ->map! ->getLatLong($street . ' ' . $city . ' ' . $state);! }! }! !   MadisonPHP  2015   48  
  • 49. Setter Injection class MapService {! protected $map;! ! public function setMap(GoogleMaps $map) {! $this->map = $map;! }! public function getMap() {! return $this->map;! }! public function getLatLong($street, $city, $state) {! return $this->getMap()->getLatLong($street . ' ' . $city . ' ' . $state);! }! }!   MadisonPHP  2015   49  
  • 51. Single Responsibility Principle •  Every  class  should  have  a  single  responsibility,  and  that  responsibility   should  be  encapsulated  in  that  class   MadisonPHP  2015   51  
  • 52. What is a Responsibility? •  Responsibility  is  a  “Reason  To  Change”  –  Robert  C.  MarPn   •  By  having  more  than  one  “Reason  to  Change”,  code  is  harder  to   maintain  and  becomes  coupled   •  Since  the  class  is  coupled  to  mulPple  responsibiliPes,  it  becomes   harder  for  the  class  to  adapt  to  any  one  responsibility     MadisonPHP  2015   52  
  • 53. An Example /** * Create a new invoice instance. * * @param LaravelCashierContractsBillable $billable * @param object * @return void */ public function __construct(BillableContract $billable, $invoice) { $this->billable = $billable; $this->files = new Filesystem; $this->stripeInvoice = $invoice; } /** * Create an invoice download response. * * @param array $data * @param string $storagePath * @return SymfonyComponentHttpFoundationResponse */ public function download(array $data, $storagePath = null) { $filename = $this->getDownloadFilename($data['product']); $document = $this->writeInvoice($data, $storagePath); $response = new Response($this->files->get($document), 200, [ 'Content-Description' => 'File Transfer', 'Content-Disposition' => 'attachment; filename="'.$filename.'"', 'Content-Transfer-Encoding' => 'binary', 'Content-Type' => 'application/pdf', ]); $this->files->delete($document); return $response; } MadisonPHP  2015   53   hGps://github.com/laravel/cashier/blob/master/src/Laravel/Cashier/Invoice.php  
  • 54. Why is this Bad? •  This  single  class  has  the  following  responsibiliPes:   •  GeneraPng  totals  for  the  invoice  (including  discounts/coupons)   •  GeneraPng  an  HTML  View  of  the  invoice  (Invoice::view())   •  GeneraPng  a  PDF  download  of  the  invoice(Invoice::download())   •  This  is  coupled  to  a  shell  script  as  well   •  Two  different  displays  handled  by  the  class.  Adding  more  means   more  responsibility   •  Coupled  to  a  specific  HTML  template,  the  filesystem,  the  Laravel   Views  system,  and  PhantomJS  via  the  shell  script   MadisonPHP  2015   54  
  • 55. How to Improve •  Change  responsibility  to  just  building  the  invoice  data   •  Move  the  ‘output’  stuff  to  other  classes   MadisonPHP  2015   55  
  • 57. [Could  not  afford  licensing  fee  for  Grumpy  TesPng  Picture]   MadisonPHP  2015   57  
  • 58. This is not a testing talk •  Using  Interfaces  makes  it  easier  to  mock  objects   •  Reducing  coupling  and  following  Demeter’s  Law  makes  you  have  to   mock  less  objects   •  Dependency  InjecPon  means  you  only  mock  what  you  need  for  that   test   •  Single  Responsibility  means  your  test  should  be  short  and  sweet   •  Easier  tesPng  leads  to  more  tesPng   MadisonPHP  2015   58  
  • 60. We can make a dog with wheels! •  Abstract  class  for  Animal   •  Class  for  Dog  that  extends  Animal   •  Trait  for  Wheels   •  With  the  write  methodology,  we  could  even  unit  test  this   In  the  real  world,  we  can  now  represent  a  crippled  dog   MadisonPHP  2015   60  
  • 61. Here’s a cute dog instead MadisonPHP  2015   61  
  • 62. Additional Resources •  Clean  Code  –  Robert  C.  MarPn   •  PHP  Objects,  PaGerns,  and  PracPce  –  MaG  Zandstra   MadisonPHP  2015   62  
  • 63. Thank You! hGp://ctankersley.com   chris@ctankersley.com   @dragonmantank     hGps://joind.in/16010   MadisonPHP  2015   63  
  • 64. Photos •  Slide  9  -­‐  hGp://bit.ly/1dkaoxS   •  Slide  10  -­‐  hGp://bit.ly/1c4Gc8z   •  Slide  11  -­‐  hGp://bit.ly/1R3isBp   •  Slide  12  -­‐  hGp://bit.ly/1ScEWRZ   •  Slide  13  -­‐  hGp://bit.ly/1Bc0qUv   •  Slide  14  -­‐  hGp://bit.ly/1ILhfNV   •  Slide  15  -­‐  hGp://bit.ly/1SeekA7     MadisonPHP  2015   64