<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Professional PHP &#187; design-patterns</title>
	<atom:link href="http://www.procata.com/blog/archives/tag/design-patterns/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.procata.com/blog</link>
	<description>PHP Programming, Web Development, PHP Advocacy and PHP Best Practices.</description>
	<lastBuildDate>Fri, 10 Dec 2010 17:23:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The Evolution of Design Patterns</title>
		<link>http://www.procata.com/blog/archives/2006/01/31/the-evolution-of-design-patterns/</link>
		<comments>http://www.procata.com/blog/archives/2006/01/31/the-evolution-of-design-patterns/#comments</comments>
		<pubDate>Tue, 31 Jan 2006 18:59:22 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Agile Methods]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software Design]]></category>
		<category><![CDATA[books]]></category>
		<category><![CDATA[design-patterns]]></category>
		<category><![CDATA[dynamic-typing]]></category>

		<guid isPermaLink="false">http://www.procata.com/blog/?p=172</guid>
		<description><![CDATA[Rebecca Wirfs-Brock suggests that it may be time for the GoF Design Patterns book to be refreshed.  She points out that the C++ and graphics programming examples may be less relevant to today&#8217;s C# and Java programmers.  She implies that state of the art has advanced in the twelve years since the book [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.wirfs-brock.com/2006/01/pattern-drift.html">Rebecca Wirfs-Brock suggests</a> that it may be time for the GoF <a href="http://www.amazon.com/exec/obidos/redirect?link_code=ur2&#038;tag=procata&#038;camp=1789&#038;creative=9325&#038;path=http%3A%2F%2Fwww.amazon.com%2Fgp%2Fproduct%2F0201633612%2Fqid%3D1138731933%2Fsr%3D2-1%2Fref%3Dpd_bbs_b_2_1%3Fs%3Dbooks%26v%3Dglance%26n%3D283155">Design Patterns</a> book to be refreshed.  She points out that the C++ and graphics programming examples may be less relevant to today&#8217;s C# and Java programmers.  She implies that state of the art has advanced in the twelve years since the book was written.  She also suggests that the GoF authors may have made some of the wrong tradeoffs when they specified some of the patterns.  </p>
<p>I know I would like to see an update to this groundbreaking work with more modern interpretations of what have become the canonical patterns.</p>
<p>Rebecca talks about how the interface type has come to replace the C++ abstract class.  One area that I am interested in is how <a href="http://en.wikipedia.org/wiki/Duck_typing">Duck typing</a> may replace the interface construct in many of the classic patterns.  I&#8217;m not sure that patterns intended for statically typed languages such as C++ and java necessarily have the same implementation in dynamically typed languages, such as smalltalk, Ruby and of course, PHP.</p>
<p>For the last few weeks, I&#8217;ve been doing an interesting educational exercise. I&#8217;ve been simultaneously reading <a href="http://www.amazon.com/exec/obidos/redirect?link_code=ur2&#038;tag=procata&#038;camp=1789&#038;creative=9325&#038;path=http%3A%2F%2Fwww.amazon.com%2Fgp%2Fproduct%2F0201633612%2Fqid%3D1138731933%2Fsr%3D2-1%2Fref%3Dpd_bbs_b_2_1%3Fs%3Dbooks%26v%3Dglance%26n%3D283155">Design Patterns</a>, <a href="http://www.amazon.com/exec/obidos/redirect?link_code=ur2&#038;tag=procata&#038;camp=1789&#038;creative=9325&#038;path=http%3A%2F%2Fwww.amazon.com%2Fgp%2Fproduct%2F0201485672%2Fqid%3D1138732395%2Fsr%3D2-1%2Fref%3Dpd_bbs_b_2_1%3Fs%3Dbooks%26v%3Dglance%26n%3D283155">Refactoring</a>, <a href="http://www.amazon.com/exec/obidos/redirect?link_code=ur2&#038;tag=procata&#038;camp=1789&#038;creative=9325&#038;path=http%3A%2F%2Fwww.amazon.com%2Fgp%2Fproduct%2F0321213351%2Fqid%3D1138732395%2Fsr%3D2-2%2Fref%3Dpd_bbs_b_2_2%3Fs%3Dbooks%26v%3Dglance%26n%3D283155">Refactoring to Patterns</a>, and <a href="http://www.amazon.com/exec/obidos/redirect?link_code=ur2&#038;tag=procata&#038;camp=1789&#038;creative=9325&#038;path=http%3A%2F%2Fwww.amazon.com%2Fgp%2Fproduct%2F0135974445%2Fqid%3D1138732599%2Fsr%3D2-1%2Fref%3Dpd_bbs_b_2_1%3Fs%3Dbooks%26v%3Dglance%26n%3D283155">Agile Software Development</a>.  I&#8217;m finding the cross-referencing between each of these highly complementary books to be be educational.  I&#8217;m hoping to add <a href="http://www.amazon.com/exec/obidos/redirect?link_code=ur2&#038;tag=procata&#038;camp=1789&#038;creative=9325&#038;path=http%3A%2F%2Fwww.amazon.com%2Fgp%2Fproduct%2F0201184621%2Fref%3Dwl_it_dp%3F%255Fencoding%3DUTF8%26colid%3D340RCXJY0586F%26coliid%3DISXN6HUYWJS3O%26v%3Dglance%26n%3D283155">Design Patterns Smalltalk Companion</a> and <a href="http://www.amazon.com/exec/obidos/redirect?link_code=ur2&#038;tag=procata&#038;camp=1789&#038;creative=9325&#038;path=http%3A%2F%2Fwww.amazon.com%2Fgp%2Fproduct%2F0973589825%2Fqid%3D1138732845%2Fsr%3D1-1%2Fref%3Dsr_1_1%3Fs%3Dbooks%26v%3Dglance%26n%3D283155">PHP|Architect&#8217;s Guide to PHP Design Patterns</a> (<a href="http://blog.casey-sweat.us/">Jason Sweat&#8217;s</a> book) to get a more dynamic perspective in the mix.  This is my reading project for the next few months.</p>
<p>That 10 years after first reading the Design Patterns book, i am still studying from it shows how much of a classic this book has become.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.procata.com/blog/archives/2006/01/31/the-evolution-of-design-patterns/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Building a culture of objects in PHP</title>
		<link>http://www.procata.com/blog/archives/2006/01/13/building-a-culture-of-objects-in-php/</link>
		<comments>http://www.procata.com/blog/archives/2006/01/13/building-a-culture-of-objects-in-php/#comments</comments>
		<pubDate>Fri, 13 Jan 2006 07:36:25 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[active-record]]></category>
		<category><![CDATA[design-patterns]]></category>
		<category><![CDATA[late-static-binding]]></category>
		<category><![CDATA[object-oriented-programming]]></category>
		<category><![CDATA[oop]]></category>
		<category><![CDATA[zend-framework]]></category>

		<guid isPermaLink="false">http://www.procata.com/blog/?p=150</guid>
		<description><![CDATA[This is a follow up post to Why isn&#8217;t PHP the natural successor to Java?
Joshua Eichorn (among others) notices that active record can&#8217;t work as shown in the Zend Framework webcast.  The syntax presented during the web cast is not possible in PHP because of inherited static methods are treated.  Mike Naberezny notes [...]]]></description>
			<content:encoded><![CDATA[<p>This is a follow up post to <a href="http://www.procata.com/blog/archives/2005/09/29/why-isnt-php-the-natural-successor-to-java/">Why isn&#8217;t PHP the natural successor to Java?</a></p>
<p>Joshua Eichorn (<a href="http://shiflett.org/archive/171">among others</a>) notices that <a href="http://blog.joshuaeichorn.com/archives/2006/01/09/zactiverecord-cant-work/">active record can&#8217;t work</a> as shown in the <a href="http://www.procata.com/blog/archives/2005/12/05/zend-framework-webcast/">Zend Framework webcast</a>.  The syntax presented during the web cast is not possible in PHP because of inherited static methods are treated.  Mike Naberezny notes the problem and suggests that it will end up getting fixed in PHP:</p>
<blockquote><p>Weâ€™ve been working on the solution to the problem with statics on the C front, so eventually it will be solved there.</p></blockquote>
<p>In the sitepoint thread <a href="http://www.sitepoint.com/forums/showthread.php?t=334377">Trouble in Zend Framework Land?</a>, 33degrees smells vaporware:</p>
<blockquote><p>I find it amusing that they did the webcast using that syntax, while there is currently no way of implementing it in PHP5. Makes you wonder how much code they&#8217;d actually written at that point.
</p></blockquote>
<p><a href="http://elizabethmariesmith.com/2006/01/09/annoying-statics-in-php/">Elizabeth Marie Smith</a> does too and adds:</p>
<blockquote><p>
I find it rather annoying that they havenâ€™t fixed the problem BEFORE now &#8211; after all, the bugs (marked bogus or wont fix because obviously the zend guys werenâ€™t using php5 at that point if they didnâ€™t see the problem until zend framework came along) the bugs/requests have been around for a LONG TIME
</p></blockquote>
<p>I look at this incident as an incredibly good omen.  My optimism about Zend&#8217;s PHP framework is not for the framework itself, but for what it means for OO support in PHP.  In my book, the more developers that have commit access to both ZPF and to PHP, the better PHP 6 will be for me.  I look at ZPF as an important step in building a culture of objects in the PHP community.</p>
<p>What?</p>
<p>In my previous post, I talked about how the leaders of the agile development culture seemed to be migrating from Java to Ruby with nary a glance at PHP.  One of the reasons is that PHP lacks a culture of objects.</p>
<p>Support for object oriented constructs in PHP is relatively new, rough, and uneven.  PHP competetors Ruby, Python, Java, and .NET all have OO class libraries, yet PHP does not.  The classes and interfaces that PHP does have are not necessarily what I would hold up as paragons of modern OO design.  </p>
<p>I can see why this would be the case. PHP is written in C.  Being an <a href="http://www.procata.com/blog/archives/2005/05/10/expert-programmers/">expert</a> in C programming does not necessarily make one an expert in object oriented programming (nor does it preclude it).  My impression from reading the php-dev mailing list is that of a C culture rather than a object culture.  (witness the <a href="http://www.procata.com/blog/archives/2004/07/29/goto-in-php/">goto vs exceptions</a> debate.)</p>
<p>I&#8217;ll save any critique of PHP&#8217;s built in classes for OO for future blog posts.  Instead, lets look at PHP&#8217;s documentation.  I regard PHP&#8217;s online documentation as excellent.  Its one of the factors that drew me to PHP in the first place.  I especially like the comments system.  Yet, go the the <a href="">front page</a> and search for one of the built in classes.  Try &#8220;exception.&#8221;  Helpful?  Did you know to switch the dropdown from the default functions option first?  I&#8217;d like to link to the documentation for the Exception class.  Where should I link?  Classes are not first class citizens in the PHP manual as functions are.</p>
<p>Try searching for the &#8216;getTraceAsString&#8217; method of the Exception class.  I&#8217;d like to leave a comment about it, where should I go?</p>
<p>My purpose is not to run down PHP&#8217;s support for objects.  Merely to suggest that there is more work yet to be done for first class support.</p>
<p>Ok, so PHP doesn&#8217;t exactly have a culture of objects.  Who cares about objects?</p>
<p>To answer that, I want to explore the complex relationship between PHP and Zend.  A good way to highlight the distinction is to look at the PHP usage numbers and the adoption rates for PHP 5.  While web hosts account for the vast majority of the PHP <a href="http://www.php.net/usage.php">usage numbers</a> as reported, they have been <a href="http://www.nexen.net/interview/index.php?id=50">slow to convert to PHP 5</a>.  On the other hand, <a href="http://www.internetnews.com/ent-news/article.php/3573486">Zend reports</a> that 50% of their customers have adopted PHP 5, suggesting that Zend&#8217;s customers are a bit different than the general PHP using population.</p>
<p>I think the PHP 5 adoption rates show that Zend&#8217;s customers care about objects. I suspect that some of the object support in PHP 5 is a result of feedback from Zend&#8217;s customers.</p>
<p>Zend is not a charity.  I would imagine the ZPF project consumes a great number of resources and they are doing it for a reason.  I think Zend&#8217;s customers also care about frameworks.  It sure looks to me like the ZPF project was triggered by Rails.</p>
<p>So somewhere in the ZPF project, they should be trying to do the same thing in rails and in ZPF and comparing the code.  (if they don&#8217;t there are a bunch of bloggers, me included, who will do it for them.)  I&#8217;m sure their customers will do it too.  Perhaps the Active Record syntax shown in the webcast was inspired from such a comparison?  I think that in order to look good in these comparisons, some aspects of PHP&#8217;s object support are going to have to be improved.  Static inheritance won&#8217;t be the last thing to get fixed.</p>
<p>Its is the zend framework effort thats going to put the finish on what PHP 5 started.  I honestly believe that PHP 6 is going to end up a runaway success.  (Is it still true that only the even numbered star trek moves are good?)</p>
<p>So if PHP doesn&#8217;t exactly have the best reputation as an object oriented language, what can we do about it.  Or specifically, what can Zend do about it?</p>
<p>Well, when Microsoft was being criticized for the lack of patterns in their PetStore example, what did the do?  One, they fixed it.  Two, they hired Martin Fowler&#8217;s company to <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpatterns/html/esp.asp">write about .net patterns</a>.  Ever notice how many .Net patterns there are in Martin Fowler&#8217;s Patterns of Enterprise Application Architecture Book?</p>
<p>I&#8217;d like to see Zend hire a reputable object guru to help PHP turn around its object reputation.  This should be someone who is known outside the PHP community, someone who has been going to OOPSLA for longer than PHP has existed.  Someone who has a book on object oriented programming, articles, a blog, and who is an expert at teaching object oriented programming (<a href="http://www.procata.com/blog/archives/2005/05/10/expert-programmers/">10 years to be an expert</a>).  Writing and teaching help hone ones thoughts and this job requires a communicator.</p>
<p>To start, Zend can put this person to work both advising on ZPF and telling the world about ZPF.  However, I would hope a longer term goal would be to apply some deep experience in coordinating and advising on the classes and interfaces that are going into the language itself.</p>
<p>I would hate to see the sales objection &#8220;php&#8217;s functions are inconsistent&#8221; morph into &#8220;php&#8217;s classes are inconsistent.&#8221;  Not only that, today&#8217;s class and interface designs are going to be around a long time.  Public refactoring is not a good in a language class library or in a widely used framework.  Witness the slow adoption of PHP 5 and the problems with reference changes in 4.4, 5.0.5.  Deep experience can help get a better design at the outset.</p>
<p>I for one welcome our new object oriented overlords.  <img src='http://www.procata.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.procata.com/blog/archives/2006/01/13/building-a-culture-of-objects-in-php/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

