<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>A Little Software Engineering</title>
	<atom:link href="http://yaseb.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://yaseb.wordpress.com</link>
	<description></description>
	<lastBuildDate>Mon, 16 Jan 2012 15:29:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='yaseb.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>A Little Software Engineering</title>
		<link>http://yaseb.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://yaseb.wordpress.com/osd.xml" title="A Little Software Engineering" />
	<atom:link rel='hub' href='http://yaseb.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Scala: First and Last Element of a Set?</title>
		<link>http://yaseb.wordpress.com/2012/01/13/scala-first-and-last-element-of-a-set/</link>
		<comments>http://yaseb.wordpress.com/2012/01/13/scala-first-and-last-element-of-a-set/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 20:34:27 +0000</pubDate>
		<dc:creator>gefeizhang</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://yaseb.wordpress.com/?p=146</guid>
		<description><![CDATA[I just came into two functions of class Set of Scala: head to return the &#8220;first&#8221; element of the set, and last to return the &#8220;last&#8221; element. Clearly, this is a case of unfortunate design. Since the elements of a set are not ordered, there is neither a first one nor a last one. I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yaseb.wordpress.com&amp;blog=10851673&amp;post=146&amp;subd=yaseb&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I just came into two functions of class <code>Set</code> of Scala: <code>head</code> to return the &#8220;first&#8221; element of the set, and <code>last</code> to return the &#8220;last&#8221; element. Clearly, this is a case of unfortunate design.  Since the elements of a set are not ordered, there is neither a first one nor a last one. I wonder why the Scala team made this design.</p>
<p>Although the <a href="http://www.scala-lang.org/api/current/scala/collection/Set.html">documentation</a> warns that the functions may return different values at different runs, I bet a lot of programmers still make the mistake of assuming the result of the functions would be stable. Pretty dangerous!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yaseb.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yaseb.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yaseb.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yaseb.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yaseb.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yaseb.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yaseb.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yaseb.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yaseb.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yaseb.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yaseb.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yaseb.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yaseb.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yaseb.wordpress.com/146/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yaseb.wordpress.com&amp;blog=10851673&amp;post=146&amp;subd=yaseb&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yaseb.wordpress.com/2012/01/13/scala-first-and-last-element-of-a-set/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/15f8ac12fc526f9245082feb5f1c5db4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gefeizhang</media:title>
		</media:content>
	</item>
		<item>
		<title>Project Euler Problem 1</title>
		<link>http://yaseb.wordpress.com/2011/12/28/project-euler-problem-1/</link>
		<comments>http://yaseb.wordpress.com/2011/12/28/project-euler-problem-1/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 09:07:36 +0000</pubDate>
		<dc:creator>gefeizhang</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[functional programming]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[project euler]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://yaseb.wordpress.com/?p=141</guid>
		<description><![CDATA[The first problem of Project Euler is pretty simple. It reads: If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. Well, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yaseb.wordpress.com&amp;blog=10851673&amp;post=141&amp;subd=yaseb&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The first problem of Project Euler is pretty simple. It reads:</p>
<blockquote><p>If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.</p>
<p>Find the sum of all the multiples of 3 or 5 below 1000.
</p></blockquote>
<p>Well, the naive way to solve this problem is simply to generate a list, and then to find the sum of its elements:</p>
<p><code><br />
sum(filter(lambda x: x%3==0 or x%5==0, range(1,1000)))</code></p>
<p>and the answer is 233168.</p>
<p>Although I appreciate the elegance of functional programming (lambda function, filter, sum), mathematically the above code is not a good solution. The sum of all numbers that are either dividable by 3 or 5 in fact equals the sum of all numbers that ar dividable by 3, plus the sum of all numbers that are dividable by 5, minus the sum of all numbers that are dividable by 15, therefore</p>
<p><code><br />
rg = range(1,1000)<br />
sum(filter(lambda x: x%3==0, rg)) + sum(filter(lambda x: x%5==0, rg)) - sum(filter(lambda x: x%15==0, rg))<br />
</code></p>
<p>And again, the answer is 233168.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yaseb.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yaseb.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yaseb.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yaseb.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yaseb.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yaseb.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yaseb.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yaseb.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yaseb.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yaseb.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yaseb.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yaseb.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yaseb.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yaseb.wordpress.com/141/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yaseb.wordpress.com&amp;blog=10851673&amp;post=141&amp;subd=yaseb&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yaseb.wordpress.com/2011/12/28/project-euler-problem-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/15f8ac12fc526f9245082feb5f1c5db4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gefeizhang</media:title>
		</media:content>
	</item>
		<item>
		<title>Project Euler</title>
		<link>http://yaseb.wordpress.com/2011/12/28/project-euler/</link>
		<comments>http://yaseb.wordpress.com/2011/12/28/project-euler/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 08:56:50 +0000</pubDate>
		<dc:creator>gefeizhang</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[project euler]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://yaseb.wordpress.com/?p=137</guid>
		<description><![CDATA[Project Euler is a very nice collection of math/programming problems. It provides very valuable exercises for math/programming. While the first problems are easy to solve, the others may be pretty challenging. I am now staring a series in this blog to show my solutions to some of the problems.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yaseb.wordpress.com&amp;blog=10851673&amp;post=137&amp;subd=yaseb&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://projecteuler.net">Project Euler</a> is a very nice collection of math/programming problems. It provides very valuable exercises for math/programming. While the first problems are easy to solve, the others may be pretty challenging.</p>
<p>I am now staring a series in this blog to show my solutions to some of the problems.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yaseb.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yaseb.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yaseb.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yaseb.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yaseb.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yaseb.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yaseb.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yaseb.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yaseb.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yaseb.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yaseb.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yaseb.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yaseb.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yaseb.wordpress.com/137/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yaseb.wordpress.com&amp;blog=10851673&amp;post=137&amp;subd=yaseb&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yaseb.wordpress.com/2011/12/28/project-euler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/15f8ac12fc526f9245082feb5f1c5db4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gefeizhang</media:title>
		</media:content>
	</item>
		<item>
		<title>Greedy SmartSVN</title>
		<link>http://yaseb.wordpress.com/2011/09/14/greedy-smartsvn/</link>
		<comments>http://yaseb.wordpress.com/2011/09/14/greedy-smartsvn/#comments</comments>
		<pubDate>Wed, 14 Sep 2011 14:45:01 +0000</pubDate>
		<dc:creator>gefeizhang</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[smartsvn]]></category>

		<guid isPermaLink="false">http://yaseb.wordpress.com/?p=127</guid>
		<description><![CDATA[Did you know deinstalling SmartSVN requires to close quite a few other applications?<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yaseb.wordpress.com&amp;blog=10851673&amp;post=127&amp;subd=yaseb&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Did you know deinstalling SmartSVN requires to close quite a few other applications?<br />
<img src="http://yaseb.files.wordpress.com/2011/07/smartsvn.png?w=450" alt="null" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yaseb.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yaseb.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yaseb.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yaseb.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yaseb.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yaseb.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yaseb.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yaseb.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yaseb.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yaseb.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yaseb.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yaseb.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yaseb.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yaseb.wordpress.com/127/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yaseb.wordpress.com&amp;blog=10851673&amp;post=127&amp;subd=yaseb&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yaseb.wordpress.com/2011/09/14/greedy-smartsvn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/15f8ac12fc526f9245082feb5f1c5db4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gefeizhang</media:title>
		</media:content>

		<media:content url="http://yaseb.files.wordpress.com/2011/07/smartsvn.png" medium="image">
			<media:title type="html">null</media:title>
		</media:content>
	</item>
		<item>
		<title>A Simple Mistake of Using Java Exception</title>
		<link>http://yaseb.wordpress.com/2011/09/01/a-simple-mistake-of-using-java-exception/</link>
		<comments>http://yaseb.wordpress.com/2011/09/01/a-simple-mistake-of-using-java-exception/#comments</comments>
		<pubDate>Thu, 01 Sep 2011 08:38:52 +0000</pubDate>
		<dc:creator>gefeizhang</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[exception]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://yaseb.wordpress.com/?p=121</guid>
		<description><![CDATA[Recently I ran into the following code in a legacy system: try { ... } except (Exception e) { System.out.println(e.getStackElement()); } While it may look innocent, it&#8217;s actually dangerous. In case of an exception, the system prints the String representation of e.getStackElement(), which actually is of type StackElement[]. Since it is an array, its String [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yaseb.wordpress.com&amp;blog=10851673&amp;post=121&amp;subd=yaseb&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently I ran into the following code in a legacy system:<br />
<code><br />
try {<br />
...<br />
} except (Exception e) {<br />
  System.out.println(e.getStackElement());<br />
}<br />
</code></p>
<p>While it may look innocent, it&#8217;s actually dangerous. In case of an exception, the system prints the String representation of e.getStackElement(), which actually is of type <strong>StackElement[]</strong>. Since it is an array, its String representation is only the address of the array, instead of the content of the array. Since the output is a one-liner, it does not catch one&#8217;s eye in the log, and it may take some time (and really took mine) for the debugger to find the exception.</p>
<p>I have no idea why the original programmer come up with the idea of using getStackElement(). Maybe he thought println(e.getStackElement()) were the same as e.printStackElement().</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yaseb.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yaseb.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yaseb.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yaseb.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yaseb.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yaseb.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yaseb.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yaseb.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yaseb.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yaseb.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yaseb.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yaseb.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yaseb.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yaseb.wordpress.com/121/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yaseb.wordpress.com&amp;blog=10851673&amp;post=121&amp;subd=yaseb&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yaseb.wordpress.com/2011/09/01/a-simple-mistake-of-using-java-exception/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/15f8ac12fc526f9245082feb5f1c5db4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gefeizhang</media:title>
		</media:content>
	</item>
		<item>
		<title>One Liner Scala for Project Euler Problem 4</title>
		<link>http://yaseb.wordpress.com/2011/08/23/one-liner-scala-for-project-euler-problem-4/</link>
		<comments>http://yaseb.wordpress.com/2011/08/23/one-liner-scala-for-project-euler-problem-4/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 10:44:29 +0000</pubDate>
		<dc:creator>gefeizhang</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[functional programming]]></category>
		<category><![CDATA[scala]]></category>
		<category><![CDATA[project euler]]></category>

		<guid isPermaLink="false">http://yaseb.wordpress.com/?p=113</guid>
		<description><![CDATA[It only takes one line code to solve Problem 4 of Project Euler in Scala (and many other functional programming languages): ((for (x &#60;- 100 until 1000; y &#60;- x until 1000) yield x * y) filter (x =&#62; x.toString == x.toString.reverse)).max &#160; &#160;<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yaseb.wordpress.com&amp;blog=10851673&amp;post=113&amp;subd=yaseb&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It only takes one line code to solve <a href="http://projecteuler.net/index.php?section=problems&amp;id=4">Problem 4 </a>of Project Euler in Scala (and many other functional programming languages):</p>
<p><code>((for (x &lt;- 100 until 1000; y &lt;- x until 1000) yield x * y) filter (x =&gt; x.toString == x.toString.reverse)).max </code></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yaseb.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yaseb.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yaseb.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yaseb.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yaseb.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yaseb.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yaseb.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yaseb.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yaseb.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yaseb.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yaseb.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yaseb.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yaseb.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yaseb.wordpress.com/113/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yaseb.wordpress.com&amp;blog=10851673&amp;post=113&amp;subd=yaseb&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yaseb.wordpress.com/2011/08/23/one-liner-scala-for-project-euler-problem-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/15f8ac12fc526f9245082feb5f1c5db4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gefeizhang</media:title>
		</media:content>
	</item>
		<item>
		<title>How to Use Exceptions: An Example</title>
		<link>http://yaseb.wordpress.com/2011/08/09/how-to-use-exceptions-an-example/</link>
		<comments>http://yaseb.wordpress.com/2011/08/09/how-to-use-exceptions-an-example/#comments</comments>
		<pubDate>Tue, 09 Aug 2011 21:20:51 +0000</pubDate>
		<dc:creator>gefeizhang</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[exception]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://yaseb.wordpress.com/?p=106</guid>
		<description><![CDATA[Today I had to debug a legacy system, including a feature, let me call it xy. In the property file, there were two properties concerning this feature: &#8220;xy.enabled&#8221; and &#8220;xy.url&#8221;. &#8220;xy.enabled&#8221; is used to indicate whether the feature should actually be activated, and if it is true, the system needs to read some data from [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yaseb.wordpress.com&amp;blog=10851673&amp;post=106&amp;subd=yaseb&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today I had to debug a legacy system, including a feature, let me call it xy. In the property file, there were two properties concerning this feature: &#8220;xy.enabled&#8221; and &#8220;xy.url&#8221;. &#8220;xy.enabled&#8221; is used to indicate whether the feature should actually be activated, and if it is true, the system needs to read some data from a URL stored in &#8220;xy.url&#8221;.</p>
<p>The defect of this system was that even &#8220;xy.enabled&#8221; is changed to &#8220;true&#8221;, the feature xy was still not activated in the system.</p>
<p>It was not very easy to find the problem, but after a while  of debugging, I finally got it: the original programmer made a mistake while coding, and reading the property &#8220;xy.enabled&#8221; is done by a method Util.getBooleanProperty(&#8220;xy.url&#8221;).  Obviously, &#8220;xy.url&#8221; is wrong. I replaced it by &#8220;xy.enabled&#8221;, and it worked fine.</p>
<p>But why does the original code, with Util.getBooleanProperty(&#8220;xy.url&#8221;), not throw an exception? Obviously getBooleanProperty is supposed to read a string representing a boolean value, obviously xy.url does not a boolean value!</p>
<p>Yes, that&#8217;s true. The method getBooleanProperty reads like this:</p>
<p><code><br />
public static getBooleanProperty(String property) {<br />
  return getProperty(property).equalsIngoreCase("true");<br />
}<br />
</code></p>
<p>where getProperty(String p) returns the String value of property p stored in the property file. </p>
<p>getBolleanProperty really does not throw any exception if the value is not a boolean value at all!</p>
<p>If the original programmer had designed any syntax check, or simpley used Boolean.valueOf, which throws an exception if the parameter is malformed, debugging this problem would have been much easier. This is where exceptions are supposed to help.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yaseb.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yaseb.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yaseb.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yaseb.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yaseb.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yaseb.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yaseb.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yaseb.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yaseb.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yaseb.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yaseb.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yaseb.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yaseb.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yaseb.wordpress.com/106/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yaseb.wordpress.com&amp;blog=10851673&amp;post=106&amp;subd=yaseb&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yaseb.wordpress.com/2011/08/09/how-to-use-exceptions-an-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/15f8ac12fc526f9245082feb5f1c5db4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gefeizhang</media:title>
		</media:content>
	</item>
		<item>
		<title>Foldr in Python</title>
		<link>http://yaseb.wordpress.com/2011/06/11/foldr-in-python/</link>
		<comments>http://yaseb.wordpress.com/2011/06/11/foldr-in-python/#comments</comments>
		<pubDate>Sat, 11 Jun 2011 08:48:34 +0000</pubDate>
		<dc:creator>gefeizhang</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[foldr]]></category>
		<category><![CDATA[functional programming]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://yaseb.wordpress.com/?p=90</guid>
		<description><![CDATA[In [1, p.70] Graham Hutton gives a nice example of the power of the function &#8220;foldr&#8221; in Haskell. The following function bin2int provides a very elegant way to convert a binary number to a decimal number: bin2int = foldr(\x y -&#62; x + 2 * y) 0 Since I am programming Python now, I asked [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yaseb.wordpress.com&amp;blog=10851673&amp;post=90&amp;subd=yaseb&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In [1, p.70] Graham Hutton gives a nice example of the power of the function &#8220;foldr&#8221; in Haskell. The following function bin2int provides a very elegant way to convert a binary number to a decimal number:<br />
<code> bin2int = foldr(\x y -&gt; x + 2 * y) 0</code></p>
<p>Since I am programming Python now, I asked myself how to do foldr in Python.</p>
<p>The answer is surprisingly simple: just reverse x and y in the lambda expression, as well as the list. For instance, bin2int can be implemented in Python as:</p>
<p><code><br />
def bin2int(x):<br />
&nbsp;    t = copy.deepcopy(x)<br />
&nbsp;    t.reverse()<br />
&nbsp;    return reduce(lambda y,x: x+2*y, t)<br />
</code></p>
<p>Voila. There we got a foldr in python!</p>
<p>[1] Graham Hutton. Programming in Haskell. Cambridge University Press. 2007.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yaseb.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yaseb.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yaseb.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yaseb.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yaseb.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yaseb.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yaseb.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yaseb.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yaseb.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yaseb.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yaseb.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yaseb.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yaseb.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yaseb.wordpress.com/90/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yaseb.wordpress.com&amp;blog=10851673&amp;post=90&amp;subd=yaseb&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yaseb.wordpress.com/2011/06/11/foldr-in-python/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/15f8ac12fc526f9245082feb5f1c5db4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gefeizhang</media:title>
		</media:content>
	</item>
		<item>
		<title>Something surprising in Groovy Meta Programing</title>
		<link>http://yaseb.wordpress.com/2011/01/10/something-surprising-in-groovy-meta-programing/</link>
		<comments>http://yaseb.wordpress.com/2011/01/10/something-surprising-in-groovy-meta-programing/#comments</comments>
		<pubDate>Mon, 10 Jan 2011 10:42:59 +0000</pubDate>
		<dc:creator>gefeizhang</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[mop]]></category>

		<guid isPermaLink="false">http://yaseb.wordpress.com/?p=81</guid>
		<description><![CDATA[Suppose you have a Groovy shell which contains the following code: def b = 5 println this.binding.getVariable("b") If you run this script, an error is reported: Caught: groovy.lang.MissingPropertyException: No such property: b for class: groovy.lang.Binding But if you remove the &#8220;def&#8221; type of variable b, surprise, it works! def b = 5 println this.binding.getVariable("b") This [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yaseb.wordpress.com&amp;blog=10851673&amp;post=81&amp;subd=yaseb&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Suppose you have a Groovy shell which contains the following code:<br />
<code><br />
def b = 5<br />
println this.binding.getVariable("b")<br />
</code></p>
<p>If you run this script, an error is reported:<br />
<code><br />
Caught: groovy.lang.MissingPropertyException: No such property: b for class: groovy.lang.Binding</code></p>
<p>But if you remove the &#8220;def&#8221; type of variable b, surprise, it works!<br />
<code><br />
<del datetime="2011-01-10T10:34:34+00:00">def</del> b = 5<br />
println this.binding.getVariable("b")<br />
</code></p>
<p>This means that a variable of a script is stored in its binding only when the variable is not declared with a type. Interesting, no?</p>
<p>The reason for this strange behavior is that when in a script a variable is not declared, it is then stored in the binding of the script. If the variable is not yet contained in the binding, then it is added to the binding. On the other side, when a variable is declared in the script, then it is considered local, and not stored in the binding.</p>
<p>I don&#8217;t really undestand the reason of this rule, though. It only complicates things unnecessarity. Simply putting everything in the binding would be clear and leave the programmer no chance to make mistakes (in confusing binding or not binding). </p>
<p>Exploring the Groovy literatur to find more &#8230;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yaseb.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yaseb.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yaseb.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yaseb.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yaseb.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yaseb.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yaseb.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yaseb.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yaseb.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yaseb.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yaseb.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yaseb.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yaseb.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yaseb.wordpress.com/81/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yaseb.wordpress.com&amp;blog=10851673&amp;post=81&amp;subd=yaseb&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yaseb.wordpress.com/2011/01/10/something-surprising-in-groovy-meta-programing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/15f8ac12fc526f9245082feb5f1c5db4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gefeizhang</media:title>
		</media:content>
	</item>
		<item>
		<title>Ten Things Oscar Nierstrasz Hates About Object-Oriented-Programming</title>
		<link>http://yaseb.wordpress.com/2010/10/18/ten-things-oscar-nierstrasz-hates-about-object-oriented-programming/</link>
		<comments>http://yaseb.wordpress.com/2010/10/18/ten-things-oscar-nierstrasz-hates-about-object-oriented-programming/#comments</comments>
		<pubDate>Mon, 18 Oct 2010 19:54:28 +0000</pubDate>
		<dc:creator>gefeizhang</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[object-orientation]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://yaseb.wordpress.com/?p=74</guid>
		<description><![CDATA[Found at &#8220;The Journal of Object Technology&#8220;<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yaseb.wordpress.com&amp;blog=10851673&amp;post=74&amp;subd=yaseb&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Found at &#8220;<a href="http://blog.jot.fm/2010/08/26/ten-things-i-hate-about-object-oriented-programming/">The Journal of Object Technology</a>&#8220;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yaseb.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yaseb.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yaseb.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yaseb.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yaseb.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yaseb.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yaseb.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yaseb.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yaseb.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yaseb.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yaseb.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yaseb.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yaseb.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yaseb.wordpress.com/74/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yaseb.wordpress.com&amp;blog=10851673&amp;post=74&amp;subd=yaseb&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yaseb.wordpress.com/2010/10/18/ten-things-oscar-nierstrasz-hates-about-object-oriented-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/15f8ac12fc526f9245082feb5f1c5db4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gefeizhang</media:title>
		</media:content>
	</item>
	</channel>
</rss>
