<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: More beautiful code</title>
	<atom:link href="http://blog.agilephp.com/2008/11/08/more-beautiful-code/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.agilephp.com/2008/11/08/more-beautiful-code/</link>
	<description>Dagfinn Reiersøl on PHP, agile development, Ruby and other addictive substances</description>
	<lastBuildDate>Fri, 23 Jul 2010 20:17:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Open</title>
		<link>http://blog.agilephp.com/2008/11/08/more-beautiful-code/comment-page-1/#comment-118</link>
		<dc:creator>Open</dc:creator>
		<pubDate>Sun, 30 Nov 2008 17:09:08 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/wordpress/?p=1395#comment-118</guid>
		<description>&lt;p&gt;This api is not easy in use. The code is very long, more complicated things are hard to describe.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>This api is not easy in use. The code is very long, more complicated things are hard to describe.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dagfinn</title>
		<link>http://blog.agilephp.com/2008/11/08/more-beautiful-code/comment-page-1/#comment-117</link>
		<dc:creator>dagfinn</dc:creator>
		<pubDate>Thu, 13 Nov 2008 19:56:51 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/wordpress/?p=1395#comment-117</guid>
		<description>&lt;p&gt;Good point. If I wanted to implement it this way (I&#039;m not sure, not having considered it sufficiently) andValues() would probably be a piece of syntactic sugar, implemented as an alias for hasValues(). The Ruby mock framework Flexmock has something similar: &quot;returns is an alias for and_return&quot;.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Good point. If I wanted to implement it this way (I&#8217;m not sure, not having considered it sufficiently) andValues() would probably be a piece of syntactic sugar, implemented as an alias for hasValues(). The Ruby mock framework Flexmock has something similar: &#8220;returns is an alias for and_return&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: brem</title>
		<link>http://blog.agilephp.com/2008/11/08/more-beautiful-code/comment-page-1/#comment-115</link>
		<dc:creator>brem</dc:creator>
		<pubDate>Thu, 13 Nov 2008 16:25:56 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/wordpress/?p=1395#comment-115</guid>
		<description>&lt;p&gt;The problem with your second &quot;sentence&quot; is that it denatures the meaning of entities.&lt;/p&gt;
&lt;p&gt;A function that has the name &quot;hasValues&quot; has an expected behaviour. It will tell me if the calling structure or object will contain the  values in parameters. Whereas, a function called &quot;andValues&quot; means absolutely nothing.&lt;/p&gt;
&lt;p&gt;So yes, you get a pretty english sentence, but you lose the meaning of what you&#039;re doing. So in the context of your little sentence, it works fine, but in the greater context, in the next lines of code, a function &quot;andValues&quot; has &quot;little value&quot;. :)&lt;/p&gt;
&lt;p&gt;brem&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>The problem with your second &#8220;sentence&#8221; is that it denatures the meaning of entities.</p>
<p>A function that has the name &#8220;hasValues&#8221; has an expected behaviour. It will tell me if the calling structure or object will contain the  values in parameters. Whereas, a function called &#8220;andValues&#8221; means absolutely nothing.</p>
<p>So yes, you get a pretty english sentence, but you lose the meaning of what you&#8217;re doing. So in the context of your little sentence, it works fine, but in the greater context, in the next lines of code, a function &#8220;andValues&#8221; has &#8220;little value&#8221;. <img src='http://blog.agilephp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>brem</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dagfinn</title>
		<link>http://blog.agilephp.com/2008/11/08/more-beautiful-code/comment-page-1/#comment-116</link>
		<dc:creator>dagfinn</dc:creator>
		<pubDate>Mon, 10 Nov 2008 15:05:51 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/wordpress/?p=1395#comment-116</guid>
		<description>&lt;p&gt;@Simon: That&#039;s OK, I don&#039;t take it personally. Objections help me think.&lt;/p&gt;
&lt;p&gt;i) It&#039;s an extra API on top of the existing test framework&#039;s. You don&#039;t have to use it if you don&#039;t want to, but the intention is to get more compact and less cryptic code.&lt;/p&gt;
&lt;p&gt;ii) Perhaps it looks clumsy. My criterion is that it takes less time to understand the code if you haven&#039;t read it in the last month and need to update it.&lt;/p&gt;
&lt;p&gt;iii) Any understandable API needs to use words in some natural language. English is just the usual choice. I&#039;m just discussing the principles. If you want to use words from German, Esperanto or Buganda, the principles are the same.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>@Simon: That&#8217;s OK, I don&#8217;t take it personally. Objections help me think.</p>
<p>i) It&#8217;s an extra API on top of the existing test framework&#8217;s. You don&#8217;t have to use it if you don&#8217;t want to, but the intention is to get more compact and less cryptic code.</p>
<p>ii) Perhaps it looks clumsy. My criterion is that it takes less time to understand the code if you haven&#8217;t read it in the last month and need to update it.</p>
<p>iii) Any understandable API needs to use words in some natural language. English is just the usual choice. I&#8217;m just discussing the principles. If you want to use words from German, Esperanto or Buganda, the principles are the same.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simon</title>
		<link>http://blog.agilephp.com/2008/11/08/more-beautiful-code/comment-page-1/#comment-119</link>
		<dc:creator>Simon</dc:creator>
		<pubDate>Mon, 10 Nov 2008 10:08:59 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/wordpress/?p=1395#comment-119</guid>
		<description>&lt;p&gt;Thanks for raising this subject.&lt;/p&gt;
