Skip to content

Instantly share code, notes, and snippets.

View tkouleris's full-sized avatar
:octocat:
Infinite Refactor

Thodoris Kouleris tkouleris

:octocat:
Infinite Refactor
View GitHub Profile
@tkouleris
tkouleris / Proxy.php
Created July 20, 2016 06:00
Proxy pattern example
<?php
/*
* Proxy Pattern Example
* --------------------------
*
* Wiki: A proxy, in its most general form, is a class functioning as an interface
* to something else. The proxy could interface to * anything: a network connection,
* a large object in memory, a file, or some other resource that is expensive or impossible
* to duplicate. In short, a proxy is a wrapper or agent object that is being called by the
* client to access the real serving object behind the scenes. Use of the proxy can simply be
@tkouleris
tkouleris / TemplateMethod.php
Created July 19, 2016 05:16
Design Pattern - Template Method Example
<?php
abstract class Beverage{
/* Hook methods */
public abstract function boilWater();
public abstract function brew();
public abstract function serve();
public abstract function addSupplements();
/* The template method */
@tkouleris
tkouleris / Singleton.php
Created July 15, 2016 04:50
Singleton Design Pattern Example
<?php
/*
* Singleton Pattern Example
* --------------------------
*
* Wiki: In software engineering, the singleton pattern is
* a design pattern that restricts the instantiation of a
* class to one * object. This is useful when exactly one object
* is needed to coordinate actions across the system.
*