- Added my design talk.

This commit is contained in:
Derick Rethans
2010-06-11 13:13:59 +00:00
parent 2631e478f2
commit 0a659b57a8
27 changed files with 486 additions and 1 deletions

65
design-dpc10.xml Normal file
View File

@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<presentation
template="css"
navmode="html"
navbarbackground="#4373b4"
navbartopiclinks="0"
navColor="#f1fbff"
logo1=""
stylesheet="presentations/slides/ezc/ez.css"
backgroundfixed="1" >
<topic>PHP</topic>
<title>Designing for Reusability</title>
<event>Dutch PHP Conference</event>
<location>Amsterdam, Netherlands</location>
<date>June 11th, 2008</date>
<speaker>Derick Rethans</speaker>
<email>derick@derickrethans.nl</email>
<twitter>derickr</twitter>
<url>http://derickrethans.nl/talks.php</url>
<joindin>http://joind.in/1534</joindin>
<slide>slides/dbus/title.xml</slide>
<slide>slides/toolbox/me.xml</slide>
<!-- INTRODUCTION -->
<!-- THE SATELLITE VIEW -->
- configuration objects
- dependency injection
- overabstraction
<slide>slides/design/components.xml</slide>
<slide>slides/design/dependency-example-wrong1.xml</slide>
<slide>slides/design/dependency-hell.xml</slide>
<slide>slides/design/dependency-example-wrong2.xml</slide>
<slide>slides/design/dependency-example-better1.xml</slide>
<slide>slides/design/hammer.xml</slide>
<slide>slides/design/factory.xml</slide>
<slide>slides/design/hammer-factory.xml</slide>
<slide>slides/design/factory-service.xml</slide>
<slide>slides/design/hammer-factory-design.xml</slide>
<slide>slides/toolbox/dependencies.xml</slide>
<!-- CLASSES THEMSELF -->
<slide>slides/design/break-up.xml</slide>
<slide>slides/design/split-out.xml</slide>
<slide>slides/design/ppp.xml</slide>
<slide>slides/design/active-record.xml</slide>
<slide>slides/design/refactor.xml</slide>
<slide>slides/design/refactor2.xml</slide>
<!-- REUSEABILITY == TESTABILITY -->
<slide>slides/design/testability.xml</slide>
<slide>slides/tdd/unit-test-issues.xml</slide>
<slide>slides/design/mocking.xml</slide>
<slide>slides/design/mvc.xml</slide>
<slide>slides/internals/questions.xml</slide>
<slide>slides/dbus/end.xml</slide>
- mvc
- different input streams
- different renders
- different output
</presentation>

View File

@@ -0,0 +1,32 @@
<slide>
<title>ORM/ActiveRecord</title>
<list>
<bullet>Is a mechanism for mapping objects to a database</bullet>
<bullet>Makes classes inherit from "ActiveRecord"</bullet>
<bullet>Hibernate is alternative</bullet>
<bullet>Traits</bullet>
</list>
<div effect="fade-in">
<example><![CDATA[<?php
trait ActiveRecord
{
public function load()
{
var_dump(get_class($this));
}
}
class Car {
use ActiveRecord;
}
$c = new Car;
$c->load();
?>]]></example>
</div>
<div effect="fade-in">
<example class="result"><![CDATA[string(3) "Car"]]></example>
</div>
</slide>

View File

@@ -0,0 +1,47 @@
<slide>
<title>Implementations</title>
<div effect="fade-out">
<example><![CDATA[public function createRequest()
{
$this->request = new ezcMvcRequest();
$this->processStandardHeaders();
$this->processAcceptHeaders();
$this->processUserAgentHeaders();
$this->processFiles();
$this->processAuthVars();
$this->processCookies();
$this->request->raw = &$_SERVER;
return $this->request;
}]]></example>
</div>
<div effect="fade-in">
<example><![CDATA[public function createRequest()
{
$this->request = $this->createRequestObject();
$this->processStandardHeaders();
$this->processAcceptHeaders();
$this->processUserAgentHeaders();
$this->processFiles();
$this->processAuthVars();
$this->processCookies();
$this->request->raw = &$_SERVER;
return $this->request;
}
/**
* Creates and returns an ezcMvcRequest object.
*
* @return ezcMvcRequest
*/
protected function createRequestObject()
{
return new ezcMvcRequest();
}]]></example>
</div>
</slide>

View File

@@ -0,0 +1,5 @@
<slide>
<title>Application Components</title>
<blurb class="center-page">Any larger application will consist of multiple components</blurb>
</slide>

BIN
slides/design/dep-hell.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

View File