&lt;p&gt;I see your point, but I have so many objections to so-called &quot;fluent&quot; interfaces that I never know where to start. Please take none of this personally!&lt;/p&gt;
&lt;p&gt;i) I already know PHP and - for example - xUnit, why do I have to learn your own hand-rolled language simply to maintain your code?&lt;/p&gt;
&lt;p&gt;ii) &quot;Fluent&quot; interfaces _never_ read like fluent English. They, without exception, read like a clumsy, uncomfortable hybrid of English and whatever programming language is in use.&lt;/p&gt;
&lt;p&gt;iii) If the interface did manage to read like English...how does that help the millions of people that are fluent in, say, PHP but don&#039;t think in English in the first place?&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Thanks for raising this subject.</p>
<p>I see your point, but I have so many objections to so-called &#8220;fluent&#8221; interfaces that I never know where to start. Please take none of this personally!</p>
<p>i) I already know PHP and &#8211; for example &#8211; xUnit, why do I have to learn your own hand-rolled language simply to maintain your code?</p>
<p>ii) &#8220;Fluent&#8221; interfaces _never_ read like fluent English. They, without exception, read like a clumsy, uncomfortable hybrid of English and whatever programming language is in use.</p>
<p>iii) If the interface did manage to read like English&#8230;how does that help the millions of people that are fluent in, say, PHP but don&#8217;t think in English in the first place?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dagfinn</title>
		<link>http://blog.agilephp.com/2008/11/08/more-beautiful-code/comment-page-1/#comment-121</link>
		<dc:creator>dagfinn</dc:creator>
		<pubDate>Sat, 08 Nov 2008 13:22:29 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/wordpress/?p=1395#comment-121</guid>
		<description>&lt;p&gt;I must say I&#039;m fascinated by the number of objections I&#039;m getting here. Let me answer some of them.&lt;/p&gt;
&lt;p&gt;@Ilja: Of course you could have a full-blown DSL, but it&#039;s more work to implement.&lt;/p&gt;
&lt;p&gt;@zilenCe: I haven&#039;t designed this in detail, and I might want to do it differently after thinking more about it. Still, I don&#039;t think you would have to add an extra call at the end. The chain would involve the object generated by the assertThat() call. $this, the test case, would receive the final result and be able to check the assertion.&lt;/p&gt;
&lt;p&gt;You say that assertTrue and assertFalse are easy to use. Of course, but they are unable to express anything complex. Which is what I&#039;m trying to do here.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>I must say I&#8217;m fascinated by the number of objections I&#8217;m getting here. Let me answer some of them.</p>
<p>@Ilja: Of course you could have a full-blown DSL, but it&#8217;s more work to implement.</p>
<p>@zilenCe: I haven&#8217;t designed this in detail, and I might want to do it differently after thinking more about it. Still, I don&#8217;t think you would have to add an extra call at the end. The chain would involve the object generated by the assertThat() call. $this, the test case, would receive the final result and be able to check the assertion.</p>
<p>You say that assertTrue and assertFalse are easy to use. Of course, but they are unable to express anything complex. Which is what I&#8217;m trying to do here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dougal Matthews</title>
		<link>http://blog.agilephp.com/2008/11/08/more-beautiful-code/comment-page-1/#comment-120</link>
		<dc:creator>Dougal Matthews</dc:creator>
		<pubDate>Sat, 08 Nov 2008 12:52:51 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/wordpress/?p=1395#comment-120</guid>
		<description>&lt;p&gt;If you really want something that reads more like english... try python!&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>If you really want something that reads more like english&#8230; try python!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zilenCe</title>
		<link>http://blog.agilephp.com/2008/11/08/more-beautiful-code/comment-page-1/#comment-114</link>
		<dc:creator>zilenCe</dc:creator>
		<pubDate>Sat, 08 Nov 2008 10:40:52 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/wordpress/?p=1395#comment-114</guid>
		<description>&lt;p&gt;The problem with the chaining implementation is that it does not know, when it is the last on the chain and when to check the assertion. You need a method like -&gt;assert() or -&gt;end() or -&gt;check() or whatever it is named, thus it is required to add an additional call at the end of the assertion, making it less fun to read.&lt;/p&gt;
