This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Observer Design Pattern - Weather Station Example | |
*/ | |
abstract class Observer{ | |
public function update(){} | |
} | |
abstract class Subject{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
abstract class SongComposite{ | |
public function songInfo(){} | |
} | |
class Song extends SongComposite{ | |
private $songTitle; | |
private $songBand; | |
public function __construct($sTitle, $sBand){ | |
$this->songTitle = $sTitle; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class IntegerRange implements Iterator{ | |
private $start; | |
private $end; | |
private $current; | |
public function __construct($start, $end){ | |
$this->start = $start; | |
$this->end = $end; | |
$this->current = $start; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
abstract class PCgame{ | |
protected $title; | |
protected $productKey; | |
protected $medium; | |
protected $box; | |
public function setTitle($GameTitle){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Car{ | |
private $doors; | |
private $seats; | |
private $color; | |
public function __construct(){ | |
echo "new Car object\r\n"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
interface IDiscount{ | |
function calculateDiscount($bill); | |
} | |
class NoDiscount implements IDiscount{ | |
public function calculateDiscount($bill){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Facade Design Pattern | |
* ----------------------- | |
* | |
* Wiki:The Facade design pattern is often used when a system is very complex or difficult to understand because the system has a large number of | |
* interdependent classes or its source code is unavailable. This pattern hides the complexities of the larger system and provides a simpler | |
* interface to the client. It typically involves a single wrapper class which contains a set of members required by client. These members access | |
* the system on behalf of the facade client and hide the implementation details. | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* | |
* Factory Design Pattern | |
* ----------------------- | |
* Wiki: In class-based programming, the factory method pattern is a creational pattern that uses factory methods to deal with the problem of creating | |
* objects without having to specify the exact class of the object that will be created. This is done by creating objects by calling a factory | |
* method—either specified in an interface and implemented by child classes, or implemented in a base class and optionally overridden by derived | |
* classes—rather than by calling a constructor. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Chain of Responsibility Pattern - Wiki | |
--------------------------------------- | |
* In object-oriented design, the chain-of-responsibility pattern is a design pattern consisting of a source of command objects and * a series of processing objects.[1] Each processing object contains logic that defines the types of command objects that it can | |
* handle; the rest are passed to the next processing object in the chain. A mechanism also exists for adding new processing bjects * to the end of this chain.In a variation of the standard chain-of-responsibility model, some handlers may act as | |
* dispatchers,capable of sending commands out in a variety of directions, forming a tree of responsibility. In some cases, this | |
* can occur recursively, with processing objects calling higher-up processing objects with commands that attempt to solve some | |
* smaller part of the problem; in this case recursion continues until the command is processed, or the entire tree has been | |
* explored. An XML interpreter might work in thi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* | |
* Adapter Design Pattern | |
* ----------------------- | |
* Wiki: An adapter helps two incompatible interfaces to work | |
* together. This is the real world definition for an adapter. | |
* Interfaces may be incompatible but the inner functionality | |
* should suit the need. The Adapter design pattern allows | |
* otherwise incompatible classes to work together by converting |
NewerOlder