<?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; api-design</title>
	<atom:link href="http://www.procata.com/blog/archives/tag/api-design/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>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><![CDATA[api-design]]></category>
		<category><![CDATA[api-documentation]]></category>
		<category><![CDATA[docblocks]]></category>
		<category><![CDATA[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>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>PDO Design Evolution</title>
		<link>http://www.procata.com/blog/archives/2004/10/23/pdo/</link>
		<comments>http://www.procata.com/blog/archives/2004/10/23/pdo/#comments</comments>
		<pubDate>Sat, 23 Oct 2004 22:32:30 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software Design]]></category>
		<category><![CDATA[api-design]]></category>
		<category><![CDATA[pdo]]></category>

		<guid isPermaLink="false">http://www.procata.com/blog/archives/2004/10/23/pdo/</guid>
		<description><![CDATA[Alan Knowles has an interesting post on PDO.
I really don&#8217;t know much about PDO, i haven&#8217;t used it yet.  Most of what I know comes from:
Wez Furlong&#8217;s first steps with PDO examples
Wez&#8217;s Oracle PDO Article
John Lim&#8217;s discussion of adodb and PDO
A sitepoint thread on PDO
I haven&#8217;t seen any API type docs yet.  I [...]]]></description>
			<content:encoded><![CDATA[<p>Alan Knowles has an interesting post <a href="http://blog.akbkhome.com/archives/55_PDO__Why_it_should_not_be_part_of_core_PHP.html">on PDO</a>.</p>
<p>I really don&#8217;t know much about PDO, i haven&#8217;t used it yet.  Most of what I know comes from:<br />
<a href="http://netevil.org/node.php?nid=44">Wez Furlong&#8217;s first steps with PDO examples</a><br />
<a href="http://www.oracle.com/technology/pub/articles/php_experts/otn_pdo_oracle5.html">Wez&#8217;s Oracle PDO Article</a><br />
<a href="http://phplens.com/phpeverywhere/?q=node/view/1">John Lim&#8217;s discussion of adodb and PDO</a><br />
<a href="http://www.sitepoint.com/forums/showthread.php?t=171535">A sitepoint thread on PDO</a><br />
I haven&#8217;t seen any API type docs yet.  I did download an older version of the PECL code and skim through it.</p>
<p>Alan has some interesting things to say.  I have to agree with him on using libgda as a back end.  Using a more mature, existing, debugged code base seems very reasonable to me.  Could libgda be used as the PDO back end while retaining the PDO front end API?</p>
<p>When I first looked at PDO, the parameter binding is one of the things that really jumped out at me.  It reminded me of register globals, a technique that didn&#8217;t necessarily turn out well and was painful to back out of.  Now that Alan says it, this technique is a bit more reminiscent of C than PHP.  As i understand its an optional way to use PDO.  A way that I would not use.</p>
<p>Wez <a href="http://blog.akbkhome.com/archives/55_PDO__Why_it_should_not_be_part_of_core_PHP.html#c186">comments</a>:</p>
<blockquote><p>
- copying C: I agree that bound parameters can lead to magic code. There are two things to keep in mind: a good coding style (with comments) is the best remedy for code that might be considered magic.
</p></blockquote>
<p>I have to strongly disagree on the coding style point.  Salting magic code with comments does not make it palatable.  The solution is to remove the magic.</p>
<p>I am not familiar enough with PDO to understand the iterator argument.  None of the examples I have seen actually use iterators.</p>
<p>What I would like to see out of a basic OO DB API in PHP is better support for translating the database record into an object.  For example, the fetch(PDO_FETCH_OBJ) method returns an anonymous object.  I would like a way for this method to construct an object of a particular class along with an initialization protocol such as <a href="http://www.php.net/manual/en/function.unserialize.php">unserialize</a> has with objects.</p>
<p>I do think that PDO should be a part of core PHP, but perhaps one with a more mature libgda backend and a more evolved PHP front end API, influenced by Alan&#8217;s feedback and DBDO efforts.</p>
<p>I have noticed that sometimes the API design in PHP tends to simply wrap underlying 3rd party C libraries, even when that design doesn&#8217;t make the most sense in PHP.  (for example the PHP wrapping of expat) PDO is a more of an attempt to design a PHP oriented API and then work the 3rd party libraries into the common design.  To me, this is a step forward.  However, the PDO API probably needs to go through a few iterations as Alan suggests before being frozen into core PHP.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.procata.com/blog/archives/2004/10/23/pdo/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Evolution not Revolution</title>
		<link>http://www.procata.com/blog/archives/2004/06/18/evolution-not-revolution/</link>
		<comments>http://www.procata.com/blog/archives/2004/06/18/evolution-not-revolution/#comments</comments>
		<pubDate>Fri, 18 Jun 2004 20:55:45 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Agile Methods]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[api-design]]></category>

		<guid isPermaLink="false">http://www.procata.com/blog/archives/2004/06/18/evolution-not-revolution/</guid>
		<description><![CDATA[I ran across an Interview with Scott Collins about Mozilla at ArsTechnica. In light of Joel Spolsky&#8217;s How Microsoft Lost the API War article, I found one comment particularly interesting:
And we didn&#8217;t get out a 5.0, and that cost of us everything, it was the biggest mistake ever
This was obviously an emotional issue for Scott, [...]]]></description>
			<content:encoded><![CDATA[<p>I ran across an <a href="http://arstechnica.com/etc/linux/collins-interview-1.html">Interview with Scott Collins</a> about Mozilla at ArsTechnica. In light of Joel Spolsky&#8217;s How <a href="http://www.joelonsoftware.com/articles/APIWar.html">Microsoft Lost the API War</a> article, I found one comment particularly interesting:</p>
<blockquote><p>And we didn&#8217;t get out a 5.0, and that cost of us everything, it was the biggest mistake ever</p></blockquote>
<p>This was obviously an emotional issue for Scott, and I think he is right.</p>
<p>Engineer types seldom recognize the incredible risk involved with embarking on a rewrite of an existing, working application. Joel&#8217;s point, is that Microsoft is making a similar mistake with their APIs today.</p>
<p><a href="http://www.sitepoint.com/blog-post-view.php?id=175686">Harry speculates</a> that PHP may be able to pick up some of the market share loss that this type of mistake could lead to.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.procata.com/blog/archives/2004/06/18/evolution-not-revolution/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>API Design</title>
		<link>http://www.procata.com/blog/archives/2004/05/05/api-design/</link>
		<comments>http://www.procata.com/blog/archives/2004/05/05/api-design/#comments</comments>
		<pubDate>Thu, 06 May 2004 02:52:04 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Software Design]]></category>
		<category><![CDATA[api-design]]></category>

		<guid isPermaLink="false">http://www.procata.com/blog/archives/2004/05/05/api-design/</guid>
		<description><![CDATA[I ran across a couple older items on API design: Words of Wisdom on Designing Usable APIs and Think of Objects as Machines.
good API designs happens when designers think of &#8230; client programmers as users.
I wish more developers took this to heart.  I&#8217;ll add my own law of API design:
Good API design makes common [...]]]></description>
			<content:encoded><![CDATA[<p>I ran across a couple older items on API design: <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=4826">Words of Wisdom on Designing Usable APIs</a> and <a href="http://www.artima.com/objectdesign/machine.html">Think of Objects as Machines</a>.</p>
<blockquote><p>good API designs happens when designers think of &#8230; client programmers as users.</p></blockquote>
<p>I wish more developers took this to heart.  I&#8217;ll add my own law of API design:</p>
<blockquote><p>Good API design makes common things simple while leaving uncommon things possible.</p></blockquote>
<p>You can call it Moore&#8217;s law.  <img src='http://www.procata.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>When comparing two API possibilities, I often just count characters in a couple common examples of usage.  To me, the API choice that results in fewer characters for the client programmer is usually the better API.  This can tip the balance for subtle choices, or help evaluate two libraries which do the same thing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.procata.com/blog/archives/2004/05/05/api-design/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