&lt;p&gt;Also, considering that most methods have simplified names where you can interpret a lot of stuff into them you may end up having a unit-test class with several hundred methods (noone can remember that). Using assertTrue and assertFalse is much easier than having -&gt;hasValue(false) -&gt;isFalse -&gt;isNotTrue -&gt;isNotFalse -&gt;isTrue -&gt;isTheValueIWant(false) just to create easier &quot;sentences&quot;.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>The problem with the chaining implementation is that it does not know, when it is the last on the chain and when to check the assertion. You need a method like -&gt;assert() or -&gt;end() or -&gt;check() or whatever it is named, thus it is required to add an additional call at the end of the assertion, making it less fun to read.</p>
<p>Also, considering that most methods have simplified names where you can interpret a lot of stuff into them you may end up having a unit-test class with several hundred methods (noone can remember that). Using assertTrue and assertFalse is much easier than having -&gt;hasValue(false) -&gt;isFalse -&gt;isNotTrue -&gt;isNotFalse -&gt;isTrue -&gt;isTheValueIWant(false) just to create easier &#8220;sentences&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ilia Jerebtsov</title>
		<link>http://blog.agilephp.com/2008/11/08/more-beautiful-code/comment-page-1/#comment-113</link>
		<dc:creator>Ilia Jerebtsov</dc:creator>
		<pubDate>Sat, 08 Nov 2008 06:34:13 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/wordpress/?p=1395#comment-113</guid>
		<description>&lt;p&gt;Trouble is, it&#039;s not a DSL, and it&#039;s not English. It&#039;s still PHP code, and when I look at what I expect to be code, I will parse it as code. It might be helpful for a tester, but a programmer would stil see it as a set of method and function calls.&lt;/p&gt;
&lt;p&gt;$this-&gt;assertThat(&lt;br /&gt;
  $form-&gt;hasSelect(&lt;br /&gt;
    withName(&#039;statusConfirm&#039;)&lt;br /&gt;
  )-&gt;hasValues(),&lt;br /&gt;
  array(&#039;Yes&#039;,&#039;No&#039;)&lt;br /&gt;
);&lt;/p&gt;
&lt;p&gt;This format actually makes it more dificult for me to count the references - something I do automatically when reading code. &lt;/p&gt;
&lt;p&gt;If you want a DSL, then you might as well make it a full blown DSL, like SQL:&lt;/p&gt;
&lt;p&gt;$this-&gt;assert( &#039;FORM HAS SELECT ( WITHNAME &quot;statusConfirm&quot; AND HASVALUES (&quot;Yes&quot;, &quot;No&quot;) )&#039; );&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Trouble is, it&#8217;s not a DSL, and it&#8217;s not English. It&#8217;s still PHP code, and when I look at what I expect to be code, I will parse it as code. It might be helpful for a tester, but a programmer would stil see it as a set of method and function calls.</p>
<p>$this-&gt;assertThat(<br />
  $form-&gt;hasSelect(<br />
    withName(&#8217;statusConfirm&#8217;)<br />
  )-&gt;hasValues(),<br />
  array(&#8216;Yes&#8217;,'No&#8217;)<br />
);</p>
<p>This format actually makes it more dificult for me to count the references &#8211; something I do automatically when reading code. </p>
<p>If you want a DSL, then you might as well make it a full blown DSL, like SQL:</p>
<p>$this-&gt;assert( &#8216;FORM HAS SELECT ( WITHNAME &#8220;statusConfirm&#8221; AND HASVALUES (&#8220;Yes&#8221;, &#8220;No&#8221;) )&#8217; );</p>
]]></content:encoded>
	</item>
</channel>
</rss>
