<?xml version="1.0" encoding="utf-8"?>
<!-- generator="wordpress/2.1.2" -->
<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/"
	>

<channel>
	<title>Professional PHP</title>
	<link>http://www.procata.com/blog</link>
	<description>PHP Programming, Web Development, PHP Advocacy and PHP Best Practices.</description>
	<pubDate>Mon, 12 May 2008 05:04:21 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.1.2</generator>
	<language>en</language>
			<item>
		<title>Benchmarking PHP&#8217;s Magic Methods</title>
		<link>http://www.procata.com/blog/archives/2007/11/04/benchmarking-phps-magic-methods/</link>
		<comments>http://www.procata.com/blog/archives/2007/11/04/benchmarking-phps-magic-methods/#comments</comments>
		<pubDate>Mon, 05 Nov 2007 00:01:02 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Software Design]]></category>
<category>benchmarks</category><category>performance optimization</category><category>profiling</category>
		<guid isPermaLink="false">http://www.procata.com/blog/archives/2007/11/04/benchmarking-phps-magic-methods/</guid>
		<description><![CDATA[Larry Garfield has an interesting set of benchmarks covering many of PHP&#8217;s magic methods.  His results correspond pretty well to my own benchmarks in the area.  The thing to take away is that its not necessarily the overhead of the magic methods, but rather what you do inside them.  Its hard to [...]]]></description>
			<content:encoded><![CDATA[<p>Larry Garfield has an interesting <a href="http://www.garfieldtech.com/blog/magic-benchmarks">set of benchmarks</a> covering many of PHP&#8217;s <a href="http://php.net/oop5.magic">magic methods</a>.  His results correspond pretty well to my own benchmarks in the area.  The thing to take away is that its not necessarily the overhead of the magic methods, but rather what you do inside them.  Its hard to do anything useful inside a magic method, such as __get or __call that isn&#8217;t <b>10 to 20 times slower</b> than the &#8220;non-magic&#8221; solution.</p>
<p>There are probably more than a few naive programmers who would read results like this and start to avoid these constructs in their own code for performance reasons.  These are the same kinds of people obsessing over a few single or double quotes, who eschew &#8220;slow&#8221; objects in favor of switch statements that are many times slower than the polymorphic method calls they are trying to avoid.</p>
<p>But, that&#8217;s not the end of the story.  Larry ran his benchmarks using 2,000,000 iterations.  The <b>N</b> really matters here.  Sure, iterators are slower than arrays, but you aren&#8217;t going to be iterating over two million things.  I tend to fetch my database records in lots of 25 or 50.  You aren&#8217;t going to be making two million invocations of __call.  But how many will you make?  Under what value of N does the performance of these techniques cease to matter?  Is it ten, one hundred, one thousand, or ten thousand?  You may be surprised at how few calls your program actually does and how little impact it has on performance.</p>
<p>As <a href="http://netevil.org/">Wez</a> and <a href="http://www.travisswicegood.com/">Travis</a> point out in their comments, profiling is the way to find out the potential impact and to discover your true N.</p>
<p>Paul M. Jones has a <a href="http://paul-m-jones.com/blog/?p=182">good example</a> of what I&#8217;m talking about.  There, call_user_func_array appears to be a bottleneck, but it turns out that its the function being called, htmlspecialchars, not the calling process that consumes the balance of the time.  In that case, the function was &#8220;only&#8221; called 300 times.  I find that order of magnitude to be fairly typical.  Something to be aware of, perhaps, but not something to obsess over.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.procata.com/blog/archives/2007/11/04/benchmarking-phps-magic-methods/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Endpoints of the Scale of Stupidity on Video</title>
		<link>http://www.procata.com/blog/archives/2007/11/02/the-endpoints-of-the-scale-of-stupidity-on-video/</link>
		<comments>http://www.procata.com/blog/archives/2007/11/02/the-endpoints-of-the-scale-of-stupidity-on-video/#comments</comments>
		<pubDate>Fri, 02 Nov 2007 20:55:22 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Software Design]]></category>
<category>oop</category>
		<guid isPermaLink="false">http://www.procata.com/blog/archives/2007/11/02/the-endpoints-of-the-scale-of-stupidity-on-video/</guid>
		<description><![CDATA[A quote from Cal Henderson (via simonwillison) presents a &#8220;Web Application Scale of Stupidity:&#8221;

&#124; OGF (One Giant Function) ---- Sanity ---- OOP (Object Oriented Programming) &#124;

The scale that Cal is talking about is actually better known as modularity:

&#124; Few large modules ----  Sanity? ---- Many Small Modules &#124;

If you haven&#8217;t listened to Alan Kay [...]]]></description>
			<content:encoded><![CDATA[<p>A quote from Cal Henderson (via <a href="http://simonwillison.net/2007/Nov/2/cal/">simonwillison</a>) presents a &#8220;Web Application Scale of Stupidity:&#8221;<br />
<code><br />
| OGF (One Giant Function) ---- Sanity ---- OOP (Object Oriented Programming) |<br />
</code></p>
<p>The scale that Cal is talking about is actually better known as <a href="http://sunnyday.mit.edu/16.355/parnas-criteria.html">modularity</a>:</p>
<p><code><br />
| Few large modules ----  Sanity? ---- Many Small Modules |<br />
</code></p>
<p>If you haven&#8217;t listened to Alan Kay talk about the benefits of many small modules, you should do so now.  Alan Kay coined the term Object Oriented.  Love OO or hate OO, if you have an opinion on it, you should know what he was thinking.  Hint, it wasn&#8217;t C++.</p>
<p><embed style="width:400px; height:326px;" id="VideoPlayback" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=-2950949730059754521&#038;hl=en" flashvars=""> </embed></p>
<p>On the other end of the scale, One Giant Function is generally known as <a href="http://www.laputan.org/pub/foote/mud.pdf">Big ball of Mud</a>(PDF)  Here is Brian Foote&#8217;s presentation on the paper (read the paper first).</p>
<p><embed style="width:400px; height:326px;" id="VideoPlayback" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=8693679271218408739&#038;hl=en" flashvars=""> </embed></p>
]]></content:encoded>
			<wfw:commentRss>http://www.procata.com/blog/archives/2007/11/02/the-endpoints-of-the-scale-of-stupidity-on-video/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Let Your Properties be Properties</title>
		<link>http://www.procata.com/blog/archives/2007/05/08/let-your-properties-be-properties/</link>
		<comments>http://www.procata.com/blog/archives/2007/05/08/let-your-properties-be-properties/#comments</comments>
		<pubDate>Tue, 08 May 2007 17:41:51 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Software Design]]></category>
<category>php patterns</category><category>properties</category><category>refactoring</category>
		<guid isPermaLink="false">http://www.procata.com/blog/archives/2007/05/08/let-your-properties-be-properties/</guid>
		<description><![CDATA[There is a coding pattern that I see (and have used) in PHP code that defines generic methods on a class for setting and getting properties.
&#160;
function set&#40;$name, $value&#41;;
function get&#40;$name&#41;;
&#160;Google code search for examples
Some times there are some ancillary methods to deal with unsetting, checking for existence, setting via an array, or dealing with references in [...]]]></description>
			<content:encoded><![CDATA[<p>There is a coding pattern that I see (and have used) in PHP code that defines generic methods on a class for setting and getting properties.<br />
<pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> set<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$name</span>, <span style="color: #0000ff;">$value</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">function</span> get<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$name</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre><a href="http://www.google.com/codesearch?hl=en&#038;lr=&#038;q=lang%3Aphp+function%5Cs%2Bset%5Cw*%5Cs*%5C%28%5Cs*%5C%24name%5Cs*%2C%5Cs*%26%3F%5Cs*%5C%24value%5Cs*%5C%29&#038;btnG=Search">Google code search for examples</a></p>
<p>Some times there are some ancillary methods to deal with unsetting, checking for existence, setting via an array, or dealing with references in PHP 4.  They can really clutter up the definition of a class.  That&#8217;s not good.  All this code is fairly standard, too, but it gets duplicated on every class that does this.  That&#8217;s not good, either.</p>
<p>Oh, I&#8217;ll solve this problem by making a base class, some may say.  Wrong.  This a very feeble reason to spend your one shot at inheritance.  Trust me, I know, I&#8217;ve done it.</p>
<p>I think the idea is to make the class extensible.  But PHP is really ok with just setting new properties on a class.<br />
<pre class="php">&nbsp;
<span style="color: #0000ff;">$obj</span>-&gt;<span style="color: #006600;">foo</span> = <span style="color: #ff0000;">'bar'</span>;
&nbsp;</pre><br />
So why not just do this?</p>
<p>Another variation of this pattern is to use setXXX($name, $value) or setYYY($name, $value) methods.  This happens alot with &#8220;options&#8221; or &#8220;vars&#8221; or &#8220;properties.&#8221;  It also happens on request wrapper classes.  To me this looks like there is an object here just begging to get out for each XXX and YYY.<br />
<pre class="php">&nbsp;
<span style="color: #0000ff;">$obj</span>-&gt;<span style="color: #006600;">xxx</span>-&gt;<span style="color: #006600;">prop</span> = <span style="color: #ff0000;">'foo'</span>;
<span style="color: #0000ff;">$obj</span>-&gt;<span style="color: #006600;">yyy</span>-&gt;<span style="color: #006600;">prop</span> = <span style="color: #ff0000;">'foo'</span>;
<span style="color: #0000ff;">$obj</span>-&gt;<span style="color: #006600;">zzz</span>-&gt;<span style="color: #006600;">prop</span> = <span style="color: #ff0000;">'foo'</span>;
&nbsp;</pre><br />
This eliminates a slew of property manipulation methods and leaves the original class free to implement its true purpose.  Methods of the form getXXX($name) and setXXX($name, $value) should be the solution of last resort.  </p>
<p>Since I&#8217;ve started eliminating these in my own code in favor of direct properties, intermediate objects or __set and __get, I feel I&#8217;ve seen nothing but positive results.  Try it.  You may like it, too.  Let your properties be properties.</p>
<p><b>UPDATE:</b><br />
From reading the comments, I think there was some confusion about what I meant in this post.  I am not talking about using naked properties instead of accessor methods.  I&#8217;m not talking about accessor methods at all in this post.  A specific accessor method, such as<br />
<pre class="php"><span style="color: #0000ff;">$obj</span>-&gt;<span style="color: #006600;">getFoo</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></pre><br />
where the name of the property is part of the method name is very different than<br />
<pre class="php"><span style="color: #0000ff;">$obj</span>-&gt;<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'foo'</span><span style="color: #66cc66;">&#41;</span>;</pre><br />
Where you pass the name of the property as a string parameter.  Its only the latter pattern, where the property name is an actual parameter to the method, that I am talking about in this post and that I think should generally be refactored.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.procata.com/blog/archives/2007/05/08/let-your-properties-be-properties/feed/</wfw:commentRss>
		</item>
		<item>
		<title>On the Perils of Inline API Documentation</title>
		<link>http://www.procata.com/blog/archives/2007/04/13/on-the-perils-of-inline-api-documentation/</link>
		<comments>http://www.procata.com/blog/archives/2007/04/13/on-the-perils-of-inline-api-documentation/#comments</comments>
		<pubDate>Fri, 13 Apr 2007 15:55:26 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Software Design]]></category>
<category>api design</category><category>api documentation</category><category>docblocks</category><category>phpdocumentor</category>
		<guid isPermaLink="false">http://www.procata.com/blog/archives/2007/04/13/on-the-perils-of-inline-api-documentation/</guid>
		<description><![CDATA[Travis Swicegood has a post questioning the value of the docblock.  I have a deep sympathy with this sentiment.
Even on projects with extensive generated documentation, I find that kind of documentation to be of extremely low value.  The problem with inline API documentation is that there is no sense of priority.  Developers [...]]]></description>
			<content:encoded><![CDATA[<p>Travis Swicegood has a post <a href="http://www.travisswicegood.com/index.php/2007/04/11/programming_languages_are_declarative">questioning the value of the docblock</a>.  I have a deep sympathy with this sentiment.</p>
<p>Even on projects with extensive generated documentation, I find that kind of documentation to be of extremely low value.  The problem with inline API documentation is that there is no sense of priority.  Developers are encouraged to document every element that can possibly be documented. Then, when the documentation is generated, there is no way to distinguish the important from noise.</p>
<p>Another problem is restating the obvious.  When a property or method really is well named, there may not be much more to say in the docblock.  But, the mechanics of docblocks invites the programmer to say it anyway.  So, you end up with comments like &#8220;$widget the widget.&#8221;</p>
<p>Duplication is also a significant problem.  If you inherit from a base class or you implement an interface, there is a tendency to copy and paste the doc block from the parent to the children.  This is an obvious maintenance problem.  In fact, this is one of the major problems with comments.  If comments restate what the code does, its a form of code duplication.  When the code is changed, it requires changes in the comments.  In this sense, comments make code harder to maintain.</p>
<p>Lately, I&#8217;ve been trying to curb the <a href="http://en.wikipedia.org/wiki/Attractive_nuisance_doctrine">attractive nuisance</a> aspect of docblock comments by replacing docblocks with comments like<br />
<pre class="php">&nbsp;
<span style="color: #808080; font-style: italic;">// Definition in parent</span>
&nbsp;</pre><br />
 or<br />
<pre class="php">&nbsp;
<span style="color: #808080; font-style: italic;">// docblock intentionally omitted.</span>
&nbsp;</pre><br />
It would be nice if there were standard abbreviations for things like these.  The idea being to eliminate the attractive nuisance of the commentable element by placing a comment there that is not a docblock, and then commenting only the elements where you have something to say.</p>
<p>Well, if docblocks are so bad, what is the alternative?  Well, I&#8217;ve tried a few, including using a wiki for API documentation.  Here is the problem.  If duplication between the comment and the code is created by inline documentation, that maintenance problem becomes significantly worse with distance.  If the documentation is external to the code, that distance really harms the ability to keep the documentation in sync with the code.  So, docblocks are bad, but everything else is worse.</p>
<p>Docblocks were popularized by Sun and Java (or maybe Donald Knuth).  But when sun was documenting their Java APIs with docblocks, they had a professional documentation team to do the work.  When teams that don&#8217;t have a dedicated documenter role use these tools, I think they fall short.</p>
<p>So what is the solution?  I&#8217;d like to see better techniques and conventions for solving the problems of docblocks: avoiding duplication, avoiding restating the obvious, and avoiding the tendency to docblock everything thats docblockable.  Maybe there are more successful documenters out there who are handling these API documentation anti-patterns better than I am.  I&#8217;d sure like to hear how.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.procata.com/blog/archives/2007/04/13/on-the-perils-of-inline-api-documentation/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Software Development Team Diversity</title>
		<link>http://www.procata.com/blog/archives/2007/03/26/software-development-team-diversity/</link>
		<comments>http://www.procata.com/blog/archives/2007/03/26/software-development-team-diversity/#comments</comments>
		<pubDate>Mon, 26 Mar 2007 14:00:24 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
		
		<category><![CDATA[Agile Methods]]></category>

		<category><![CDATA[Software Design]]></category>
<category>agile php</category><category>extreme programming</category><category>hiring</category><category>programmer education</category><category>programming</category>
		<guid isPermaLink="false">http://www.procata.com/blog/archives/2007/03/26/software-development-team-diversity/</guid>
		<description><![CDATA[Matt Mullenweg has a post about Hiring Diversity.    A successful software project must fulfill many competing goals and factors and meet a wide variety of challenges.   Diversity is the combined arms of software development.  In my personal experience, the diverse team performs better.  A diverse team allows the [...]]]></description>
			<content:encoded><![CDATA[<p>Matt Mullenweg has a post about <a href="http://photomatt.net/2007/03/24/kapor-vs-zuckerberg/">Hiring Diversity</a>.    A successful software project must fulfill many competing goals and factors and meet a wide variety of challenges.   Diversity is the combined arms of software development.  In my personal experience, the diverse team performs better.  A diverse team allows the most appropriate team member to step up to a challenge.  The interaction between team members with different points of view helps a project balance competing goals.</p>
<h3>Technical Background</h3>
<p>A team needs members with a technical background.  These guys are the ones that ensure everything works.  They can write the hard bits of code, keep everything performing and make sure the code is maintainable.  Without these guys, you will have problems.  On the other hand, sometimes those with a technical background view problems solving as a puzzle, where the solution is the end in itself.<br />
In my experience, team members with a less technical background are more empathic toward the user community.  They view problem solving as a means to a goal.  A customer focus is what makes a project successful.  Software can be successful despite technical problems, but it cannot be successful if doesn&#8217;t meet the customer&#8217;s needs.  Having some non-technical people helps prevent your resident technocrats from building a system that will service 10,000 concurrent users, but doesn&#8217;t meet the needs of the 329 users you have today.<br />
Perhaps at the extreme end of this spectrum is the extreme programming practice of including a customer on the development team.</p>
<h3>Experience</h3>
<p>In <a href="http://www.procata.com/blog/archives/2005/05/10/expert-programmers/">expert versus novice programmers</a>, I make the distinction between skill level and experience.  Age, skill and experience often correlate, but not always.  Your young apprentice programmers are important to have on a team.  They can react faster.  Sometimes not knowing better is a bonus.  They&#8217;ll do things more senior team members don&#8217;t want to do.  They do things they&#8217;re not supposed to do, sometimes for the benefit of the team.<br />
I think people underestimate how long it takes to actually become an expert, as I mention in my previous post.  But, then they also underestimate how similar all software projects are.  They also overestimate the impact of their toolset.  Generally the technologies in the laundry lists that form most job listings are not the critical success factors for that project.<br />
People want a programmer with who can hit the ground running, who is familiar with all of the teams tools, languages and libraries.  But, this is a monoculture as well.  Sometimes you need people who aren&#8217;t from your toolset culture to point out where you have swallowed the hook too deeply or to introduce new tools and techniques from their alternate background.  Sometimes their learning process can teach you something.<br />
While some experience is valued in programmers, age sometimes isn&#8217;t.  However, you need the older, more stable people as well.  They keep the young ones from repeating the mistakes of the past.  They keep the project on an even keel.  It helps to have an older perspective on the team.  I think they help keep attention focused on what matters.  The tension between the older and younger team members helps keep the team on track.</p>
<h3>Traditional Diversity Factors</h3>
<p>I have no opinion on the impact of race.  I have an opinion about women on software teams.  I wish there were more of them.  I have worked on software development teams with diverse nationalities.  I regard that experience as positive.  Different cultures have different tolerances for risk, different respect for authority or tradition.  I think cultural diversity on a team is a good thing.</p>
<h3>Managing Diversity</h3>
<p>Over the years, there have been many methods proposed of matching people with the jobs they are best at.  The solution that works best is to ask them.  People gravitate toward the tasks that require their special skill sets.  Good team management means hiring diversely and allowing that migration.  On a well managed, diverse team, people will self select the jobs they are best at.  As a result, the diverse team is more resilient and I believe potentially more successful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.procata.com/blog/archives/2007/03/26/software-development-team-diversity/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Problem with Markup Languages</title>
		<link>http://www.procata.com/blog/archives/2007/03/14/the-problem-with-markup-languages/</link>
		<comments>http://www.procata.com/blog/archives/2007/03/14/the-problem-with-markup-languages/#comments</comments>
		<pubDate>Wed, 14 Mar 2007 17:30:14 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Usability]]></category>

		<category><![CDATA[Software Design]]></category>
<category>html markup</category><category>input filtering</category><category>markup languages</category><category>regular expressions</category><category>security</category><category>wiki syntax</category><category>wordpress</category>
		<guid isPermaLink="false">http://www.procata.com/blog/archives/2007/03/14/the-problem-with-markup-languages/</guid>
		<description><![CDATA[Chris Shiflett has a post today, Allowing HTML and Preventing XSS.  The problem is how to allow users to format their contributed content without introducing security vulnerabilities.  The answer is usually some sort of markup language or filtering and sanitization of HTML.
BBCODE was designed for this purpose.  There is no actual standard, [...]]]></description>
			<content:encoded><![CDATA[<p>Chris Shiflett has a post today, <a href="http://shiflett.org/blog/2007/mar/allowing-html-and-preventing-xss">Allowing HTML and Preventing XSS</a>.  The problem is how to allow users to format their contributed content without introducing security vulnerabilities.  The answer is usually some sort of markup language or filtering and sanitization of HTML.</p>
<p>BBCODE was designed for this purpose.  There is no actual standard, but the core syntax seems fairly uniform.  It&#8217;s good for those used to forums, where it seems to norm.</p>
<p>HTML markup is nice because it is a standard, even if varying subsets are supported.  Learning a little HTML isn&#8217;t going to hurt anyone, at least for the next 20 years or so.  The problem is that HTML was never intended to be hand edited.  The syntax is not the most inviting, and different HTML-like markup languages handle whitespace differently than the HTML standard.</p>
<p>Wiki markup syntaxes were designed to be human friendly. The main problem I have with wiki syntax is that there is no standard.  It seems like every wiki has a different way to formulate a link, for example.  I guess there is some progress with <a href="http://www.wikicreole.org/">Wiki Creole</a>, but I still have a bad taste in my mouth.</p>
<p>The other problem I have with wiki markup is that I find it to be non-deterministic.  When I edit any given wiki and try to use more than basic formatting, I never know what I am going to get.  Most of the markup processing engines for these wikis are impenetrable morasses of regular expressions.  It can be hard to gauge interactions.  Are you really sure they are secure?</p>
<p>Speaking of impenetrable morasses of regular expressions, have you ever looked at WordPress&#8217;s input path?  I&#8217;m sure every one with a WordPress blog who likes to blog about PHP code knows that it is a code eater.  I&#8217;ve been particularly disappointed with WordPress in this area.  Most the &#8220;code formatting&#8221; plugins still have problems protecting code from WordPress&#8217; heavy hand.</p>
<p>But the WordPress preg_replace gauntlet doesn&#8217;t just mangle code.  I have a post which has been sitting in draft mode for several weeks because I can&#8217;t figure out how to give it the proper markup.  WordPress is somehow taking my perfectly balanced input markup and producing &#8220;unbalanced&#8221; output markup.  I haven&#8217;t yet tracked down the problem to either submit a fix or to do a good bug report.  Frankly, I&#8217;m not looking forward to trudging through all those regular expressions.</p>
<p>In Chris&#8217; post, he takes the regular expression approach.  Folks in the comments have pointed out a few problems with his approach, including the problem of interleaved tags.  If you can&#8217;t tell by now, I am not a fan of the regular expression gauntlet approach to markup languages.  I prefer a defined syntax and a traditional computer science style parser (which may use regular expressions).</p>
<p>The other must-have is a preview option.  With so much variation in markup languages, not having a preview leaves the user to play Russian roulette with their submitted content.  I&#8217;ve talked about that before in the <a href="http://www.procata.com/blog/archives/2005/03/31/the-usability-of-input-filtering/">usability of input filtering</a>.  This is another area where WordPress leaves the user high and dry.  </p>
<p>The complex input path in WordPress combined with its reliance on global variables seems to leave it unable to do an in-page preview.  The admin area preview is an IFRAME so that it launches a separate request.  The various live preview plugins are JavaScript based and don&#8217;t work when it is disabled.  They also don&#8217;t pass the input through the same input path that WordPress uses, so they are not a true preview.</p>
<p>I don&#8217;t mean for this to be a WordPress rant, on the whole, I like WordPress.  Rather, I just wanted to point out how hard it can be to do good input filtering, that is safe, reliable, deterministic, and usable.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.procata.com/blog/archives/2007/03/14/the-problem-with-markup-languages/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Delphi for PHP</title>
		<link>http://www.procata.com/blog/archives/2007/02/23/delphi-for-php/</link>
		<comments>http://www.procata.com/blog/archives/2007/02/23/delphi-for-php/#comments</comments>
		<pubDate>Fri, 23 Feb 2007 18:55:39 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Open Source]]></category>

		<category><![CDATA[Software Design]]></category>
<category>delphi</category><category>delphi for php</category><category>delphi4php</category><category>php</category><category>vcl</category><category>vcl4php</category>
		<guid isPermaLink="false">http://www.procata.com/blog/archives/2007/02/23/delphi-for-php/</guid>
		<description><![CDATA[I have to comment on this week&#8217;s annoucement of Delphi for PHP.  I was a Delphi programmer for about 5 years before taking up PHP about 6 years ago.  What a convergence.
I have a great fondness and respect for the old Object Pascal based Delphi.  Delphi&#8217;s VCL has been influential, inspiring the [...]]]></description>
			<content:encoded><![CDATA[<p>I have to comment on this week&#8217;s annoucement of <a href="http://www.codegear.com/Products/Delphi/DelphiforPHP/tabid/237/Default.aspx">Delphi for PHP</a>.  I was a Delphi programmer for about 5 years before taking up PHP about 6 years ago.  What a convergence.</p>
<p>I have a great fondness and respect for the old Object Pascal based Delphi.  Delphi&#8217;s VCL has been influential, inspiring the GUI components in Java.  And, of course <a href="http://en.wikipedia.org/wiki/Anders_Hejlsberg">Ander Heijlsberg</a> went on to put a huge stamp on C# and .NET that would be familiar to any Delphi programmers.</p>
<p>I&#8217;ve always admired this approach of extending the language syntax to make common things easy and for the integration between the language and the tools. In Delphi, this was evidenced by the excellent properties support.  Six years later, this is the feature I miss the most in PHP.  This language extension approach has seen its culmination in C# and <a href="http://msdn2.microsoft.com/en-us/netframework/aa904594.aspx">LINQ</a>.  It almost pains me to say it, but the cutting edge of commercial language design is at Microsoft now.</p>
<p>On the other hand, I&#8217;ve never had that much respect for Borland as a company. We were big enough to have Borland representative&#8217;s come to our office and try sell us their products.  They were terrible at the mechanics of selling into big companies.  I was in their beta programs.  I went to their conferences.  I&#8217;ve never had any sense that they know what they are doing business wise.  Inprise?  What were they thinking?  Now here they are, just having gotten their asses kicked by eclipse in the Java IDE space and what are they working on?  They release an IDE for PHP, just as Zend is embracing Eclipse in the PHP space.  Brilliant!</p>
<p>I don&#8217;t quite know what Delphi means now.  To me, its always been and IDE plus Object Pascal.  What is it now? I also don&#8217;t quite know what Borland has become.  Is it <a href="http://www.codegear.com/">CodeGear</a> now?  I guess that the Delphi for PHP IDE comes from <a href="http://www.qadram.com/">Quadram</a> and their now discontinued QStudio product.  And the VCL is their WCL (no linkage found).  Anytime I&#8217;ve been touched by the corporate entity that was Borland, confusion ensued.  I&#8217;m confused now.</p>
<p>It appears that the <a href="http://sourceforge.net/projects/vcl4php">PHP version of the VCL</a> will be released on open source.  There is nothing at the sourceforge project, yet, but I&#8217;ll be interested to see what it looks like, if only for old times sake.</p>
<p>The Delphi tool approach was to serialize an object based representation of an application, then offer tools to create that serialized representation, and to load that representation at run time.  In Delphi, that serialization was done into the form files (.DFM).  I&#8217;ll be interested to see how Delphi for PHP does it.  Perhaps, this is an area where the <a href="http://www.zend.com/pdt">Eclipse PHP Development Tool</a> can learn. I know that I definitely had Delphi in mind when I was writing my column  on <a href="http://www.phparch.com/issue.php?mid=98">Object Serialization</a> for this month&#8217;s php | Architect.</p>
<p>Meanwhile, if you want to see the Delphi influence in PHP with code that you can download today, take a look at the <a href="http://www.xisc.com/">Prado</a> framework, which I imagine to be like the VCL for PHP, but without the supporting IDE.</p>
<p>This is a space I&#8217;ll definitely be watching.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.procata.com/blog/archives/2007/02/23/delphi-for-php/feed/</wfw:commentRss>
		</item>
		<item>
		<title>OOP is Mature, not Dead</title>
		<link>http://www.procata.com/blog/archives/2007/01/07/oop-is-mature-not-dead/</link>
		<comments>http://www.procata.com/blog/archives/2007/01/07/oop-is-mature-not-dead/#comments</comments>
		<pubDate>Sun, 07 Jan 2007 20:51:16 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Software Design]]></category>
<category>closures</category><category>late static binding</category><category>object oriented programming</category><category>oop</category><category>php</category><category>properties</category><category>uniform access principle</category>
		<guid isPermaLink="false">http://www.procata.com/blog/archives/2007/01/07/oop-is-mature-not-dead/</guid>
		<description><![CDATA[I ran across an interesting series of blog posts by Karsten Wagner claiming that OOP is dead (part 2 and part 3).  The premise behind these posts is that OOP has failed to deliver and that it is on the decline in favor of more functional or meta programming techniques.  Maybe its true [...]]]></description>
			<content:encoded><![CDATA[<p>I ran across an interesting series of blog posts by Karsten Wagner claiming that <a href="http://kawagner.blogspot.com/2006/08/oop-is-dead.html">OOP is dead</a> (<a href="http://kawagner.blogspot.com/2006/08/oop-is-dead-part-2.html">part 2</a> and <a href="http://kawagner.blogspot.com/2006/08/oop-is-dead-part-3.html">part 3</a>).  The premise behind these posts is that OOP has failed to deliver and that it is on the decline in favor of more functional or meta programming techniques.  Maybe its true that the discussion of the merits of OOP is on the decline.  At least if you read <a href="http://reddit.com/">reddit</a>.</p>
<p>However, OOP is not on the decline.  Quite simply, it has become mature.  The discussion may be on the decline because almost every language that anyone actually uses implements a core set of OOP features.  OOP has won its arguments.  Good luck taking a language mainstream without it.</p>
<p>Oh, yeah, there are some OOP features that are still controversial or unusual.  There is the single versus multiple inheritance debate, or perhaps Ruby&#8217;s open classes.  But, I think these things have a way of cross-pollinating across the popular languages when they make sense.</p>
<p>A good example of this cross-pollination is happening now with properties, accessor methods and the <a href="http://en.wikipedia.org/wiki/Uniform_access_principle">uniform access principle</a>.  Language support for declared accessor method is slowly creeping across all of the major languages.  Not that Objective C is all that popular, but <a href="http://developer.apple.com/leopard/overview/tools.html">Objective C 2.0</a> adds support for &#8216;em.  Even stodgy old Java is considering <a href="http://www.javalobby.org/java/forums/t88090.html">language level property support</a>.</p>
<p>Sadly, PHP does not yet have language support for declared properties with accessor methods.  What are <a href="http://us2.php.net/manual/en/language.oop5.overloading.php">__get and __set</a>?  They&#8217;re property missing handlers, not accessor methods.  You can simulate accessor methods with them, but that is a poor solution for most applications.  There is no way to support differing visibility, for example protected setters and public getters.  Property not found handlers are prohibitively verbose to write, have a poor performance profile, have no capability for reflection, cause interoperability problems, and have inheritance edge case gotchas (not present in the java beans model, for example).  My hope is to see good language support for properties in PHP 6.</p>
<p>Closures may not be object oriented, but they seem to be undergoing that same language cross-pollination.  Thats seems to be a pretty good sign that they are useful.  It doesn&#8217;t have to be closures OR objects, it can be closures AND objects.  We can use each when they make sense.</p>
<p>Closures are another wish list item for PHP 6.  PHP is almost wired for them with its <a href="http://us2.php.net/callback">callback</a> psuedo type.  Everywhere you can use a callback in PHP, you could use a closure.  I&#8217;d like to see the callback Pinocchio become a real boy like integer or boolean.  The cool thing is that with PHP&#8217;s weak typing the string and array forms of the callback pseudo-type can automatically be converted to a native closure type when needed.</p>
<p>As I said, the core OOP features that most programmers use are in all the mainstream languages.  The interesting part is how they handle the OOP edge cases.  This is the space where the framework developers live.  As I wrote in <a href="http://www.procata.com/blog/archives/2006/01/13/building-a-culture-of-objects-in-php/">culture of objects</a>, PHP has some problems here.  In some ways I think Ruby&#8217;s support for edge cases is exactly what allow a framework such as rails to be built in it, although, I&#8217;m not familiar enough with Ruby to say for certain.</p>
<p>I think addressing some of these issues in PHP 6 will make it a Ruby killer for web applications.  It isn&#8217;t necessary to be perfect here, just to be good enough and allow the larger community, distribution, and stability to take over.  Unfortunately, there is a long lead time here.  If PHP 6  were to add support for declared accessor methods, closures, and late static binding &#8212; my top three framework enablers &#8212; it would still be at least 2-3 years before PHP 6 was sufficiently deployed and the frameworks could adapt to the new features.</p>
<p>In the meantime, while the PHP culture may have problems, the Ruby culture may not be without its own problems.  The influx of <a href="http://www.randomhacks.net/articles/2005/12/03/why-ruby-is-an-acceptable-lisp">lisp</a> and smalltalk programmers, two languages that did not go &#8220;mainstream&#8221; may <a href="http://beust.com/weblog/archives/000382.html">prevent Ruby from going mainstream</a>.  Take a look at <a href="http://blog.lostlake.org/index.php?/archives/11-The-Impending-Ruby-Fracture.html">The impending ruby fracture</a>.  Isn&#8217;t this one of the things that happened to SmallTalk and Lisp?  I&#8217;m still not convinced that Ruby hasn&#8217;t inherited many of the same maintenance problems from its Perl heritage.  Just like english, huh?  Only time will reveal Ruby&#8217;s maintenance characteristics.  I give it about 2 to 3 years for today&#8217;s Rails systems to hit full legacy mode. How long do you think it will take for top notch unicode support in Ruby?</p>
<p>Obviously PHP 6 is all about teh unicode.  Including an opcode cache is going to be an important performance and adoption driver.  However, I&#8217;d like to see more progress on framework enablers.  I really want to see these in the next major PHP deployment cycle and not in the PHP 7 deployment cycle.  Are there framework enablers other than closures, declared property accessors and late static binding that I have overlooked?</p>
<p>I have high hopes for PHP 6 as a mature and mainstream language.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.procata.com/blog/archives/2007/01/07/oop-is-mature-not-dead/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Looking forward to 2007</title>
		<link>http://www.procata.com/blog/archives/2007/01/04/looking-forward-to-2007/</link>
		<comments>http://www.procata.com/blog/archives/2007/01/04/looking-forward-to-2007/#comments</comments>
		<pubDate>Fri, 05 Jan 2007 03:49:50 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
		
		<category><![CDATA[Misc]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Usability]]></category>

		<category><![CDATA[Web Design]]></category>

		<category><![CDATA[Software Design]]></category>
<category>books</category>
		<guid isPermaLink="false">http://www.procata.com/blog/archives/2007/01/04/looking-forward-to-2007/</guid>
		<description><![CDATA[Well, I&#8217;m finally back in town after the holidays.  Let me tell you, I&#8217;m glad to be home.  Between multiple holidays and taking my grandma to her cancer treatments in Ann Arbor, I was gone far too much of last month.
My Grandma is doing well.  They used an experimental new procedure called [...]]]></description>
			<content:encoded><![CDATA[<p>Well, I&#8217;m finally back in town after the holidays.  Let me tell you, I&#8217;m glad to be home.  Between multiple holidays and taking my grandma to her cancer treatments in Ann Arbor, I was gone far too much of last month.</p>
<p>My Grandma is doing well.  They used an experimental new procedure called radio frequency ablation to remove the meta-static colon cancer tumors from her lungs.  This procedure is amazing compared to the standard treatment.  The doctors at the University of Michigan were impressive.  We&#8217;ll know the results in a couple months when her lungs look a little less like scrambled eggs.  We&#8217;re hopeful.</p>
<p>I&#8217;m not much for retrospectives.  Looking forward into 2007, I have a few major goals.  I joined a gym today.  I&#8217;m going to get a new laptop and refresh my development environment next week after MacWorld.  I want to get at least a beta release of WACT out by May.  I have to prepare for php|tek.  I need to find a new place to live by this fall.  (Ann Arbor?) I want to move by the end of the year.</p>
<p>I loved all my christmas and birthday gifts this year.  (My birthday is December 28th.)  This year I pointed everyone to my Amazon.com wishlist and I ended up with a ton of good books to read.  Jason Gillmore from Apress also sent me some web development books.  My to-read stack for 2007 includes:</p>
<ul>
<li><a href="http://www.amazon.com/exec/obidos/redirect?link_code=as2&#038;path=ASIN/0440509017&#038;tag=procata&#038;camp=1789&#038;creative=9325">The Promise of Sleep</a> - A survey of the subject of sleep for laymen, written by a top sleep researcher.  I&#8217;m almost done with this one.  This book has a bunch of sleep deprivation horror stories and a good survey of what is known about sleep, which is not much.  Its incredible that we know so little about something we spend so much time doing.  Its also amazing how many people have easily treatable sleep disorders that don&#8217;t even know it.  Do you snore?</li>
<li><a href="http://www.amazon.com/exec/obidos/redirect?link_code=as2&#038;path=ASIN/0321344758&#038;tag=procata&#038;camp=1789&#038;creative=9325">Don&#8217;t make me Think</a> - Looks like a nice overview book on web usability.</li>
<li><a href="http://www.amazon.com/exec/obidos/redirect?link_code=as2&#038;path=ASIN/0321125215&#038;tag=procata&#038;camp=1789&#038;creative=9325">Domain Driven Design</a> - Recommended by Jason and Marcus.  How did I get this far without reading this book?</li>
<li><a href="http://www.amazon.com/exec/obidos/redirect?link_code=as2&#038;path=ASIN/1400079179&#038;tag=procata&#038;camp=1789&#038;creative=9325">Da Vinci Code</a> - Wasn&#8217;t on my wishlist, but I&#8217;ll read it anyway.  I read so little fiction these days.  Where is a beach when you need one?</li>
<li><a href="http://www.amazon.com/exec/obidos/redirect?link_code=as2&#038;path=ASIN/0142000280&#038;tag=procata&#038;camp=1789&#038;creative=9325">Getting Things Done</a> - I&#8217;m almost through this one.  It is a testimony to the power of the ideas that this book expresses that so many people recommend it, despite its being so incredibly dull.  Useful?  Yes.  Inspiring?  No.  But, then I&#8217;ve read enough of these self help / personal productivity type books for a lifetime.  Anyone want to buy a Franklin Planner?  I used mine until I got a cell phone.</li>
<li><a href="http://www.amazon.com/exec/obidos/redirect?link_code=as2&#038;path=ASIN/1590597532&#038;tag=procata&#038;camp=1789&#038;creative=9325">Practical Subversion</a> - I&#8217;m really liking subversion.  If you haven&#8217;t tried it, do so.  I&#8217;m hoping to combine this with Greg Beaver&#8217;s book, <a href="http://www.amazon.com/exec/obidos/redirect?link_code=as2&#038;path=ASIN/1904811191&#038;tag=procata&#038;camp=1789&#038;creative=9325">The PEAR installer manifesto</a> &#8212; the book on my wishlist I most wanted that I didn&#8217;t get, to create a new deployment process.</li>
<li><a href="http://www.amazon.com/exec/obidos/redirect?link_code=as2&#038;path=ASIN/159059732X&#038;tag=procata&#038;camp=1789&#038;creative=9325">Pro CSS Techniques</a> - A CSS book that tackles maintainability?  I&#8217;m really looking forward to this one.</li>
<li><a href="http://www.amazon.com/exec/obidos/redirect?link_code=as2&#038;path=ASIN/159059505X&#038;tag=procata&#038;camp=1789&#038;creative=9325">Pro MySQL</a> - The last MySQL book I read was a couple years ago, yet I use it almost every day.  I&#8217;m due for a refresh.  This one looks good.</li>
<li><a href="http://www.amazon.com/exec/obidos/redirect?link_code=as2&#038;path=ASIN/1590595084&#038;tag=procata&#038;camp=1789&#038;creative=9325">Pro PHP Security</a> - Never hurts to brush up.  This one looks like it has alot on encryption, SSL and SSH; not strong areas for me.</li>
<li><a href="http://www.amazon.com/exec/obidos/redirect?link_code=as2&#038;path=ASIN/0471606952&#038;tag=procata&#038;camp=1789&#038;creative=9325">Pattern-Oriented Software ARchitecture Volume 2</a> - The first volume, <a href="http://www.amazon.com/exec/obidos/redirect?link_code=as2&#038;path=ASIN/0471958697&#038;tag=procata&#038;camp=1789&#038;creative=9325">A system of patterns</a>, is one of my &#8220;always within reach when developing&#8221; books.  Nice to add to the set.</li>
</ul>
<p>Thanks for the books, guys.  I&#8217;ll have in-depth reviews of some of these here in the future.</p>
<p>Happy New Year.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.procata.com/blog/archives/2007/01/04/looking-forward-to-2007/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Why is PHP Code Considered Hard to Maintain?</title>
		<link>http://www.procata.com/blog/archives/2006/11/09/why-is-php-code-considered-hard-to-maintain/</link>
		<comments>http://www.procata.com/blog/archives/2006/11/09/why-is-php-code-considered-hard-to-maintain/#comments</comments>
		<pubDate>Fri, 10 Nov 2006 06:37:21 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Open Source]]></category>

		<category><![CDATA[Software Design]]></category>
<category>maintainability</category><category>namespaces</category><category>php</category><category>scaleability</category>
		<guid isPermaLink="false">http://www.procata.com/blog/archives/2006/11/09/why-is-php-code-considered-hard-to-maintain/</guid>
		<description><![CDATA[Tobias Schlitt describes Tim Bray&#8217;s talk at the International PHP Conference.  (PDF slides)   Tim compares PHP, Java, and Rails along several dimensions.  One of those dimensions is maintainability.  Tim ranks PHP as least maintainable, Rails in the middle, and Java as most maintainable.  
This is not a surprising ranking. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://schlitt.info/applications/blog/index.php?/archives/508-Tim-Bray-compared-Java,-Ruby-and-PHP.html">Tobias Schlitt</a> describes <a href="http://www.tbray.org/ongoing/">Tim Bray&#8217;s</a> talk at the International PHP Conference.  (<a href="http://www.tbray.org/talks/php.de.pdf">PDF slides</a>)   Tim compares PHP, Java, and Rails along several dimensions.  One of those dimensions is maintainability.  Tim ranks PHP as least maintainable, Rails in the middle, and Java as most maintainable.  </p>
<p>This is not a surprising ranking.  After all, Tim is from Sun, and the maintainability complaint is common in Anti-PHP rants.  I&#8217;m not trying to suggest that Tim is anti-PHP, far from it, it seems.  I&#8217;m just using his ranking as a spring board to ask questions.</p>
<p>Chances are that your average Java jockey or C scientist&#8217;s first exposure to PHP is to download one of the popular PHP applications.  These are usually the product of some open source mega-project with developers of varying degrees of skill.  Our engineer-by-day spends a few evenings with the program.  The code is not technically outstanding. </p>
<p>How can something like this be so popular he asks?  Yet, the software is successful by definition.  Nobody downloads unsuccessful open source applications.  The technocrat, heavily invested in his own technical prowess, faced with successful yet technically inferior code experiences cognitive dissonance.  The only thing to do is to belittle the successful, but surely offensive code.  &#8220;I could write better code than this,&#8221; he says, or &#8220;this code sucks,&#8221; or &#8220;this is unmaintainable.&#8221;</p>
<p>It is easy to dismiss these gripes inside the PHP community.  After all, those of us using PHP professionally can write maintainable code in PHP.  Ask any programmer and they will tell you, &#8220;My code is maintainable.&#8221;  Who writes all of this unmaintainable code, anyway?</p>
<p>Lets take this gripe at face value for a moment.  Why is PHP code considered hard to maintain?  Is it the language that produces code that is hard to maintain, or is it that the popular ambassadors of the language happen to be programs that are hard to maintain?</p>
<p>Another common PHP sucks complaint is that PHP doesn&#8217;t scale.  When you are talking about traffic, there are all sorts of counter examples for this.  Personally, I&#8217;m dying to learn the story behind those .php extensions on YouTube.  But, this post is not about requests per second.</p>
<p>Another kind of scalability is team size.  I think that when some people complain that PHP doesn&#8217;t scale, what they mean is that PHP doesn&#8217;t scale to large development teams or large projects.  Now we are back to the maintainability issue.</p>
<p>What is it about PHP that makes people think that it is not suitable for larger development teams?</p>
<p>The criticisms of maintainability and scalability generally come from outside the PHP community.  But, there is a common complaint from within the PHP community.  </p>
<p>It is hard to find a PHP wish list that doesn&#8217;t include namespaces.  It comes up again and again.</p>
<p>Sometimes users request a feature without explicitly making their true desires and intentions known.  They say &#8220;I want feature X,&#8221; but what they really mean is &#8220;solve problem Y.&#8221;  Good programmers can hear the request for X, but make the jump to solving Y.  </p>
<p>When people ask for the namespace feature, the problem they want to solve is integrating code from multiple parties.  I wonder if the frequency of this request is a signal of a problem in this department?   Perhaps one that requires more than just namespaces to solve?  Is the namespace request a proxy for a larger problem?</p>
<p>What is it about PHP that makes it hard to integrate code written by multiple parties, whether they be different developers or different organizations?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.procata.com/blog/archives/2006/11/09/why-is-php-code-considered-hard-to-maintain/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
