SlideShare uma empresa Scribd logo
1 de 41
Baixar para ler offline
#4




Object Oriented Programming with PHP 5
                        Design Patterns
                             Doc. v. 0.1 - 19/03/09




                  Wildan Maulana | wildan [at] tobethink.com
About Design Pattern
• Design Patterns was introduced by
  Eric Gamma and his three other
  friends in the book Design Patterns, in
  1972
• You might have done one of this
  before ...
Design Patterns
    Strategy Pattern
•
    Factory Pattern
•
    Abstract Factory
•
    Adapter Pattern
•
    Singleton Pattern
•
    Iterator Pattern
•
    Observer Pattern
•
    Proxy Pattern or Lazy Loading
•
    Decorator Pattern
•
    Facade Pattern
•
Strategy Pattern
• Strategy pattern is a common pattern
  helps us make decisions on different
  case, more easily.
Strategy Pattern Example
                   Context



                   Strategy




Email Notifier   SMS Notifier   Fax Notifier
<?php                             <?php
 //notifier.interface.php          //emailnotifier.class.php
 interface notifier                include_once(quot;notifier.interface.phpquot;);
 {                                 class EmailNotifier implements notifier
    public function notify();      {
 }                                    public function notify()
 ?>                                   {
                                        //do something to notify the user by Email
                                      }
                                   }
                                   ?>
<?php
                                                <?php
//faxnotifier.class.php
                                                smsnotifier.class.php
include_once(quot;notifier.interface.phpquot;);
class FaxNotifier implements notifier
                                                include_once(quot;notifier.interface.phpquot;);
{
                                                class SMSNotifier implements notifier
   public function notify()
                                                {
   {
                                                  public function notify()
     //do something to notify the user by Fax
                                                  {
   }
                                                    //do something to notify the user by SMS
}
                                                  }
?>
                                                }
<?php
include_once(quot;emailnotifier.class.phpquot;);
include_once(quot;faxnotifier.class.phpquot;);
include_once(quot;smsnotifier.class.phpquot;);
/**
  * Let's create a mock object User which we assume has a method named
  * getNotifier(). This method returns either quot;smsquot; or quot;faxquot; or quot;emailquot;
  */
$user = new User();
$notifier = $user->getNotifier();
switch ($notifier)
{
   case quot;emailquot;:
     $objNotifier = new EmailNotifier();
     break;
   case quot;smsquot;:
     $objNotifier = new SMSNotifier();
     break;
   case quot;faxquot;:
     $objNotifier = new FaxNotifier();
   break;
}
$objNotifier->notify();
?>
Factory Pattern
• The main goal of factory pattern is delivering
  an object by hiding all the complexities behind
  it.
• Example :
Before using Factory Pattern
<?php                                  <?php
class MySQLManager                     class PostgreSQLManager                How we use this class :
{                                      {
  public function setHost($host)         public function setHost($host)
  {                                      {                                    <?php
    //set db host
                                           //set db host                      $MM = new MySQLManager();
  }                                                                           $MM->setHost(quot;hostquot;);
                                         }
  public function setDB($db)                                                  $MM->setDB(quot;dbquot;);
                                         public function setDB($db)
  {                                                                           $MM->setUserName(quot;userquot;);
                                         {
    //set db name                                                             $MM->setPassword(quot;pwdquot;);
                                           //set db name
  }                                                                           $MM->connect();
                                         }
  public function setUserName($user)                                          ?>
                                         public function setUserName($user)
  {
                                                                              <?php
                                         {
    //set user name
                                                                              $PM = new PostgreSQLManager();
  }                                        //set user name                    $PM->setHost(quot;hostquot;);
  public function setPassword($pwd)      }                                    $PM->setDB(quot;dbquot;);
  {                                      public function setPassword($pwd)    $PM->setUserName(quot;userquot;);
    //set password                       {                                    $PM->setPassword(quot;pwdquot;);
  }                                                                           $PM->connect();
                                           //set password
  public function connect()                                                   ?>
                                         }
  {
                                         public function connect()
                                                                                Merge them ...
    //now connect
                                         {
  }
                                           //now connect
}                                                                             <?php
                                         }
?>                                                                             If ($dbtype==quot;mysqlquot;)
                                       }                                       //use mysql class
                                       ?>                                      Else if ($dbtype==quot;postgresqlquot;)
                                                                               //use postgresql class
                                                                              ?>
<?php
class DBManager
                                              How to use it ....
{
  public static function setDriver($driver)
  {
                                              <?php
    $this->driver = $driver;
  //set the driver                            $DM = new DBManager();
  }
                                              $DM->setDriver(quot;mysqlquot;);
  public static function connect()
                                              $DM->connect(quot;hostquot;,quot;userquot;,quot;dbquot;,quot;pwdquot;);
  {
    if ($this->driver==quot;mysqlquot;)
                                              ?>
    {
      $MM = new MySQLManager();
      $MM->setHost(quot;hostquot;);
                                                                               Context
      $MM->setDB(quot;dbquot;);
      $MM->setUserName(quot;userquot;);
                                              The DBManager now works
      $MM->setPassword(quot;pwdquot;);
      $this->connection = $MM->connect();
                                              as a Factory ......
    }
                                                                               Factory
    else if($this->driver==quot;pgsqlquot;)
    {
      $PM = new PostgreSQLManager();
      $PM->setHost(quot;hostquot;);
                                                                          Concrete product
      $PM->setDB(quot;dbquot;);
      $PM->setUserName(quot;userquot;);
      $PM->setPassword(quot;pwdquot;);
      $this->connection= $PM->connect();
    }
                                                                           Database driver
  }
}
?>
Abstract Factory Pattern
• Abstract Factory is almost similar to Factory,
  the only difference is that all your concrete
  objects must extend a common abstract class.

• One major benefit is that we define all the
  necessary functions in a single place, which is
  present in all derived classes with the same
  standard. We can also encapsulate common
  functions/procedures in the abstract class.
<?php
<?php
                                       class MySQLManager extends DBDriver