@@ -0,0 +1,51 @@
<slide>
<title>Manual Injection</title>
<div effect="fade-out">
<example><![CDATA[<?php
class Wrappy
{
private $lineLength;
function __construct( Config $configObj )
{
$this->lineLength = $configObj->getLineLength();
}
}
$configObj = new Config();
$wrap = new Wrappy( $configObj );
?>]]></example>
</div>
<div effect="fade-in-out">
<example><![CDATA[<?php
class Wrappy
{
private $lineLength;
function __construct( Config $configObj = null )
{
$this->lineLength = $configObj ? $configObj->getLineLength() : 78;
}
}
$wrap = new Wrappy();
?>]]></example>
</div>
<div effect="fade-in">
<example><![CDATA[<?php
class Wrappy
{
private $lineLength;
function __construct( ConfigInterface $configObj = null )
{
$this->lineLength = $configObj ? $configObj->getLineLength() : 78;
}
}
$wrap = new Wrappy();
?>]]></example>
</div>
</slide>

View File

@@ -0,0 +1,34 @@
<slide>
<title>Dependencies Example</title>
<div effect="fade-out">
<example><![CDATA[<?php
class Wrappy
{
private $lineLength;
function __construct()
{
$configObj = Config::get();
$this->lineLength = $configObj->getLineLength();
}
}
?>]]></example>
<blurb class="center-page">The Singleton Disaster</blurb>
</div>
<div effect="fade-in">
<example><![CDATA[<?php
class Wrappy
{
private $lineLength;
function __construct()
{
global $configObj;
$this->lineLength = $configObj->getLineLength();
}
}
?>]]></example>
<blurb class="center-page">The Globals Catastrophe</blurb>
</div>
</slide>

View File

@@ -0,0 +1,17 @@
<slide>
<title>Hard Dependency</title>
<example><![CDATA[<?php
class Wrappy
{
private $lineLength;
function __construct()
{
$configObj = new Config();
$this->lineLength = $configObj->getLineLength();
}
}
?>]]></example>
<blurb class="center-page">Hard Dependency</blurb>
</slide>

View File

@@ -0,0 +1,34 @@
<slide>
<title>Bad Dependencies</title>
<div effect="fade-out">
<example><![CDATA[<?php
class Wrappy
{
private $lineLength;
function __construct()
{
$configObj = Config::get();
$this->lineLength = $configObj->getLineLength();
}
}
?>]]></example>
<blurb class="center-page">The Singleton Disaster</blurb>
</div>
<div effect="fade-in">
<example><![CDATA[<?php
class Wrappy
{
private $lineLength;
function __construct()
{
global $configObj;
$this->lineLength = $configObj->getLineLength();
}
}
?>]]></example>
<blurb class="center-page">The Globals Catastrophe</blurb>
</div>
</slide>

View File

@@ -0,0 +1,5 @@
<slide>
<title>Spaghetti</title>
<image filename="dep-hell.png"/>
</slide>

View File

@@ -0,0 +1,26 @@
<slide>
<title>Service</title>
<example><![CDATA[<?php
class Wrappy
{
private $lineLength;
function __construct( Config $configObj )
{
$this->lineLength = $configObj->getLineLength();
}
}
/*
<service>
<wrappy>
<config>
...
</wrappy>
</service>
*/
$wrappy = ServiceDepmanager::createWrappy();
?>]]></example>
</slide>

24
slides/design/factory.xml Normal file
View File

@@ -0,0 +1,24 @@
<slide>
<title>Factory</title>
<example><![CDATA[<?php
class Wrappy
{
private $lineLength;
function __construct( Config $configObj )
{
$this->lineLength = $configObj->getLineLength();
}
}
class TextManipulationFactory
{
function getWrappy()
{
$config = new Config();
return new Wrappy($config);
}
}
?>]]></example>
</slide>

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

View File

@@ -0,0 +1,7 @@
<slide>
<title>Hammer Factory Plans</title>
<image filename="hammer-factory-design.jpg" pdf-scale="0.7"/>
<blurb>"Why I Hate Frameworks"</blurb>
<blurb><link href="http://discuss.joelonsoftware.com/default.asp?joel.3.219431.12"/></blurb>
</slide>

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -0,0 +1,4 @@
<slide>
<title>Factory</title>
<image filename="hammer-factory.jpg" pdf-scale="0.7"/>
</slide>

BIN
slides/design/hammer.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

5
slides/design/hammer.xml Normal file
View File

@@ -0,0 +1,5 @@
<slide>
<title>Building stuff</title>
<image filename="hammer.jpg"/>
</slide>

View File

@@ -0,0 +1,5 @@
<slide>
<title>Mocking</title>
<blurb class="center-page">Hiding an implementation by a fake implementation</blurb>
</slide>

26
slides/design/mvc.xml Normal file
View File

