<?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: Procedural Language Eliminated GOTOs; OO Eliminated IFs</title>
	<atom:link href="http://misko.hevery.com/2008/08/14/procedural-language-eliminated-gotos-oo-eliminated-ifs/feed/" rel="self" type="application/rss+xml" />
	<link>http://misko.hevery.com/2008/08/14/procedural-language-eliminated-gotos-oo-eliminated-ifs/</link>
	<description>Testability Explorer</description>
	<lastBuildDate>Fri, 30 Jul 2010 03:59:03 -0400</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: How to think about OO : Clevertester</title>
		<link>http://misko.hevery.com/2008/08/14/procedural-language-eliminated-gotos-oo-eliminated-ifs/comment-page-1/#comment-3590</link>
		<dc:creator>How to think about OO : Clevertester</dc:creator>
		<pubDate>Mon, 07 Jun 2010 19:52:37 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=159#comment-3590</guid>
		<description>[...] Now that we took advantage of polymorphism, each different kind of user knows how to log in and we can easily add new kind of user type to the system. Also notice how the user no longer has all of the flag fields which were controlling the ifs to give the user different behavior. The ifs and flags have disappeared. [...]</description>
		<content:encoded><![CDATA[<p>[...] Now that we took advantage of polymorphism, each different kind of user knows how to log in and we can easily add new kind of user type to the system. Also notice how the user no longer has all of the flag fields which were controlling the ifs to give the user different behavior. The ifs and flags have disappeared. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Berlin Brown</title>
		<link>http://misko.hevery.com/2008/08/14/procedural-language-eliminated-gotos-oo-eliminated-ifs/comment-page-1/#comment-2463</link>
		<dc:creator>Berlin Brown</dc:creator>
		<pubDate>Wed, 25 Nov 2009 16:32:34 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=159#comment-2463</guid>
		<description>He is insane?  Remove logic?

I like it.</description>
		<content:encoded><![CDATA[<p>He is insane?  Remove logic?</p>
<p>I like it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: How to leave a comment</title>
		<link>http://misko.hevery.com/2008/08/14/procedural-language-eliminated-gotos-oo-eliminated-ifs/comment-page-1/#comment-924</link>
		<dc:creator>How to leave a comment</dc:creator>
		<pubDate>Wed, 29 Apr 2009 05:57:49 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=159#comment-924</guid>
		<description>private Getter getter = new Getter() {
    public T get() {
      final T value = initialize();
      getter = new Getter(){
        T get() { return value; }
      }
    }
  };</description>
		<content:encoded><![CDATA[<p>private Getter getter = new Getter() {<br />
    public T get() {<br />
      final T value = initialize();<br />
      getter = new Getter(){<br />
        T get() { return value; }<br />
      }<br />
    }<br />
  };</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christian Gruber</title>
		<link>http://misko.hevery.com/2008/08/14/procedural-language-eliminated-gotos-oo-eliminated-ifs/comment-page-1/#comment-325</link>
		<dc:creator>Christian Gruber</dc:creator>
		<pubDate>Thu, 06 Nov 2008 04:35:29 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=159#comment-325</guid>
		<description>I&#039;m really starting to like Scala, since it runs in the JVM, but allows me to pass functions similar to your javascript example.

As to the ifs, ifs aren&#039;t per-se bad, but they are harder to test, since you have to test each possible boolean outcome, and in complicated if/elseif/elseif/else constructs, you are often having to stage a lot of tests.  If you could separate the flow/decision logic from the processing logic (the stuff done in each test), you can abstract and make the flow logic generic and test is separately from the work itself.</description>
		<content:encoded><![CDATA[<p>I&#8217;m really starting to like Scala, since it runs in the JVM, but allows me to pass functions similar to your javascript example.</p>
<p>As to the ifs, ifs aren&#8217;t per-se bad, but they are harder to test, since you have to test each possible boolean outcome, and in complicated if/elseif/elseif/else constructs, you are often having to stage a lot of tests.  If you could separate the flow/decision logic from the processing logic (the stuff done in each test), you can abstract and make the flow logic generic and test is separately from the work itself.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John M. Długosz</title>
		<link>http://misko.hevery.com/2008/08/14/procedural-language-eliminated-gotos-oo-eliminated-ifs/comment-page-1/#comment-280</link>
		<dc:creator>John M. Długosz</dc:creator>
		<pubDate>Mon, 20 Oct 2008 16:27:21 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=159#comment-280</guid>
		<description>Your assertion of &quot;You can’t remove these IFs&quot; is language centric.  Polymorphism and overloading in Java replaces explicit comparisons against types, and only types.  Furthermore, virtual function calling distinguishes polymorphic types at run-time, and signature overloading does so with declared types at compile time.

Other languages don&#039;t necessarily have these specific features or these limitations.  In functional languages, you can typically &quot;overload&quot; values so you could write a factorial function as two forms: one for the base case and one for the recursive case.  Something like

   fact[1] := 1
   fact[n] := n×fact[n-1]

To be more concrete, in Perl 6 you could write:

   multi sub fact (Int $n)
      { return $n * fact($n - 1); }
   multi sub fact (Int $n where 1)
      { return 1; }

and then you can check for improper arguments as well, by adding another form:

   multi sub fact (Int $n where { $_ &lt; 1 })
      { fail; }

As for your specific example, how is what you describe different from simply using a &#039;final&#039; variable directly (I assume this is like &#039;static&#039; in C++&#039;) which implements the specific feature of &quot;initialize on first use&quot;?  I don&#039;t know the meaning of the Java syntax

   new Getter() { class-like-block }

which is key to your idiom.</description>
		<content:encoded><![CDATA[<p>Your assertion of &#8220;You can’t remove these IFs&#8221; is language centric.  Polymorphism and overloading in Java replaces explicit comparisons against types, and only types.  Furthermore, virtual function calling distinguishes polymorphic types at run-time, and signature overloading does so with declared types at compile time.</p>
<p>Other languages don&#8217;t necessarily have these specific features or these limitations.  In functional languages, you can typically &#8220;overload&#8221; values so you could write a factorial function as two forms: one for the base case and one for the recursive case.  Something like</p>
<p>   fact[1] := 1<br />
   fact[n] := n×fact[n-1]</p>
<p>To be more concrete, in Perl 6 you could write:</p>
<p>   multi sub fact (Int $n)<br />
      { return $n * fact($n &#8211; 1); }<br />
   multi sub fact (Int $n where 1)<br />
      { return 1; }</p>
<p>and then you can check for improper arguments as well, by adding another form:</p>
<p>   multi sub fact (Int $n where { $_ &lt; 1 })<br />
      { fail; }</p>
<p>As for your specific example, how is what you describe different from simply using a &#8216;final&#8217; variable directly (I assume this is like &#8217;static&#8217; in C++&#8217;) which implements the specific feature of &#8220;initialize on first use&#8221;?  I don&#8217;t know the meaning of the Java syntax</p>
<p>   new Getter() { class-like-block }</p>
<p>which is key to your idiom.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: john smith</title>
		<link>http://misko.hevery.com/2008/08/14/procedural-language-eliminated-gotos-oo-eliminated-ifs/comment-page-1/#comment-55</link>
		<dc:creator>john smith</dc:creator>
		<pubDate>Fri, 15 Aug 2008 12:35:09 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=159#comment-55</guid>
		<description>I don&#039;t understand.  When did anyone say IFs were bad?  I cannot see at all how all that code is better than an IF statement.

You want to add all kinds of gunk to the Java language to avoid IFs?  No one has ever shown me that adding closures in Java will allow it to do something it doesn&#039;t do now.  Just because it saves a couple of lines of code doesn&#039;t mean the language should be changed.  In this case, it adds lines to code.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t understand.  When did anyone say IFs were bad?  I cannot see at all how all that code is better than an IF statement.</p>
<p>You want to add all kinds of gunk to the Java language to avoid IFs?  No one has ever shown me that adding closures in Java will allow it to do something it doesn&#8217;t do now.  Just because it saves a couple of lines of code doesn&#8217;t mean the language should be changed.  In this case, it adds lines to code.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