abstract class DBDriver
                                       {
{
                                         public function connect()
  public function connect();             {
  public function executeQuery();          //implement own connection procedures
  public function insert_id();           }
  public function setHost($host)         public function executeQuery()
  {                                      {
                                           //execute mysql query and return result
    //set db host
                                         }
  }
                                         public function insertId()
  public function setDB($db)             {
  {                                        //find the latest inserted id
    //set db name                        }
  }                                    }
  public function setUserName($user)   ?>
  {
    //set user name
                                       Later we will use this MySQLManager class
  }
  public function setPassword($pwd)    as usual in our DBManager...
  {
    //set password
  }
  //.....
}
?>
Abstract Pattern
                      Context


                      Factory


                  Concrete Product


Database driver                      Database driver




                     Abstract
                  Database driver
Adapter Pattern
• Adapter is actually an object that acts like an adapter in real
  life, in that it converts one thing to another. Using Adapter
  you can convert electric sources from higher to lower volts.
  Similarly in OOP, using Adapter pattern, one object can fit for
  the same methods of another object.

   Context          Doc Manager




                    Google Doc
                                                 Writely
                     Adapter
<?php
   <?php                                                      interface DocManager
   class Writely implements DocManager()                      {
   {                                                            public function authenticate($user, $pwd);
     public function authenticate($user, $pwd)                  public function getDocuments($folderid);
     {                                                          public function getDocumentsByType($folderid, $type);
       //authenticate using Writely authentication scheme       public function getFolders($folderid=null);
                                                                public function saveDocument($document);
     }
                                                              }
     public function getDocuments($folderid)
                                                              ?>
     {                                                                <?php
       //get documents available in a folder                          class GoogleDocs
     }                                                                {
     public function getDocumentsByType($folderid, $type)                public function authenticateByClientLogin()
     {                                                                   {
                                                                           //authenticate using Writely authentication scheme
       //get documents of specific type from a folder
                                                                         }
     }
                                                                         public function setUser()
     public function getFolders($folderid=null)
                                                                         {
     {
                                                                           //set user
       //get all folders under a specific folder
                                                                         }
     }
                                                                         public function setPassword()
     public function saveDocuments($document)                            {
     {                                                                     //set password
       //save the document                                               }
     }                                                                   public function getAllDocuments()
   }                                                                     {
   ?>                                                                      //get documents available in a folder
                                                                         }
                                                                         public function getRecentDocuments()
  How to fit Goolgle Docs to our existing code ?                         {
                                                                         }
                                                                         public function getDocument()
We need to develop the wrapper
                                                                         {
object, which implements the same DocManager
                                                                         }
interface but uses the GoogleDoc object to perform the actual
                                                                      }
work.                                                                 ?>
<?php
Class GoogleDocsAdapter implements DocManager
{
                                                                Now we will just instantiate an instance
  private $GD;
                                                                of GoogleDocsAdapter and then use that
  public function __construct()
  {
                                                                instance in our core code.
    $this->GD = new GoogleDocs();
                                                                As it implements the same interface,
  }
  public function authenticate($user, $pwd)
                                                                there is no need to change the core code.
  {
    $this->GD->setUser($user);
    $this->GD->setPwd($pwd);
                                                                This is an example when adapter
    $this->GD->authenticateByClientLogin();
                                                                Pattern can be usefull
  }
  public function getDocuments($folderid)
  {
    return $this->GD->getAllDocuments();
  }
  public function getDocumentsByType($folderid, $type)
  {
      //get documents using GoogleDocs object and return only
      // which match the type
  }
  public function getFolders($folderid=null)
  {
    //for example there is no folder in GoogleDocs, so
    //return anything.
   }
   public function saveDocument($document)
   {
     //save the document using GoogleDocs object
   }
}
?>
Singleton Pattern
    The main purpose of the Singleton pattern is to deliver a single
•
    instance of object no matter how many times you instantiate it.
    That is, if an object is instantiated once, using the Singleton pattern
    you can deliver only that instance when you require it again in your
    code. This saves memory consumption by preventing the creation
    of multiple instances of an object. Thus Singleton pattern is used to
    improve the performance of your application.


         Context            Doc Manager

                                          Singleton is a very important pattern !

                             Google Doc
                                                            Writely
                              Adapter
Singleton Pattern               <?php
                                class MySQLManager
                                {
                                   private static $instance;
<?php                              public function __construct()
$a = new MYSQLManager();           {
$b = new MYSQLManager();             if (!self::$instance)
$c = new MYSQLManager();             {
$d = new MYSQLManager();               self::$instance = $this;
$e = new MYSQLManager();               echo quot;New Instancenquot;;
?>                                     return self::$instance;
                                     }
                                     else
                                     {
                                       echo quot;Old Instancenquot;;
                                       return self::$instance;
                                     }
                 New Instance
                                   }
                 Old Instance
                                //keep other methods same
                 Old Instance
                                }
                 Old Instance
                                ?>
                 Old Instance
Iterator Pattern
• Iterator is a common pattern, which
  helps you to manipulate a collection
  more easily.
Without Iterator Pattern
<?php
$posts = getAllPosts(); //example function return all post ids of this
author
for($i = 0; $i<count($posts); $i++)
{
  $title = getPostTitle($post[$i]);
  echo $title;
  $author = getPostAuthor($post[$i]);
  $content = parseBBCode(getPostContent($post[$i]));
  echo quot;Contentquot;;
  $comments = getAllComments($post[$i]);
  for ($j=0; $j<count($comments); $j++)
  {
    $commentAuthor = getCommentAuthor($comments[$j]);
    echo $commentAuthor;
    $comment = getCommentContent($comments[$j]);
    echo $comment;
  }
}
?>
On the previous example, if we turn the
comments into a collection of comment
object for that post and all the posts
into a collection of post object for easier
accessing, it will remove the burden of
template designing as well as create
manageable code.
Iterator interface in PHP5
                                The rewind() function of Iterator sets the
                            •
<?php
                                index to the start of collection.
interface Iterator
                                The current() returns the current object.
                            •
{
  function rewind();            key() function returns the current key.
                            •
  function current();
                                The function next() returns if there are more
                            •
  function key();
                                object ahead in the current loop counter. If
  function next();
                                the return is yes, this function returns true,
  function valid();
                                otherwise it returns false.
}
                                The valid() function returns the current
                            •
?>
                                object if it has any value in it. Let us create an
                                Iterator for our post object.



            Next ..., the solution for the previous code using Iterator Pattern ...
<?php
class Posts implements Iterator
                                           <?php
{
  private $posts = array();                $blogposts = getAllPosts();
  public function __construct($posts)      $posts = new Posts($posts);
  {                                        foreach ($posts as $post)
    if (is_array($posts)) {                {
      $this->posts = $posts;                 echo $post->getTitle();
    }
                                             echo $post->getAuthor();
  }
                                             echo $post->getDate();
  public function rewind() {
                                             echo $post->getContent();
    reset($this->posts);
                                             $comments = new Comments($post->getComments());
  }
                                             //another Iterator for comments, code is same as Posts
  public function current() {
                                             foreach ($comments as $comment)
    return current($this->posts);
                                             {
  }
                                               echo $comment->getAuthor();
  public function key() {
                                               echo $comment->getContent();
    return key($this->var);
  }                                          }
  public function next() {                 }
    return next($this->var);               ?>
  }
  public function valid() {
    return ($this->current() !== false);
  }
}
?>
Observer Pattern
    An Observer pattern solves a common problem in OOP. For
•
    example, if you want some objects to be notified automatically
    when something happens (an event raised), you can solve that
    problem with this pattern.
    An Observer pattern consists of two types of objects; one is an
•
    observable object, which is observed by observer object. When the
    state of an observable object changes, it notifies all observers
    registered with it.



          Observable                   Observer::notify()




                          Email Notifier             IM Notifier
<?php                                        <?php
 interface observer                           class YMNotifier implements observer
 {                                            {
   public function notify();                     public function notify()
 }                                               {
 ?>                                                //send alerts using YM
                                                   echo quot;Notifying via YMnquot;;
                                                 }
                                              };
<?php
                                              ?>
class observable
{
  private $observers = array();
  public function register($object)
                                                  <?php
  {
    if ($object instanceof observer )             class EmailNotifier implements observer
    $this->observers[] =$object;
                                                  {
    else
                                                     public function notify()
    echo quot;The object must implement
              observer interfacenquot;;
                                                     {
  }
                                                         //send alerts using Email
  public function stateChange()
                                                         echo quot;Notifying via Emailnquot;;
  {
    foreach ($this->observers as $observer)
                                                       }
    {
                                                  };
      $observer->notify();
    }                                             ?>
  }
}
?>
<?php
$postmonitor = new observable();
$ym = new YMNotifier();
$em = new EmailNotifier();
$s= new stdClass();
$postmonitor->register($ym);
$postmonitor->register($em);
$postmonitor->register($s);
$postmonitor->stateChange();              Output
?>




                             The object must implement observer interface
                             Notifying via YM
                             Notifying via Email
Proxy Pattern and
              Lazy Loading
• The main idea of lazy loading is to decrease
  the concrete dependency among objects while
  coding
• Using proxy pattern we can create a local
  version of a remote object. It provides a
  common API for accesing methods of a remote
  object without knowing the things behind the
  scene. The best example of proxy pattern
  could be the XML RPC and Soap client
Proxy Pattern
  Context         Local Object




Remote Object        Proxy
Decorator Pattern

• Decorator pattern is an important problem-solving approach
  introduced by GoF in their legendary design pattern book.
  Using this pattern we can add additional functionalities in an
  existing object without extending an object.
   – But how we can do this without inheritance ?
<?php                                     <?php
class Post                                class Comment
{                                         {
  private $title;                           private $date;
  private $content;                         private $content;
  //additional properties                   //additional properties
  public function filter()                  public function filter()
  {                                         {
    //do necessary processing                 //do necessary processing
    $this->content = $filtered_content;       $this->content = $filtered_content;
    $this->title = $filtered_title;         }
  }                                         public function getContent()
  public function getContent()              {
  {                                           return $this->content;
    return $this->content;                  }
  }                                         //additional methods
  //additional methods                    }
}                                         ?>
?>
The Decorator Objects
<?php
                                                          <?php
class BBCodeParser
                                                          class EmoticonParser
{
                                                          {
  private $post;
                                                            private $post;
  public function __construct($object)
                                                            public function __construct($object)
  {
                                                            {
    $this->post = $object;
                                                              $this->post = $object;
  }
                                                            }
  public function getContent()
                                                            public function getContent()
  {
                                                            {
    //parse bbcode
                                                              //parse bbcode
  $post->filter();
                                                              $post->filter();
    $content = $this->parseBBCode($post->getContent());
                                                              $content = $this->parseEmoticon($post->getContent());
    return $content;
                                                              return $content;
  }
                                                            }
  private function parseBBCode($content)
                                                            private function parseEmoticon($content)
  {
                                                            {
    //process BB code in the content and return it
                                                              //process Emoticon code in the content and return it
  }
                                                            }
}
                                                          }
?>
                                                          ?>
Decorator Pattern in Action
       <?php
       $post = new Post();//set the properties of the post object
       $comment = new Comment();//set the properties of the comment object
       $post->filter();
       $comment->filter();
       if ($BBCodeEnabled==false && $EmoticonEnabled==false)
       {
          $PostContent = $post->getContent();
          $CommentContent = $comment->getContent();
       }
       elseif ($BBCodeEnabled==true && $EmoticonEnabled==false)
       {
          $bb = new BBCodeParser($post);//passing a post object to
                            //BBCodeParser
          $PostContent = $bb->getContent();
          $bb = new BBCodeParser($comment);//passing a comment object to
                               //BBCodeParser
          $CommentContent = $bb->getContent();
       }
       elseif ($BBCodeEnabled==true && $EmoticonEnabled==false)
       {
          $em = new EmoticonParser($post);
          $PostContent = $bb->getContent();
          $em = new EmoticonParser($comment);
          $CommentContent = $bb->getContent();
       }
       ?>
Active Record Pattern
• This is another very important design
  pattern to simplify database
  manipulation
• We will talkl about this topic later, on
  the #7 presentation
Facade Pattern
• Facade provides a common interface to many objects. In
  other words, it just simplifies the programming providing a
  necessary interface, which actually uses a lot of other objects
  behind the scenes. Thus it minimizes the learning curve for
  developers. When a new developer joins the team, he
  suddenly gets introduced to a lot of objects with tons of
  methods and properties, among which he might need a few
  to accomplish his work. So why bother spending time
  learning them all? This is where Facade helps developers and
  saves a lot of their time.
The code structure before using Facade


       Client A                      Client B




Geo Locator       Apartment Finder              Google Map
The code structure after using Facade


              Client A                      Client B




                            Facade




Geo Locator              Apartment Finder              Google Map
The Code
                                                               <?php
<?php                                                          class GeoLocator
class ApartmentFinder                                          {
{                                                                public function getLocations($place)
  public function locateApartments($place)                       {
  {                                                                //use public geo coding service like yahoo and get the
    //use the web service and locate all apartments suitable       //lattitude and
    //search name                                                  //longitude of that place
    //now return them all in an array                              return array(quot;latquot;=>$lattitude, quot;lngquot;=>$longitude);
    return $apartmentsArray();                                   }
  }                                                            }
}                                                              ?>
?>
                                                                <?php
                                                                class GoogleMap
                                                                {
                                                                  public function initialize()
                                                                  {
                                                                    //do initialize
                                                                  }
                                                                  public function drawLocations($locations /* array */)
                                                                  {
                                                                    //locate all the points using Google Map Locator
                                                                  }
                                                                  public function dispatch($divid)
                                                                  {
                                                                    //draw the map with in a div with the div id
                                                                  }
                                                                }
                                                                ?>
The Facade
<?php
class Facade
{
  public function findApartments($place, $divid)
  {
                                                        How to use it ....
    $AF = new ApartmentFinder();
    $GL =new GeoLocator();
                                                      <?php
    $GM = new GoogleMap();                            $F = new Facade();
    $apartments = $AF->locateApartments($place);      $F->findApartments(quot;London, Greater Londonquot;,quot;mapdivquot;);
                                                      ?>
    foreach ($apartments as $apartment)
    {
      $locations[] = $GL->getLocations($apartment);
    }
    $GM->initialize();
    $GM->drawLocations($locations);
    $GM->dispatch($divid);
  }
}
?>
Summary
• Design patterns are an essential part of OOP. It makes
  your code more effective, better performing, and easier
  to maintain
• Altough sometimes we implement these design
  patterns in our code without knowing that these
  solutions are defined as design patterns.
• Use design pattern when you need it
• For more information about design pattern you can
  read Head First Design Patterns published by O'reilly
  and Design Patterns Explained by Addison-Wesley.
Q&A
Reference
• Object Oriented Programming with
  PHP5, Hasin Hayder, PACKT Publishing

Mais conteúdo relacionado

Mais procurados

Decoupling with Design Patterns and Symfony2 DIC
Decoupling with Design Patterns and Symfony2 DICDecoupling with Design Patterns and Symfony2 DIC
Decoupling with Design Patterns and Symfony2 DICKonstantin Kudryashov
 
Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8XSolve
 
The Beauty and the Beast
The Beauty and the BeastThe Beauty and the Beast
The Beauty and the BeastBastian Feder
 
The IoC Hydra - Dutch PHP Conference 2016
The IoC Hydra - Dutch PHP Conference 2016The IoC Hydra - Dutch PHP Conference 2016
The IoC Hydra - Dutch PHP Conference 2016Kacper Gunia
 
Dutch PHP Conference - PHPSpec 2 - The only Design Tool you need
Dutch PHP Conference - PHPSpec 2 - The only Design Tool you needDutch PHP Conference - PHPSpec 2 - The only Design Tool you need
Dutch PHP Conference - PHPSpec 2 - The only Design Tool you needKacper Gunia
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2Hugo Hamon
 
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)James Titcumb
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of LithiumNate Abele
 
Lithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate FrameworksLithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate FrameworksNate Abele
 
Rich Model And Layered Architecture in SF2 Application
Rich Model And Layered Architecture in SF2 ApplicationRich Model And Layered Architecture in SF2 Application
Rich Model And Layered Architecture in SF2 ApplicationKirill Chebunin
 
Functional Structures in PHP
Functional Structures in PHPFunctional Structures in PHP
Functional Structures in PHPMarcello Duarte
 
The Origin of Lithium
The Origin of LithiumThe Origin of Lithium
The Origin of LithiumNate Abele
 
Crafting beautiful software
Crafting beautiful softwareCrafting beautiful software
Crafting beautiful softwareJorn Oomen
 
Dependency Injection with PHP 5.3
Dependency Injection with PHP 5.3Dependency Injection with PHP 5.3
Dependency Injection with PHP 5.3Fabien Potencier
 
Design how your objects talk through mocking
Design how your objects talk through mockingDesign how your objects talk through mocking
Design how your objects talk through mockingKonstantin Kudryashov
 
Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5Leonardo Proietti
 
Introduction to DI(C)
Introduction to DI(C)Introduction to DI(C)
Introduction to DI(C)Radek Benkel
 
Min-Maxing Software Costs - Laracon EU 2015
Min-Maxing Software Costs - Laracon EU 2015Min-Maxing Software Costs - Laracon EU 2015
Min-Maxing Software Costs - Laracon EU 2015Konstantin Kudryashov
 

Mais procurados (20)

Decoupling with Design Patterns and Symfony2 DIC
Decoupling with Design Patterns and Symfony2 DICDecoupling with Design Patterns and Symfony2 DIC
Decoupling with Design Patterns and Symfony2 DIC
 
Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8
 
The Beauty and the Beast
The Beauty and the BeastThe Beauty and the Beast
The Beauty and the Beast
 
The IoC Hydra
The IoC HydraThe IoC Hydra
The IoC Hydra
 
The IoC Hydra - Dutch PHP Conference 2016
The IoC Hydra - Dutch PHP Conference 2016The IoC Hydra - Dutch PHP Conference 2016
The IoC Hydra - Dutch PHP Conference 2016
 
Dutch PHP Conference - PHPSpec 2 - The only Design Tool you need
Dutch PHP Conference - PHPSpec 2 - The only Design Tool you needDutch PHP Conference - PHPSpec 2 - The only Design Tool you need
Dutch PHP Conference - PHPSpec 2 - The only Design Tool you need
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2
 
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of Lithium
 
Lithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate FrameworksLithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate Frameworks
 
Min-Maxing Software Costs
Min-Maxing Software CostsMin-Maxing Software Costs
Min-Maxing Software Costs
 
Rich Model And Layered Architecture in SF2 Application
Rich Model And Layered Architecture in SF2 ApplicationRich Model And Layered Architecture in SF2 Application
Rich Model And Layered Architecture in SF2 Application
 
Functional Structures in PHP
Functional Structures in PHPFunctional Structures in PHP
Functional Structures in PHP
 
The Origin of Lithium
The Origin of LithiumThe Origin of Lithium
The Origin of Lithium
 
Crafting beautiful software
Crafting beautiful softwareCrafting beautiful software
Crafting beautiful software
 
Dependency Injection with PHP 5.3
Dependency Injection with PHP 5.3Dependency Injection with PHP 5.3
Dependency Injection with PHP 5.3
 
Design how your objects talk through mocking
Design how your objects talk through mockingDesign how your objects talk through mocking
Design how your objects talk through mocking
 
Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5
 
Introduction to DI(C)
Introduction to DI(C)Introduction to DI(C)
Introduction to DI(C)
 
Min-Maxing Software Costs - Laracon EU 2015
Min-Maxing Software Costs - Laracon EU 2015Min-Maxing Software Costs - Laracon EU 2015
Min-Maxing Software Costs - Laracon EU 2015
 

Semelhante a Design Patterns in PHP5

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
 
Object Oriented Programming with PHP 5 - More OOP
Object Oriented Programming with PHP 5 - More OOPObject Oriented Programming with PHP 5 - More OOP
Object Oriented Programming with PHP 5 - More OOPWildan Maulana
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For BeginnersJonathan Wage
 
Laying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentLaying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentTammy Hart
 
How Kris Writes Symfony Apps
How Kris Writes Symfony AppsHow Kris Writes Symfony Apps
How Kris Writes Symfony AppsKris Wallsmith
 
Dependency injection in Drupal 8
Dependency injection in Drupal 8Dependency injection in Drupal 8
Dependency injection in Drupal 8Alexei Gorobets
 
Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011Jacopo Romei
 
Php on the desktop and php gtk2
Php on the desktop and php gtk2Php on the desktop and php gtk2
Php on the desktop and php gtk2Elizabeth Smith
 
vfsStream - effective filesystem mocking
vfsStream - effective filesystem mocking vfsStream - effective filesystem mocking
vfsStream - effective filesystem mocking Sebastian Marek
 
Eclipse Pdt2.0 26.05.2009
Eclipse Pdt2.0 26.05.2009Eclipse Pdt2.0 26.05.2009
Eclipse Pdt2.0 26.05.2009Bastian Feder
 
Architecting for PHP5 - Why "Runs on PHP5" is not "Written for PHP5"
Architecting for PHP5 - Why "Runs on PHP5" is not "Written for PHP5"Architecting for PHP5 - Why "Runs on PHP5" is not "Written for PHP5"
Architecting for PHP5 - Why "Runs on PHP5" is not "Written for PHP5"ZendCon
 
Auto-loading of Drupal CCK Nodes
Auto-loading of Drupal CCK NodesAuto-loading of Drupal CCK Nodes
Auto-loading of Drupal CCK Nodesnihiliad
 
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf Conference
 
Как получить чёрный пояс по WordPress?
Как получить чёрный пояс по WordPress?Как получить чёрный пояс по WordPress?
Как получить чёрный пояс по WordPress?Yevhen Kotelnytskyi
 
What's Coming in Spring 3.0
What's Coming in Spring 3.0What's Coming in Spring 3.0
What's Coming in Spring 3.0Matt Raible
 
Design Patterns avec PHP 5.3, Symfony et Pimple
Design Patterns avec PHP 5.3, Symfony et PimpleDesign Patterns avec PHP 5.3, Symfony et Pimple
Design Patterns avec PHP 5.3, Symfony et PimpleHugo Hamon
 
Как получить чёрный пояс по WordPress? v2.0
Как получить чёрный пояс по WordPress? v2.0Как получить чёрный пояс по WordPress? v2.0
Как получить чёрный пояс по WordPress? v2.0Yevhen Kotelnytskyi
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐいHisateru Tanaka
 

Semelhante a Design Patterns in PHP5 (20)

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)
 
Object Oriented Programming with PHP 5 - More OOP
Object Oriented Programming with PHP 5 - More OOPObject Oriented Programming with PHP 5 - More OOP
Object Oriented Programming with PHP 5 - More OOP
 
Unittests für Dummies
Unittests für DummiesUnittests für Dummies
Unittests für Dummies
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For Beginners
 
Laying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentLaying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme development
 
How Kris Writes Symfony Apps
How Kris Writes Symfony AppsHow Kris Writes Symfony Apps
How Kris Writes Symfony Apps
 
Dependency injection in Drupal 8
Dependency injection in Drupal 8Dependency injection in Drupal 8
Dependency injection in Drupal 8
 
Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011
 
Php on the desktop and php gtk2
Php on the desktop and php gtk2Php on the desktop and php gtk2
Php on the desktop and php gtk2
 
vfsStream - effective filesystem mocking
vfsStream - effective filesystem mocking vfsStream - effective filesystem mocking
vfsStream - effective filesystem mocking
 
Eclipse Pdt2.0 26.05.2009
Eclipse Pdt2.0 26.05.2009Eclipse Pdt2.0 26.05.2009
Eclipse Pdt2.0 26.05.2009
 
Architecting for PHP5 - Why "Runs on PHP5" is not "Written for PHP5"
Architecting for PHP5 - Why "Runs on PHP5" is not "Written for PHP5"Architecting for PHP5 - Why "Runs on PHP5" is not "Written for PHP5"
Architecting for PHP5 - Why "Runs on PHP5" is not "Written for PHP5"
 
Auto-loading of Drupal CCK Nodes
Auto-loading of Drupal CCK NodesAuto-loading of Drupal CCK Nodes
Auto-loading of Drupal CCK Nodes
 
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
 
Как получить чёрный пояс по WordPress?
Как получить чёрный пояс по WordPress?Как получить чёрный пояс по WordPress?
Как получить чёрный пояс по WordPress?
 
What's Coming in Spring 3.0
What's Coming in Spring 3.0What's Coming in Spring 3.0
What's Coming in Spring 3.0
 
Design Patterns avec PHP 5.3, Symfony et Pimple
Design Patterns avec PHP 5.3, Symfony et PimpleDesign Patterns avec PHP 5.3, Symfony et Pimple
Design Patterns avec PHP 5.3, Symfony et Pimple
 
Как получить чёрный пояс по WordPress? v2.0
Как получить чёрный пояс по WordPress? v2.0Как получить чёрный пояс по WordPress? v2.0
Как получить чёрный пояс по WordPress? v2.0
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
Solid principles
Solid principlesSolid principles
Solid principles
 

Mais de Wildan Maulana

Hasil Pendataan Potensi Desa 2018
Hasil Pendataan Potensi Desa 2018Hasil Pendataan Potensi Desa 2018
Hasil Pendataan Potensi Desa 2018Wildan Maulana
 
Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...
Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...
Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...Wildan Maulana
 
Ketahanan Pangan #1 : Gerakan Sekolah Menanam Melon
Ketahanan Pangan #1 : Gerakan Sekolah Menanam MelonKetahanan Pangan #1 : Gerakan Sekolah Menanam Melon
Ketahanan Pangan #1 : Gerakan Sekolah Menanam MelonWildan Maulana
 
Pengembangan OpenThink SAS 2013-2014
Pengembangan OpenThink SAS 2013-2014Pengembangan OpenThink SAS 2013-2014
Pengembangan OpenThink SAS 2013-2014Wildan Maulana
 
ICA – AtoM : Retensi Arsip
ICA – AtoM : Retensi ArsipICA – AtoM : Retensi Arsip
ICA – AtoM : Retensi ArsipWildan Maulana
 
OpenThink Labs Workshop : Ketahanan Pangan Skala RT/RW
OpenThink Labs Workshop : Ketahanan Pangan Skala RT/RWOpenThink Labs Workshop : Ketahanan Pangan Skala RT/RW
OpenThink Labs Workshop : Ketahanan Pangan Skala RT/RWWildan Maulana
 
OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...
OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...
OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...Wildan Maulana
 
PostgreSQL BootCamp : Manajemen Master Data dengan SkyTools
PostgreSQL BootCamp : Manajemen Master Data dengan SkyToolsPostgreSQL BootCamp : Manajemen Master Data dengan SkyTools
PostgreSQL BootCamp : Manajemen Master Data dengan SkyToolsWildan Maulana
 
Mensetup Google Apps sebagai IdP jenis openID dan Aplikasi Berbasis CakePHP ...
Mensetup Google Apps sebagai IdP jenis openID  dan Aplikasi Berbasis CakePHP ...Mensetup Google Apps sebagai IdP jenis openID  dan Aplikasi Berbasis CakePHP ...
Mensetup Google Apps sebagai IdP jenis openID dan Aplikasi Berbasis CakePHP ...Wildan Maulana
 
Mensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai Sp
Mensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai SpMensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai Sp
Mensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai SpWildan Maulana
 
Konfigurasi simpleSAMLphp dengan Google Apps Sebagai Identity Provider
Konfigurasi simpleSAMLphp  dengan Google Apps Sebagai Identity ProviderKonfigurasi simpleSAMLphp  dengan Google Apps Sebagai Identity Provider
Konfigurasi simpleSAMLphp dengan Google Apps Sebagai Identity ProviderWildan Maulana
 
Instalasi simpleSAMLphp sebagai Identity Provider (IdP)
Instalasi simpleSAMLphp sebagai Identity Provider (IdP)Instalasi simpleSAMLphp sebagai Identity Provider (IdP)
Instalasi simpleSAMLphp sebagai Identity Provider (IdP)Wildan Maulana
 
Instalasi dan Konfigurasi simpleSAMLphp
Instalasi dan Konfigurasi simpleSAMLphpInstalasi dan Konfigurasi simpleSAMLphp
Instalasi dan Konfigurasi simpleSAMLphpWildan Maulana
 
River Restoration in Asia and Connection Between IWRM and River Restoration
River Restoration in Asia and Connection Between IWRM and River RestorationRiver Restoration in Asia and Connection Between IWRM and River Restoration
River Restoration in Asia and Connection Between IWRM and River RestorationWildan Maulana
 
Optimasi Limpasan Air Limbah Ke Kali Surabaya (Segmen Sepanjang – Jagir) De...
Optimasi Limpasan Air Limbah  Ke Kali Surabaya (Segmen Sepanjang – Jagir)  De...Optimasi Limpasan Air Limbah  Ke Kali Surabaya (Segmen Sepanjang – Jagir)  De...
Optimasi Limpasan Air Limbah Ke Kali Surabaya (Segmen Sepanjang – Jagir) De...Wildan Maulana
 
Penilaian Siswa di Finlandia - Pendidikan Dasar
Penilaian Siswa di Finlandia - Pendidikan DasarPenilaian Siswa di Finlandia - Pendidikan Dasar
Penilaian Siswa di Finlandia - Pendidikan DasarWildan Maulana
 
Proyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and Uses
Proyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and UsesProyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and Uses
Proyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and UsesWildan Maulana
 
OpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang Tua
OpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang TuaOpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang Tua
OpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang TuaWildan Maulana
 
Menggunakan AlisJK : Equating
Menggunakan AlisJK : EquatingMenggunakan AlisJK : Equating
Menggunakan AlisJK : EquatingWildan Maulana
 

Mais de Wildan Maulana (20)

Hasil Pendataan Potensi Desa 2018
Hasil Pendataan Potensi Desa 2018Hasil Pendataan Potensi Desa 2018
Hasil Pendataan Potensi Desa 2018
 
Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...
Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...
Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...
 
Ketahanan Pangan #1 : Gerakan Sekolah Menanam Melon
Ketahanan Pangan #1 : Gerakan Sekolah Menanam MelonKetahanan Pangan #1 : Gerakan Sekolah Menanam Melon
Ketahanan Pangan #1 : Gerakan Sekolah Menanam Melon
 
Pengembangan OpenThink SAS 2013-2014
Pengembangan OpenThink SAS 2013-2014Pengembangan OpenThink SAS 2013-2014
Pengembangan OpenThink SAS 2013-2014
 
ICA – AtoM : Retensi Arsip
ICA – AtoM : Retensi ArsipICA – AtoM : Retensi Arsip
ICA – AtoM : Retensi Arsip
 
OpenThink Labs Workshop : Ketahanan Pangan Skala RT/RW
OpenThink Labs Workshop : Ketahanan Pangan Skala RT/RWOpenThink Labs Workshop : Ketahanan Pangan Skala RT/RW
OpenThink Labs Workshop : Ketahanan Pangan Skala RT/RW
 
OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...
OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...
OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...
 
PostgreSQL BootCamp : Manajemen Master Data dengan SkyTools
PostgreSQL BootCamp : Manajemen Master Data dengan SkyToolsPostgreSQL BootCamp : Manajemen Master Data dengan SkyTools
PostgreSQL BootCamp : Manajemen Master Data dengan SkyTools
 
Mensetup Google Apps sebagai IdP jenis openID dan Aplikasi Berbasis CakePHP ...
Mensetup Google Apps sebagai IdP jenis openID  dan Aplikasi Berbasis CakePHP ...Mensetup Google Apps sebagai IdP jenis openID  dan Aplikasi Berbasis CakePHP ...
Mensetup Google Apps sebagai IdP jenis openID dan Aplikasi Berbasis CakePHP ...
 
Mensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai Sp
Mensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai SpMensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai Sp
Mensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai Sp
 
Konfigurasi simpleSAMLphp dengan Google Apps Sebagai Identity Provider
Konfigurasi simpleSAMLphp  dengan Google Apps Sebagai Identity ProviderKonfigurasi simpleSAMLphp  dengan Google Apps Sebagai Identity Provider
Konfigurasi simpleSAMLphp dengan Google Apps Sebagai Identity Provider
 
Instalasi simpleSAMLphp sebagai Identity Provider (IdP)
Instalasi simpleSAMLphp sebagai Identity Provider (IdP)Instalasi simpleSAMLphp sebagai Identity Provider (IdP)
Instalasi simpleSAMLphp sebagai Identity Provider (IdP)
 
Instalasi dan Konfigurasi simpleSAMLphp
Instalasi dan Konfigurasi simpleSAMLphpInstalasi dan Konfigurasi simpleSAMLphp
Instalasi dan Konfigurasi simpleSAMLphp
 
River Restoration in Asia and Connection Between IWRM and River Restoration
River Restoration in Asia and Connection Between IWRM and River RestorationRiver Restoration in Asia and Connection Between IWRM and River Restoration
River Restoration in Asia and Connection Between IWRM and River Restoration
 
Optimasi Limpasan Air Limbah Ke Kali Surabaya (Segmen Sepanjang – Jagir) De...
Optimasi Limpasan Air Limbah  Ke Kali Surabaya (Segmen Sepanjang – Jagir)  De...Optimasi Limpasan Air Limbah  Ke Kali Surabaya (Segmen Sepanjang – Jagir)  De...
Optimasi Limpasan Air Limbah Ke Kali Surabaya (Segmen Sepanjang – Jagir) De...
 
Penilaian Siswa di Finlandia - Pendidikan Dasar
Penilaian Siswa di Finlandia - Pendidikan DasarPenilaian Siswa di Finlandia - Pendidikan Dasar
Penilaian Siswa di Finlandia - Pendidikan Dasar
 
Statistik Listrik
Statistik ListrikStatistik Listrik
Statistik Listrik
 
Proyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and Uses
Proyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and UsesProyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and Uses
Proyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and Uses
 
OpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang Tua
OpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang TuaOpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang Tua
OpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang Tua
 
Menggunakan AlisJK : Equating
Menggunakan AlisJK : EquatingMenggunakan AlisJK : Equating
Menggunakan AlisJK : Equating
 

Último

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
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
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
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
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 

Último (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
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...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
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)
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 

Design Patterns in PHP5

  • 1. #4 Object Oriented Programming with PHP 5 Design Patterns Doc. v. 0.1 - 19/03/09 Wildan Maulana | wildan [at] tobethink.com
  • 2. About Design Pattern • Design Patterns was introduced by Eric Gamma and his three other friends in the book Design Patterns, in 1972 • You might have done one of this before ...
  • 3. Design Patterns Strategy Pattern • Factory Pattern • Abstract Factory • Adapter Pattern • Singleton Pattern • Iterator Pattern • Observer Pattern • Proxy Pattern or Lazy Loading • Decorator Pattern • Facade Pattern •
  • 4. Strategy Pattern • Strategy pattern is a common pattern helps us make decisions on different case, more easily.
  • 5. Strategy Pattern Example Context Strategy Email Notifier SMS Notifier Fax Notifier
  • 6. <?php <?php //notifier.interface.php //emailnotifier.class.php interface notifier include_once(quot;notifier.interface.phpquot;); { class EmailNotifier implements notifier public function notify(); { } public function notify() ?> { //do something to notify the user by Email } } ?> <?php <?php //faxnotifier.class.php smsnotifier.class.php include_once(quot;notifier.interface.phpquot;); class FaxNotifier implements notifier include_once(quot;notifier.interface.phpquot;); { class SMSNotifier implements notifier public function notify() { { public function notify() //do something to notify the user by Fax { } //do something to notify the user by SMS } } ?> }
  • 7. <?php include_once(quot;emailnotifier.class.phpquot;); include_once(quot;faxnotifier.class.phpquot;); include_once(quot;smsnotifier.class.phpquot;); /** * Let's create a mock object User which we assume has a method named * getNotifier(). This method returns either quot;smsquot; or quot;faxquot; or quot;emailquot; */ $user = new User(); $notifier = $user->getNotifier(); switch ($notifier) { case quot;emailquot;: $objNotifier = new EmailNotifier(); break; case quot;smsquot;: $objNotifier = new SMSNotifier(); break; case quot;faxquot;: $objNotifier = new FaxNotifier(); break; } $objNotifier->notify(); ?>
  • 8. Factory Pattern • The main goal of factory pattern is delivering an object by hiding all the complexities behind it. • Example :
  • 9. Before using Factory Pattern <?php <?php class MySQLManager class PostgreSQLManager How we use this class : { { public function setHost($host) public function setHost($host) { { <?php //set db host //set db host $MM = new MySQLManager(); } $MM->setHost(quot;hostquot;); } public function setDB($db) $MM->setDB(quot;dbquot;); public function setDB($db) { $MM->setUserName(quot;userquot;); { //set db name $MM->setPassword(quot;pwdquot;); //set db name } $MM->connect(); } public function setUserName($user) ?> public function setUserName($user) { <?php { //set user name $PM = new PostgreSQLManager(); } //set user name $PM->setHost(quot;hostquot;); public function setPassword($pwd) } $PM->setDB(quot;dbquot;); { public function setPassword($pwd) $PM->setUserName(quot;userquot;); //set password { $PM->setPassword(quot;pwdquot;); } $PM->connect(); //set password public function connect() ?> } { public function connect() Merge them ... //now connect { } //now connect } <?php } ?> If ($dbtype==quot;mysqlquot;) } //use mysql class ?> Else if ($dbtype==quot;postgresqlquot;) //use postgresql class ?>
  • 10. <?php class DBManager How to use it .... { public static function setDriver($driver) { <?php $this->driver = $driver; //set the driver $DM = new DBManager(); } $DM->setDriver(quot;mysqlquot;); public static function connect() $DM->connect(quot;hostquot;,quot;userquot;,quot;dbquot;,quot;pwdquot;); { if ($this->driver==quot;mysqlquot;) ?> { $MM = new MySQLManager(); $MM->setHost(quot;hostquot;); Context $MM->setDB(quot;dbquot;); $MM->setUserName(quot;userquot;); The DBManager now works $MM->setPassword(quot;pwdquot;); $this->connection = $MM->connect(); as a Factory ...... } Factory else if($this->driver==quot;pgsqlquot;) { $PM = new PostgreSQLManager(); $PM->setHost(quot;hostquot;); Concrete product $PM->setDB(quot;dbquot;); $PM->setUserName(quot;userquot;); $PM->setPassword(quot;pwdquot;); $this->connection= $PM->connect(); } Database driver } } ?>
  • 11. Abstract Factory Pattern • Abstract Factory is almost similar to Factory, the only difference is that all your concrete objects must extend a common abstract class. • One major benefit is that we define all the necessary functions in a single place, which is present in all derived classes with the same standard. We can also encapsulate common functions/procedures in the abstract class.
  • 12. <?php <?php class MySQLManager extends DBDriver abstract class DBDriver { { public function connect() public function connect(); { public function executeQuery(); //implement own connection procedures public function insert_id(); } public function setHost($host) public function executeQuery() { { //execute mysql query and return result //set db host } } public function insertId() public function setDB($db) { { //find the latest inserted id //set db name } } } public function setUserName($user) ?> { //set user name Later we will use this MySQLManager class } public function setPassword($pwd) as usual in our DBManager... { //set password } //..... } ?>
  • 13. Abstract Pattern Context Factory Concrete Product Database driver Database driver Abstract Database driver
  • 14. Adapter Pattern • Adapter is actually an object that acts like an adapter in real life, in that it converts one thing to another. Using Adapter you can convert electric sources from higher to lower volts. Similarly in OOP, using Adapter pattern, one object can fit for the same methods of another object. Context Doc Manager Google Doc Writely Adapter
  • 15. <?php <?php interface DocManager class Writely implements DocManager() { { public function authenticate($user, $pwd); public function authenticate($user, $pwd) public function getDocuments($folderid); { public function getDocumentsByType($folderid, $type); //authenticate using Writely authentication scheme public function getFolders($folderid=null); public function saveDocument($document); } } public function getDocuments($folderid) ?> { <?php //get documents available in a folder class GoogleDocs } { public function getDocumentsByType($folderid, $type) public function authenticateByClientLogin() { { //authenticate using Writely authentication scheme //get documents of specific type from a folder } } public function setUser() public function getFolders($folderid=null) { { //set user //get all folders under a specific folder } } public function setPassword() public function saveDocuments($document) { { //set password //save the document } } public function getAllDocuments() } { ?> //get documents available in a folder } public function getRecentDocuments() How to fit Goolgle Docs to our existing code ? { } public function getDocument() We need to develop the wrapper { object, which implements the same DocManager } interface but uses the GoogleDoc object to perform the actual } work. ?>
  • 16. <?php Class GoogleDocsAdapter implements DocManager { Now we will just instantiate an instance private $GD; of GoogleDocsAdapter and then use that public function __construct() { instance in our core code. $this->GD = new GoogleDocs(); As it implements the same interface, } public function authenticate($user, $pwd) there is no need to change the core code. { $this->GD->setUser($user); $this->GD->setPwd($pwd); This is an example when adapter $this->GD->authenticateByClientLogin(); Pattern can be usefull } public function getDocuments($folderid) { return $this->GD->getAllDocuments(); } public function getDocumentsByType($folderid, $type) { //get documents using GoogleDocs object and return only // which match the type } public function getFolders($folderid=null) { //for example there is no folder in GoogleDocs, so //return anything. } public function saveDocument($document) { //save the document using GoogleDocs object } } ?>
  • 17. Singleton Pattern The main purpose of the Singleton pattern is to deliver a single • instance of object no matter how many times you instantiate it. That is, if an object is instantiated once, using the Singleton pattern you can deliver only that instance when you require it again in your code. This saves memory consumption by preventing the creation of multiple instances of an object. Thus Singleton pattern is used to improve the performance of your application. Context Doc Manager Singleton is a very important pattern ! Google Doc Writely Adapter
  • 18. Singleton Pattern <?php class MySQLManager { private static $instance; <?php public function __construct() $a = new MYSQLManager(); { $b = new MYSQLManager(); if (!self::$instance) $c = new MYSQLManager(); { $d = new MYSQLManager(); self::$instance = $this; $e = new MYSQLManager(); echo quot;New Instancenquot;; ?> return self::$instance; } else { echo quot;Old Instancenquot;; return self::$instance; } New Instance } Old Instance //keep other methods same Old Instance } Old Instance ?> Old Instance
  • 19. Iterator Pattern • Iterator is a common pattern, which helps you to manipulate a collection more easily.
  • 20. Without Iterator Pattern <?php $posts = getAllPosts(); //example function return all post ids of this author for($i = 0; $i<count($posts); $i++) { $title = getPostTitle($post[$i]); echo $title; $author = getPostAuthor($post[$i]); $content = parseBBCode(getPostContent($post[$i])); echo quot;Contentquot;; $comments = getAllComments($post[$i]); for ($j=0; $j<count($comments); $j++) { $commentAuthor = getCommentAuthor($comments[$j]); echo $commentAuthor; $comment = getCommentContent($comments[$j]); echo $comment; } } ?>
  • 21. On the previous example, if we turn the comments into a collection of comment object for that post and all the posts into a collection of post object for easier accessing, it will remove the burden of template designing as well as create manageable code.
  • 22. Iterator interface in PHP5 The rewind() function of Iterator sets the • <?php index to the start of collection. interface Iterator The current() returns the current object. • { function rewind(); key() function returns the current key. • function current(); The function next() returns if there are more • function key(); object ahead in the current loop counter. If function next(); the return is yes, this function returns true, function valid(); otherwise it returns false. } The valid() function returns the current • ?> object if it has any value in it. Let us create an Iterator for our post object. Next ..., the solution for the previous code using Iterator Pattern ...
  • 23. <?php class Posts implements Iterator <?php { private $posts = array(); $blogposts = getAllPosts(); public function __construct($posts) $posts = new Posts($posts); { foreach ($posts as $post) if (is_array($posts)) { { $this->posts = $posts; echo $post->getTitle(); } echo $post->getAuthor(); } echo $post->getDate(); public function rewind() { echo $post->getContent(); reset($this->posts); $comments = new Comments($post->getComments()); } //another Iterator for comments, code is same as Posts public function current() { foreach ($comments as $comment) return current($this->posts); { } echo $comment->getAuthor(); public function key() { echo $comment->getContent(); return key($this->var); } } public function next() { } return next($this->var); ?> } public function valid() { return ($this->current() !== false); } } ?>
  • 24. Observer Pattern An Observer pattern solves a common problem in OOP. For • example, if you want some objects to be notified automatically when something happens (an event raised), you can solve that problem with this pattern. An Observer pattern consists of two types of objects; one is an • observable object, which is observed by observer object. When the state of an observable object changes, it notifies all observers registered with it. Observable Observer::notify() Email Notifier IM Notifier
  • 25. <?php <?php interface observer class YMNotifier implements observer { { public function notify(); public function notify() } { ?> //send alerts using YM echo quot;Notifying via YMnquot;; } }; <?php ?> class observable { private $observers = array(); public function register($object) <?php { if ($object instanceof observer ) class EmailNotifier implements observer $this->observers[] =$object; { else public function notify() echo quot;The object must implement observer interfacenquot;; { } //send alerts using Email public function stateChange() echo quot;Notifying via Emailnquot;; { foreach ($this->observers as $observer) } { }; $observer->notify(); } ?> } } ?>
  • 26. <?php $postmonitor = new observable(); $ym = new YMNotifier(); $em = new EmailNotifier(); $s= new stdClass(); $postmonitor->register($ym); $postmonitor->register($em); $postmonitor->register($s); $postmonitor->stateChange(); Output ?> The object must implement observer interface Notifying via YM Notifying via Email
  • 27. Proxy Pattern and Lazy Loading • The main idea of lazy loading is to decrease the concrete dependency among objects while coding • Using proxy pattern we can create a local version of a remote object. It provides a common API for accesing methods of a remote object without knowing the things behind the scene. The best example of proxy pattern could be the XML RPC and Soap client
  • 28. Proxy Pattern Context Local Object Remote Object Proxy
  • 29. Decorator Pattern • Decorator pattern is an important problem-solving approach introduced by GoF in their legendary design pattern book. Using this pattern we can add additional functionalities in an existing object without extending an object. – But how we can do this without inheritance ?
  • 30. <?php <?php class Post class Comment { { private $title; private $date; private $content; private $content; //additional properties //additional properties public function filter() public function filter() { { //do necessary processing //do necessary processing $this->content = $filtered_content; $this->content = $filtered_content; $this->title = $filtered_title; } } public function getContent() public function getContent() { { return $this->content; return $this->content; } } //additional methods //additional methods } } ?> ?>
  • 31. The Decorator Objects <?php <?php class BBCodeParser class EmoticonParser { { private $post; private $post; public function __construct($object) public function __construct($object) { { $this->post = $object; $this->post = $object; } } public function getContent() public function getContent() { { //parse bbcode //parse bbcode $post->filter(); $post->filter(); $content = $this->parseBBCode($post->getContent()); $content = $this->parseEmoticon($post->getContent()); return $content; return $content; } } private function parseBBCode($content) private function parseEmoticon($content) { { //process BB code in the content and return it //process Emoticon code in the content and return it } } } } ?> ?>
  • 32. Decorator Pattern in Action <?php $post = new Post();//set the properties of the post object $comment = new Comment();//set the properties of the comment object $post->filter(); $comment->filter(); if ($BBCodeEnabled==false && $EmoticonEnabled==false) { $PostContent = $post->getContent(); $CommentContent = $comment->getContent(); } elseif ($BBCodeEnabled==true && $EmoticonEnabled==false) { $bb = new BBCodeParser($post);//passing a post object to //BBCodeParser $PostContent = $bb->getContent(); $bb = new BBCodeParser($comment);//passing a comment object to //BBCodeParser $CommentContent = $bb->getContent(); } elseif ($BBCodeEnabled==true && $EmoticonEnabled==false) { $em = new EmoticonParser($post); $PostContent = $bb->getContent(); $em = new EmoticonParser($comment); $CommentContent = $bb->getContent(); } ?>
  • 33. Active Record Pattern • This is another very important design pattern to simplify database manipulation • We will talkl about this topic later, on the #7 presentation
  • 34. Facade Pattern • Facade provides a common interface to many objects. In other words, it just simplifies the programming providing a necessary interface, which actually uses a lot of other objects behind the scenes. Thus it minimizes the learning curve for developers. When a new developer joins the team, he suddenly gets introduced to a lot of objects with tons of methods and properties, among which he might need a few to accomplish his work. So why bother spending time learning them all? This is where Facade helps developers and saves a lot of their time.
  • 35. The code structure before using Facade Client A Client B Geo Locator Apartment Finder Google Map
  • 36. The code structure after using Facade Client A Client B Facade Geo Locator Apartment Finder Google Map
  • 37. The Code <?php <?php class GeoLocator class ApartmentFinder { { public function getLocations($place) public function locateApartments($place) { { //use public geo coding service like yahoo and get the //use the web service and locate all apartments suitable //lattitude and //search name //longitude of that place //now return them all in an array return array(quot;latquot;=>$lattitude, quot;lngquot;=>$longitude); return $apartmentsArray(); } } } } ?> ?> <?php class GoogleMap { public function initialize() { //do initialize } public function drawLocations($locations /* array */) { //locate all the points using Google Map Locator } public function dispatch($divid) { //draw the map with in a div with the div id } } ?>
  • 38. The Facade <?php class Facade { public function findApartments($place, $divid) { How to use it .... $AF = new ApartmentFinder(); $GL =new GeoLocator(); <?php $GM = new GoogleMap(); $F = new Facade(); $apartments = $AF->locateApartments($place); $F->findApartments(quot;London, Greater Londonquot;,quot;mapdivquot;); ?> foreach ($apartments as $apartment) { $locations[] = $GL->getLocations($apartment); } $GM->initialize(); $GM->drawLocations($locations); $GM->dispatch($divid); } } ?>
  • 39. Summary • Design patterns are an essential part of OOP. It makes your code more effective, better performing, and easier to maintain • Altough sometimes we implement these design patterns in our code without knowing that these solutions are defined as design patterns. • Use design pattern when you need it • For more information about design pattern you can read Head First Design Patterns published by O'reilly and Design Patterns Explained by Addison-Wesley.
  • 40. Q&A
  • 41. Reference • Object Oriented Programming with PHP5, Hasin Hayder, PACKT Publishing