<?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>PHP in Action &#187; Programming</title>
	<atom:link href="http://blog.agilephp.com/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.agilephp.com</link>
	<description>Dagfinn Reiersøl on PHP, agile development, Ruby and other addictive substances</description>
	<lastBuildDate>Mon, 28 Sep 2009 14:35:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Bad code is good for you?</title>
		<link>http://blog.agilephp.com/2009/09/28/bad-code-is-good-for-you/</link>
		<comments>http://blog.agilephp.com/2009/09/28/bad-code-is-good-for-you/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 12:08:43 +0000</pubDate>
		<dc:creator>dagfinn</dc:creator>
				<category><![CDATA[Application design]]></category>
		<category><![CDATA[Clean code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Domain-Driven Design]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.agilephp.com/?p=1630</guid>
		<description><![CDATA[



Image by Balakov via Flickr



In The importance of bad code (or, WordPress and why I am a psychic), Marco Tabini proposes the idea that we need bad code. Or at least that we should be tolerant of bad code in open source projects because that invites participants that might otherwise not contribute.
This is an interesting [...]]]></description>
			<content:encoded><![CDATA[<div class="zemanta-img" style="margin: 1em; display: block;">
<div>
<dl class="wp-caption alignleft" style="width: 250px;">
<dt class="wp-caption-dt"><a href="http://www.flickr.com/photos/71447254@N00/1544234007"><img title="Spaghetti Code" src="http://farm3.static.flickr.com/2257/1544234007_dd7686d788_m.jpg" alt="Spaghetti Code" width="240" height="155" /></a></dt>
<dd class="wp-caption-dd zemanta-img-attribution" style="font-size: 0.8em;">Image by <a href="http://www.flickr.com/photos/71447254@N00/1544234007">Balakov</a> via Flickr</dd>
</dl>
</div>
</div>
<p>In <a href="http://mtabini.blogspot.com/2009/09/importance-of-bad-code-or-wordpress-and.html">The importance of bad code (or, WordPress and why I am a psychic)</a>, Marco Tabini proposes the idea that we <em>need</em> bad code. Or at least that we should be tolerant of bad code in open source projects because that invites participants that might otherwise not contribute.</p>
<p>This is an interesting idea that struck me as novel. But after thinking more about it, I believe it&#8217;s not a radical departure from what we&#8217;re all implicitly accepting, no matter how fanatical we might be about clean code.</p>
<p><span id="more-1630"></span></p>
<p><a class="zem_slink" title="Luke Welling" rel="wikipedia" href="http://en.wikipedia.org/wiki/Luke_Welling"> Luke Welling</a>&#8217;s comment to the blog post is particularly enlightening and worth quoting in full:</p>
<blockquote><p>I&#8217;d argue that bad code is often a sign and a side effect of a thriving, welcoming user community around a project.</p>
<p>The OSS projects with good code tend to have a relatively small group of committers doing nearly all the work. There is a big learning curve to<br />
working within the project&#8217;s (probably unwritten) architectural guidelines, and a big reputation curve that a new person has to climb<br />
to get their patches accepted.</p>
<p>Bad code is often a sign of welcoming new contributors, taking patches that do something useful even if the approach is ugly.</p>
<p>We  all know the problems bad code brings, but I would argue that some  projects are not just successful in spite of bad code, but successful  because they allow bad code.</p></blockquote>
<p>I commented:</p>
<blockquote><p>If  we&#8217;re looking for the optimal strategy (which is likely to depend a lot  on the specific project), the question may be what parts of the code  need to be held to high quality standards, and what parts don&#8217;t require such strictness. And how to separate the two. Security is one of the key issues, since bugs can hide in bad code, and some of those will be security bugs.</p></blockquote>
<p>Perhaps even more important is the question of whether and how to keep a clean separation between good and bad code. Bad code becomes a problem to me mainly when I need to maintain bad code written by others. Not that I dislike it so much; I sometimes enjoy cleaning up messes, but it slows me down. But if the person who wrote it is maintaining it, it doesn&#8217;t affect me much. So a clean separation would be helpful.</p>
<p>That also makes the whole issue clearer to me. Most of us use operating systems, library software and applications that aren&#8217;t necessarily up to our coding standards. Having lower code quality in parts of a project is not much different in principle. In fact, it may be less of a problem in some cases. When you a program library that has code of poor quality, the good code is dependent on that bad code. If you are programming the core of an open-source project and someone else is adding bad code in the form of an extension, the bad code is dependent on the good code, making it even less likely that the bad code can affect the good code.</p>
<p>In <a class="zem_slink" title="Domain-driven design" rel="wikipedia" href="http://en.wikipedia.org/wiki/Domain-driven_design">Domain-Driven Design</a>, there is a pattern called Anti-Corruption Layer which can be helpful in preventing the bad code from having an undue influence on the structure of the good code. It&#8217;s worth thinking about, especially when the bad code has an illogical and confusing API.</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/eb6b55e2-85da-88bd-a263-dc329004c320/"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/reblog_a.png?x-id=eb6b55e2-85da-88bd-a263-dc329004c320" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
<p class="addtoany_share_save_container">
    <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?sitename=PHP%20in%20Action&amp;siteurl=http%3A%2F%2Fblog.agilephp.com%2F&amp;linkname=Bad%20code%20is%20good%20for%20you%3F&amp;linkurl=http%3A%2F%2Fblog.agilephp.com%2F2009%2F09%2F28%2Fbad-code-is-good-for-you%2F"><img src="http://blog.agilephp.com/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share/Save/Bookmark"/></a>

	</p>]]></content:encoded>
			<wfw:commentRss>http://blog.agilephp.com/2009/09/28/bad-code-is-good-for-you/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Sounds like an average PHP app to me</title>
		<link>http://blog.agilephp.com/2009/05/04/sounds-like-an-average-php-app-to-me/</link>
		<comments>http://blog.agilephp.com/2009/05/04/sounds-like-an-average-php-app-to-me/#comments</comments>
		<pubDate>Mon, 04 May 2009 18:59:18 +0000</pubDate>
		<dc:creator>dagfinn</dc:creator>
				<category><![CDATA[Application design]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.agilephp.com/?p=1577</guid>
		<description><![CDATA[



Image via Wikipedia



Dean Wampler blogs: Is the Supremacy of Object-Oriented Programming Over?
&#8220;The fact is, for a lot of these applications, it’s just data. The ceremony of object wrappers doesn’t carry its weight. Just put the data in a hash map (or a list if you don’t need the bits “labeled”) and then process the collection [...]]]></description>
			<content:encoded><![CDATA[<div class="zemanta-img" style="margin: 1em; display: block;">
<div>
<dl class="wp-caption alignleft" style="width: 164px;">
<dt class="wp-caption-dt"><a href="http://commons.wikipedia.org/wiki/Image:Key_delete.jpg"><img title="Delete key on PC keyboard" src="http://upload.wikimedia.org/wikipedia/commons/2/2c/Key_delete.jpg" alt="Delete key on PC keyboard" width="154" height="164" /></a></dt>
<dd class="wp-caption-dd zemanta-img-attribution" style="font-size: 0.8em;">Image via <a href="http://commons.wikipedia.org/wiki/Image:Key_delete.jpg">Wikipedia</a></dd>
</dl>
</div>
</div>
<p>Dean Wampler blogs: <a href="http://blog.objectmentor.com/articles/2009/04/20/is-the-supremacy-of-object-oriented-programming-over">Is the Supremacy of Object-Oriented Programming Over?</a></p>
<blockquote><p>&#8220;The fact is, for a lot of these applications, it’s just data. The ceremony of object wrappers doesn’t carry its weight. Just put the data in a hash map (or a list if you don’t need the bits “labeled”) and then process the collection with your iterate, map, and reduce functions. This may sound heretical, but how much Java code could you delete today if you replaced it with a stored procedure?&#8221;</p></blockquote>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><span class="zem-script more-related pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
<p class="addtoany_share_save_container">
    <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?sitename=PHP%20in%20Action&amp;siteurl=http%3A%2F%2Fblog.agilephp.com%2F&amp;linkname=Sounds%20like%20an%20average%20PHP%20app%20to%20me&amp;linkurl=http%3A%2F%2Fblog.agilephp.com%2F2009%2F05%2F04%2Fsounds-like-an-average-php-app-to-me%2F"><img src="http://blog.agilephp.com/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share/Save/Bookmark"/></a>

	</p>]]></content:encoded>
			<wfw:commentRss>http://blog.agilephp.com/2009/05/04/sounds-like-an-average-php-app-to-me/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Real programming with PHP 5.3 (part 3): Links</title>
		<link>http://blog.agilephp.com/2009/04/12/real-programming-with-php-53-part-3-links/</link>
		<comments>http://blog.agilephp.com/2009/04/12/real-programming-with-php-53-part-3-links/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 21:14:54 +0000</pubDate>
		<dc:creator>dagfinn</dc:creator>
				<category><![CDATA[Application design]]></category>
		<category><![CDATA[Clean code]]></category>
		<category><![CDATA[JavaScript/Ajax]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP 5.3]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.agilephp.com/?p=1547</guid>
		<description><![CDATA[



Image via Wikipedia



After the previous post in this series, additional independent implementations of the idea of JavaScript-style classes have turned up. So I&#8217;m going to list them and comment briefly on the differences. I hope this will be helpful to anyone who actually wants to use this in practice and needs to decide on the [...]]]></description>
			<content:encoded><![CDATA[<div class="zemanta-img" style="margin: 1em; display: block;">
<div>
<dl class="wp-caption alignright" style="width: 210px;">
<dt class="wp-caption-dt"><a href="http://commons.wikipedia.org/wiki/Image:Linking_Number_2.svg"><img title="Two curves with linking number 2." src="http://upload.wikimedia.org/wikipedia/commons/thumb/0/0e/Linking_Number_2.svg/200px-Linking_Number_2.svg.png" alt="Two curves with linking number 2." height="121" width="200"></a></dt>
<dd class="wp-caption-dd zemanta-img-attribution" style="font-size: 0.8em;">Image via <a href="http://commons.wikipedia.org/wiki/Image:Linking_Number_2.svg">Wikipedia</a></dd>
</dl>
</div>
</div>
<p>After the previous post in this series, additional independent implementations of the idea of JavaScript-style classes have turned up. So I&#8217;m going to list them and comment briefly on the differences. I hope this will be helpful to anyone who actually wants to use this in practice and needs to decide on the details of the implementation. Here are the links in chronological order:</p>
<ul>
<li><a href="http://www.sitepoint.com/forums/showthread.php?t=565576">Ionut G. Stan:Javascript style PHP with PHP 5.3.0 (forum posting).</a></li>
<li><a href="http://loveandtheft.org/2008/09/20/javascript-oo-python-ducktyping-in-php53/">Fredrik Holmström: Javascript-OO &amp; Python-DuckTyping in PHP5.3.</a></li>
<li><a href="http://www.ibm.com/developerworks/opensource/library/os-php-5.3new2/index.html">John Mertic: What&#8217;s new in PHP V5.3, Part 2: Closures and lambda functions.</a></li>
<li><a href="http://blog.agilephp.com/2009/03/31/real-programming-with-php-53-part-2-javascript-style-classes/">My own previous article.</a></li>
<li><a href="http://webreflection.blogspot.com/2009/03/jsphp-javascript-object-like-php-class.html">Andrea Giammarchi: A JavaScript Object Like PHP Class.</a></li>
</ul>
<p>One difference is how JavaScript-like the implementations are. Some of them implement a syntax that is deliberately made to resemble JavaScript.  Andrea Giammarchi&#8217;s version even uses ArrayAccess to make it possible to access object properties using both object and array syntax, as in JavaScript. At the other extreme is my implementation. I&#8217;ve tried to make it as similar to a regular PHP class as possible. You can instantiate an object in the same way as with an ordinary PHP class. This comes from defining the methods inside the class constructor.</p>
<p>After seeing all of these, I prefer my own way of doing it, except that it lacks what I mentioned in the previous article: an exception when you try to call an unrecognized method. But I&#8217;m obviously not objective, and I may have have missed something.</p>
<p class="addtoany_share_save_container">
    <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?sitename=PHP%20in%20Action&amp;siteurl=http%3A%2F%2Fblog.agilephp.com%2F&amp;linkname=Real%20programming%20with%20PHP%205.3%20%28part%203%29%3A%20Links&amp;linkurl=http%3A%2F%2Fblog.agilephp.com%2F2009%2F04%2F12%2Freal-programming-with-php-53-part-3-links%2F"><img src="http://blog.agilephp.com/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share/Save/Bookmark"/></a>

	</p>]]></content:encoded>
			<wfw:commentRss>http://blog.agilephp.com/2009/04/12/real-programming-with-php-53-part-3-links/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Is agile development a religion?</title>
		<link>http://blog.agilephp.com/2009/03/12/is-agile-development-a-religion/</link>
		<comments>http://blog.agilephp.com/2009/03/12/is-agile-development-a-religion/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 12:50:36 +0000</pubDate>
		<dc:creator>dagfinn</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.agilephp.com/?p=1499</guid>
		<description><![CDATA[

Automobile skeptic: Driving doesn&#8217;t always work. I tried it once and crashed into a tree.
Automobile zealot: How did that happen?
Skeptic: I was driving down Hazel Street, reading a magazine. And then suddenly, out of the blue, I hit the tree.
Zealot:  But you can&#8217;t read magazines while driving a car!
Skeptic: Why not?
Zealot: Because then you&#8217;re not [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-1506 alignleft" style="margin-left: 10px; margin-right: 10px;" title="2517184734_020a6de052_m" src="http://blog.agilephp.com/wp-content/uploads/2009/03/2517184734_020a6de052_m.jpg" alt="2517184734_020a6de052_m" width="240" height="180" /></p>
<p><!-- 		@page { size: 21.59cm 27.94cm; margin: 2cm } 		P { margin-bottom: 0.21cm } --></p>
<p><em>Automobile skeptic:</em> Driving doesn&#8217;t always work. I tried it once and crashed into a tree.</p>
<p><em>Automobile zealot:</em> How did that happen?</p>
<p><em>Skeptic:</em> I was driving down Hazel Street, reading a magazine. And then suddenly, out of the blue, I hit the tree.</p>
<p><em>Zealot</em>:  But you can&#8217;t read magazines while driving a car!</p>
<p><em>Skeptic:</em> Why not?</p>
<p><em>Zealot</em>: Because then you&#8217;re not paying attention to the road ahead of you.</p>
<p><em>Skeptic: </em>So what? I&#8217;ve familiarized myself with the driving process, I&#8217;ve even read a book about it. Nowhere does it say you can&#8217;t read magazines. Clearly, you are blinded by your own religious convictions. Whenever driving fails, you driving zealots find some way to explain it away. No logical argument will ever make you admit that driving can cause problems.</p>
<p>Too many conversations about agile development methods resemble this one. I came up with it after reading a column by <span id="ctl00_content_PlaceHolder_articleBody_Label" class="arial_14_16 normalLink">Andrew Binstock<em> </em></span>called &#8220;<a href="http://www.sdtimes.com/link/33300">the Zealots of Agile</a>&#8220;. Binstock is merciless:</p>
<blockquote><p><span id="ctl00_content_PlaceHolder_articleBody_Label" class="arial_14_16 normalLink">The agile movement has been nothing if not evangelical, even messianic, since its inception. From its founding with the publication of a manifesto (a manifesto!) to its subsequent, continual attack on the so-called waterfall model, agile and its exponents have hewn closely to the position that theirs is the one true path. And, consistent with this evangelical view, those who disagree either don’t really understand agile or are irretrievably deluded. For the deluded, only spectacular failure of their project will open their eyes.</span></p></blockquote>
<p>In a <a href="http://blog.objectmentor.com/articles/2009/03/10/lets-hear-it-for-the-zealots">blog post</a>, Uncle Bob argues in detail why this is inaccurate and calls it &#8220;a load of dingoes kidneys&#8221;. But if it is, why does this particular load of dingoes kidneys keep getting dumped in this particular place?</p>
<p>Above all, it&#8217;s inevitable. Anyone who pioneers something radically new and different has to be prepared for this kind of accusation. Agile development is a paradigm shift, and paradigms are, to a large extent, mutually incomprehensible. We may all be &#8220;religious fanatics&#8221; if seen from the perspective of a different paradigm than our own. To some extent, we all resist challenges to our basic assumptions, and this is always easier to see if you don&#8217;t share them.</p>
<p>The problem is not that some are skeptical of agile development processes. That&#8217;s unequivocally a good thing. Being too quick to label someone else as a fanatic is not so good. <em>That&#8217;s</em> an effective way to stop fruitful discussion and learning. I&#8217;ve also noticed (in general, not just on this subject) that those do this are often stuck on a particular point of view themselves. Also, they sometimes seem to believe that they are totally free of prejudice and irrationality themselves. But of course, they aren&#8217;t. No one is.</p>
<p>Binstock&#8217;s fallacy is a misunderstanding of the aims of agile leaders. A religous or ideological fanatic is obsessed by <em>being right</em> and by convincing others of their own rightness and righteousness. In contrast, there are those who are passionate about principles and practices because they want to <em>do better</em>. Often, being right or wrong doesn&#8217;t really matter to them. I think Kent Beck, Robert C. Martin and others not mentioned by Binstock belong to the latter category.  But if you place them in a confrontational setting, you gain licence to misinterpret their behavior as an attempt to be right. And it seems to make sense. In the real, pratical world, changing your mind without mentioning it typically just means that you&#8217;ve learned something. In the artificial world of confrontational debate, it looks like an evasive tactic.  In the real world, explaining why failure happens is a step toward improving your process. In confrontational debate, it can be seen as an attempt to <em>explain away</em> the shortcomings of that process.</p>
<p>The confrontational framing of the situation is logically consistent, but rests on a false assumption: that it is in fact this kind of game the agile leaders are playing.</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Zemified by Zemanta" href="http://reblog.zemanta.com/zemified/d5a302a4-77b6-49f5-8ab1-d27e212092bc/"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/reblog_a.png?x-id=d5a302a4-77b6-49f5-8ab1-d27e212092bc" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
<p class="addtoany_share_save_container">
    <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?sitename=PHP%20in%20Action&amp;siteurl=http%3A%2F%2Fblog.agilephp.com%2F&amp;linkname=Is%20agile%20development%20a%20religion%3F&amp;linkurl=http%3A%2F%2Fblog.agilephp.com%2F2009%2F03%2F12%2Fis-agile-development-a-religion%2F"><img src="http://blog.agilephp.com/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share/Save/Bookmark"/></a>

	</p>]]></content:encoded>
			<wfw:commentRss>http://blog.agilephp.com/2009/03/12/is-agile-development-a-religion/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