@@ -0,0 +1,26 @@
<slide>
<title>MVC/Testing</title>
<list>
<bullet>MVC generally uses HTTP</bullet>
<bullet>Is that necessary?</bullet>
<bullet>How do we test that?</bullet>
</list>
<div effect="fade-in">
<example><![CDATA[<?php
interface ezcMvcDispatcherConfiguration
{
public function createRequestParser();
public function createRouter( ezcMvcRequest $request );
public function createView( ezcMvcRoutingInformation $routeInfo, ezcMvcRequest $request, ezcMvcResult $result );
public function createResponseWriter( ezcMvcRoutingInformation $routeInfo, ezcMvcRequest $request, ezcMvcResult $result, ezcMvcResponse $response );
public function createFatalRedirectRequest( ezcMvcRequest $request, ezcMvcResult $result, Exception $e );
public function runPreRoutingFilters( ezcMvcRequest $request );
public function runRequestFilters( ezcMvcRoutingInformation $routeInfo, ezcMvcRequest $request );
public function runResultFilters( ezcMvcRoutingInformation $routeInfo, ezcMvcRequest $request, ezcMvcResult $result );
public function runResponseFilters( ezcMvcRoutingInformation $routeInfo, ezcMvcRequest $request, ezcMvcResult $result, ezcMvcResponse $response );
}
?>]]></example>
</div>
</slide>

9
slides/design/ppp.xml Normal file
View File

@@ -0,0 +1,9 @@
<slide>
<title>Visibility</title>
<list>
<bullet>public</bullet>
<bullet>protected</bullet>
<bullet>private</bullet>
</list>
</slide>

View File

@@ -0,0 +1,10 @@
<slide>
<title>Refactoring</title>
<break lines="4"/>
<blurb class="quote">*Code refactoring* is the process of changing a computer
program's source code without modifying its external functional behavior in
order to improve some of the nonfunctional attributes of the software.
Advantages include improved code readability and reduced complexity to
improve the maintainability of the source code, as well as a more
expressive internal architecture or object model *to improve extensibility*. (Wikipedia)</blurb>
</slide>

View File

@@ -0,0 +1,10 @@
<slide>
<title>Refactoring</title>
<list>
<bullet>Readability</bullet>
<bullet>Maintainability</bullet>
<bullet>Extensibility</bullet>
<bullet>Testability</bullet>
</list>
</slide>

View File

@@ -0,0 +1,59 @@
<slide>
<title>Implementations</title>
<div effect="fade-out">
<example><![CDATA[
$text .= "<ul{$idPart}>\n";
foreach ( $children as $child )
{
$path = $child[2]->nodes;
if ( !$this->options->displayRootNode )
{
array_shift( $path );
}
if ( $this->options->selectedNodeLink )
{
$slice = array_slice( $path, -1 );
$path = htmlspecialchars( $this->options->basePath . '/' . array_pop( $slice ) );
}
else
{
$path = htmlspecialchars( $this->options->basePath . '/' . join( '/', $path ) );
}
$text .= str_repeat( ' ', $level + 2 );
$data = $this->formatData( $child[1], in_array( $child[0], $this->options->highlightNodeIds ) );]]></example>
</div>
<div effect="fade-in">
<example><![CDATA[
foreach ( $children as $child )
{
$text .= str_repeat( ' ', $level + 2 );
$path = $this->formatPath( $child );
$data = $this->formatData( $child[1], in_array( $child[0], $this->options->highlightNodeIds ) );
]]></example>
<example><![CDATA[
protected function formatPath( $child )
{
$path = $child[2]->nodes;
if ( !$this->options->displayRootNode )
{
array_shift( $path );
}
if ( $this->options->selectedNodeLink )
{
$slice = array_slice( $path, -1 );
$path = htmlspecialchars( $this->options->basePath . '/' . array_pop( $slice ) );
}
else
{
$path = htmlspecialchars( $this->options->basePath . '/' . join( '/', $path ) );
}
return $path;
}
]]></example>
</div>
</slide>

View File

@@ -0,0 +1,9 @@
<slide>
<title>Testability</title>
<list>
<bullet>Test driven development</bullet>
<bullet>Code is written in small blocks</bullet>
<bullet>Makes the API better</bullet>
</list>
</slide>

View File

@@ -2,5 +2,5 @@
<slide fontsize="6em">
<title>Questions</title>
<blurb class="q_mark" align="center" marginleft="0" marginright="0" fontsize="16em">?</blurb>
<blurb class="q_mark center-page" align="center" marginleft="0" marginright="0" fontsize="16em">?</blurb>
</slide>

View File

@@ -10,6 +10,7 @@
<bullet>PHP development</bullet>
<bullet>Author of the mcrypt, input_filter, dbus, translit and date/time extensions</bullet>
<bullet>Author of Xdebug</bullet>
<bullet>Contributor to the Apache Zeta Components Incubator project (formerly eZ Components)</bullet>
<bullet>Freelancer doing PHP (internals) development</bullet>
</list>