<?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: Why Methods Should Check Their Arguments</title>
	<atom:link href="http://cafe.elharo.com/blogroll/why-methods-should-check-their-arguments/feed/" rel="self" type="application/rss+xml" />
	<link>http://cafe.elharo.com/blogroll/why-methods-should-check-their-arguments/</link>
	<description>Longer than a blog; shorter than a book</description>
	<lastBuildDate>Wed, 08 Feb 2012 21:45:25 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
	<item>
		<title>By: Anonymouse</title>
		<link>http://cafe.elharo.com/blogroll/why-methods-should-check-their-arguments/comment-page-1/#comment-27308</link>
		<dc:creator>Anonymouse</dc:creator>
		<pubDate>Sun, 05 Nov 2006 02:39:50 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/why-methods-should-check-their-arguments/#comment-27308</guid>
		<description>Stronger typing won&#039;t help (in all cases.) So you should validate your arguments. Which means you don&#039;t even need strong typing.</description>
		<content:encoded><![CDATA[<p>Stronger typing won&#8217;t help (in all cases.) So you should validate your arguments. Which means you don&#8217;t even need strong typing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Elliotte Rusty Harold</title>
		<link>http://cafe.elharo.com/blogroll/why-methods-should-check-their-arguments/comment-page-1/#comment-4704</link>
		<dc:creator>Elliotte Rusty Harold</dc:creator>
		<pubDate>Tue, 27 Jun 2006 01:03:26 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/why-methods-should-check-their-arguments/#comment-4704</guid>
		<description>XOM does throw an exception if the XPath you pass in is syntactically incorrect. Your bug was that you used a legal XPath expression that happened to not be the XPath expression you really wanted. I don&#039;t think XOM can read your mind to guess what you really meant to do. :-)</description>
		<content:encoded><![CDATA[<p>XOM does throw an exception if the XPath you pass in is syntactically incorrect. Your bug was that you used a legal XPath expression that happened to not be the XPath expression you really wanted. I don&#8217;t think XOM can read your mind to guess what you really meant to do. <img src='http://cafe.elharo.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Campbell</title>
		<link>http://cafe.elharo.com/blogroll/why-methods-should-check-their-arguments/comment-page-1/#comment-4546</link>
		<dc:creator>Paul Campbell</dc:creator>
		<pubDate>Fri, 23 Jun 2006 22:41:14 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/why-methods-should-check-their-arguments/#comment-4546</guid>
		<description>I have just been chasing a similiar problem although simpler problem in Node.query(String xpath) this afternoon.
I failed to start my query with // and it kept returning Nodes.size() = 0.

Previously, I had hardcoded my query String and had it working 
and then switched to passing an argument which was mis-coded. 
It would be nice if Node would throw an exception if it receives
faulty xpath syntax.

PS:  Would you consider adding the sample 
XOM/src/nu/xom/samples/XPathDriver.java
to http://www.xom.nu/samples.xhtml
Thanks</description>
		<content:encoded><![CDATA[<p>I have just been chasing a similiar problem although simpler problem in Node.query(String xpath) this afternoon.<br />
I failed to start my query with // and it kept returning Nodes.size() = 0.</p>
<p>Previously, I had hardcoded my query String and had it working<br />
and then switched to passing an argument which was mis-coded.<br />
It would be nice if Node would throw an exception if it receives<br />
faulty xpath syntax.</p>
<p>PS:  Would you consider adding the sample<br />
XOM/src/nu/xom/samples/XPathDriver.java<br />
to <a href="http://www.xom.nu/samples.xhtml" rel="nofollow">http://www.xom.nu/samples.xhtml</a><br />
Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: æžœå†»å¸å›½ &#187; Daily Reading Summary - Tech</title>
		<link>http://cafe.elharo.com/blogroll/why-methods-should-check-their-arguments/comment-page-1/#comment-4226</link>
		<dc:creator>æžœå†»å¸å›½ &#187; Daily Reading Summary - Tech</dc:creator>
		<pubDate>Mon, 19 Jun 2006 16:59:23 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/why-methods-should-check-their-arguments/#comment-4226</guid>
		<description>[...] [-[1]-] I just read this Why Methods Should Check Their Arguments by Elliotte Rusty Harold. I had an almost identical issue a few weeks ago. [...]</description>
		<content:encoded><![CDATA[<p>[...] [-[1]-] I just read this Why Methods Should Check Their Arguments by Elliotte Rusty Harold. I had an almost identical issue a few weeks ago. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Elliotte Rusty Harold</title>
		<link>http://cafe.elharo.com/blogroll/why-methods-should-check-their-arguments/comment-page-1/#comment-4062</link>
		<dc:creator>Elliotte Rusty Harold</dc:creator>
		<pubDate>Fri, 16 Jun 2006 10:44:08 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/why-methods-should-check-their-arguments/#comment-4062</guid>
		<description>Relative URLs are not correct in QNames. No infoset is defined for such documents. (The W3C spent a lot of time sorting this one out circa 2000.) Relative URLs should be rejected by this class, even in the right position.</description>
		<content:encoded><![CDATA[<p>Relative URLs are not correct in QNames. No infoset is defined for such documents. (The W3C spent a lot of time sorting this one out circa 2000.) Relative URLs should be rejected by this class, even in the right position.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Burdess</title>
		<link>http://cafe.elharo.com/blogroll/why-methods-should-check-their-arguments/comment-page-1/#comment-4060</link>
		<dc:creator>Chris Burdess</dc:creator>
		<pubDate>Fri, 16 Jun 2006 10:14:26 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/why-methods-should-check-their-arguments/#comment-4060</guid>
		<description>Even if the QName class went to all the effort of lexically validating its arguments you could still find combinations of relative URLs and local-names that would pass this validation in the wrong parameter position. So I don&#039;t personally feel that the extra effort of validation is worth it, especially in a method that is called a *lot*. Sometimes you really just have to be familiar with an API, and it&#039;s just unfortunate that the cost of that familiarity is hours spent debugging.</description>
		<content:encoded><![CDATA[<p>Even if the QName class went to all the effort of lexically validating its arguments you could still find combinations of relative URLs and local-names that would pass this validation in the wrong parameter position. So I don&#8217;t personally feel that the extra effort of validation is worth it, especially in a method that is called a *lot*. Sometimes you really just have to be familiar with an API, and it&#8217;s just unfortunate that the cost of that familiarity is hours spent debugging.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Elliotte Rusty Harold</title>
		<link>http://cafe.elharo.com/blogroll/why-methods-should-check-their-arguments/comment-page-1/#comment-3993</link>
		<dc:creator>Elliotte Rusty Harold</dc:creator>
		<pubDate>Thu, 15 Jun 2006 09:27:45 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/why-methods-should-check-their-arguments/#comment-3993</guid>
		<description>The URL object perhaps could have been a &lt;code&gt;java.net.URI&lt;/code&gt; object or some custom class. The  &lt;code&gt;java.net.URL&lt;/code&gt; class carries too much lookup baggage, though. It can&#039;t represent an arbitrary absolute URI, just URLs for which Java has an available protocol handler.

Also, it&#039;s a side point; but it&#039;s worth noting that the first argument is &lt;em&gt;not&lt;/em&gt; an ISBN number. It&#039;s an XML local name which happens to be the string &quot;valid-isbn&quot;. You couldn&#039;t tell from the limited context I provided, but this is actually the name of an XPath extension function that checks ISBN numbers to see if they&#039;re correct.</description>
		<content:encoded><![CDATA[<p>The URL object perhaps could have been a <code>java.net.URI</code> object or some custom class. The  <code>java.net.URL</code> class carries too much lookup baggage, though. It can&#8217;t represent an arbitrary absolute URI, just URLs for which Java has an available protocol handler.</p>
<p>Also, it&#8217;s a side point; but it&#8217;s worth noting that the first argument is <em>not</em> an ISBN number. It&#8217;s an XML local name which happens to be the string &#8220;valid-isbn&#8221;. You couldn&#8217;t tell from the limited context I provided, but this is actually the name of an XPath extension function that checks ISBN numbers to see if they&#8217;re correct.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ted Young</title>
		<link>http://cafe.elharo.com/blogroll/why-methods-should-check-their-arguments/comment-page-1/#comment-3924</link>
		<dc:creator>Ted Young</dc:creator>
		<pubDate>Thu, 15 Jun 2006 01:22:02 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/why-methods-should-check-their-arguments/#comment-3924</guid>
		<description>I agree with Ian, in that at least the URL argument should have been a URL object. The ISBN is fine as a String, unless there was some mechanism for doing a lookup. Alas, if you do that, you&#039;d probably end up writing a convenience method that took a pair of Strings, turned them into the URL and ISBN objects, and then instantiated QName. And then you&#039;d be back where you started.

So, fail early and fail often, especially in constructors.

;ted

p.s. Do you think you could turn off the full (left and right) text justification? It makes it harder to read than ragged-right text, especially with code that doesn&#039;t line-break well and the lack of hyphenation.</description>
		<content:encoded><![CDATA[<p>I agree with Ian, in that at least the URL argument should have been a URL object. The ISBN is fine as a String, unless there was some mechanism for doing a lookup. Alas, if you do that, you&#8217;d probably end up writing a convenience method that took a pair of Strings, turned them into the URL and ISBN objects, and then instantiated QName. And then you&#8217;d be back where you started.</p>
<p>So, fail early and fail often, especially in constructors.</p>
<p>;ted</p>
<p>p.s. Do you think you could turn off the full (left and right) text justification? It makes it harder to read than ragged-right text, especially with code that doesn&#8217;t line-break well and the lack of hyphenation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Elliotte Rusty Harold</title>
		<link>http://cafe.elharo.com/blogroll/why-methods-should-check-their-arguments/comment-page-1/#comment-3851</link>
		<dc:creator>Elliotte Rusty Harold</dc:creator>
		<pubDate>Wed, 14 Jun 2006 17:39:01 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/why-methods-should-check-their-arguments/#comment-3851</guid>
		<description>I seriously considered checking arguments in XOM parameterized getters too. (A regular getter has no arguments and thus doesn&#039;t need to check them.) My feeling there, though, was that there just weren&#039;t quite enough problems to justify the added cost of doing the check in the getters. At least a bad getter argument doesn&#039;t corrupt the object, whereas a bad setter or constructor argument does.

One thing I did consider and might still implement is lazy getter checking. That is, check the getter arguments only if the parameterized getter fails to find anything.</description>
		<content:encoded><![CDATA[<p>I seriously considered checking arguments in XOM parameterized getters too. (A regular getter has no arguments and thus doesn&#8217;t need to check them.) My feeling there, though, was that there just weren&#8217;t quite enough problems to justify the added cost of doing the check in the getters. At least a bad getter argument doesn&#8217;t corrupt the object, whereas a bad setter or constructor argument does.</p>
<p>One thing I did consider and might still implement is lazy getter checking. That is, check the getter arguments only if the parameterized getter fails to find anything.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Elliotte Rusty Harold</title>
		<link>http://cafe.elharo.com/blogroll/why-methods-should-check-their-arguments/comment-page-1/#comment-3772</link>
		<dc:creator>Elliotte Rusty Harold</dc:creator>
		<pubDate>Wed, 14 Jun 2006 11:27:16 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/why-methods-should-check-their-arguments/#comment-3772</guid>
		<description>Interesting points about named arguments. If I ever get around to designing my own programming language, I&#039;ll add them to the list of features to consider. However, in Java as it exists today, there are coding principles that would have avoided this bug. Unfortunately the &lt;code&gt;QName&lt;/code&gt; class didn&#039;t use them.</description>
		<content:encoded><![CDATA[<p>Interesting points about named arguments. If I ever get around to designing my own programming language, I&#8217;ll add them to the list of features to consider. However, in Java as it exists today, there are coding principles that would have avoided this bug. Unfortunately the <code>QName</code> class didn&#8217;t use them.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

