<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Prajwal Tuladhar's Blog</title>
	
	<link>http://prajwal-tuladhar.net.np</link>
	<description>programming, life and some random thoughts</description>
	<pubDate>Wed, 17 Jun 2009 07:02:12 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
	<language>en</language>
			<image><link>http://prajwal-tuladhar.net.np/</link><url>http://farm4.static.flickr.com/3024/3005114783_8a194e69e0.jpg?v=0</url><title>Prajwal Tuladhar's Icon</title></image><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/Prajwal" type="application/rss+xml" /><feedburner:emailServiceId>Prajwal</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2FPrajwal" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FPrajwal" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.feedburner.com%2FPrajwal" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/Prajwal" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2FPrajwal" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2FPrajwal" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FPrajwal" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Four Phases Test of Unit Testing</title>
		<link>http://feedproxy.google.com/~r/Prajwal/~3/j78g5ReabHg/</link>
		<comments>http://prajwal-tuladhar.net.np/2009/06/17/401/four-phases-test-of-unit-testing/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 06:59:11 +0000</pubDate>
		<dc:creator>Prajwal Tuladhar</dc:creator>
		
		<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">http://prajwal-tuladhar.net.np/?p=401</guid>
		<description><![CDATA[Gerald Meszaros has defined four phases to be included while structuring unit tests. The four phases are:

Setup is the first phase where test fixture is setup for the SUT (System under Test) to exhibit the expected behaviour as well as anything we need to put in place to be able to observe the actual outcome
Interact [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://xunitpatterns.com/index.html">Gerald Meszaros</a> has defined four phases to be included while structuring unit tests. The four phases are:</p>
<ul>
<li><strong>Setup</strong> is the first phase where test fixture is setup for the <a href="http://xunitpatterns.com/SUT.html">SUT</a> (System under Test) to exhibit the expected behaviour as well as anything we need to put in place to be able to observe the actual outcome</li>
<li>Interact with the SUT or <strong>exercise</strong></li>
<li><strong>Verify</strong> / Determine if expected outcome is obtained</li>
<li><strong>Tear Down</strong> the test fixture</li>
</ul>
<p><a href="http://xunitpatterns.com/Four%20Phase%20Test.gif"><img class="alignnone" title="Four Phase Test" src="http://xunitpatterns.com/Four%20Phase%20Test.gif" alt="" width="552" height="258" /></a></p>
<h2>Implementation</h2>
<p><strong>Account.rb</strong></p>
<pre name="code" class="ruby">

class Account
  MIN_BALANCE = 100
  attr_reader :balance

  def initialize
    @balance = MIN_BALANCE
  end
end
</pre>
<p><strong>account_test.rb</strong></p>
<pre name="code" class="ruby">

class Account_Test &lt; Test::Unit::TestCase
  def test_there_should_be_minium_balance_when_account_is_created
    #setup
    @account = Account.new
    #exercise
    balance = @account.balance
    #verify
    assert_operator balance, :&gt;, 0
  end

  def teardown
    @account = nil
  end
end
</pre>
<p>You can get more information about this topic <a href="http://xunitpatterns.com/Four%20Phase%20Test.html">here</a>.</p>
<div id="st200812023983" class="st-taf"><br/><script src="http://cdn.socialtwist.com/200812023983/script.js"></script><img style="border:0;margin:0;padding:0;" src="http://images.socialtwist.com/200812023983/button.png" onmouseout="hideHoverMap(this)" onmouseover="showHoverMap(this, '200812023983',  'http%3A%2F%2Fprajwal-tuladhar.net.np%2F2009%2F06%2F17%2F401%2Ffour-phases-test-of-unit-testing%2F', 'Four+Phases+Test+of+Unit+Testing')" onclick="cw(this, {id:'200812023983',link: 'http%3A%2F%2Fprajwal-tuladhar.net.np%2F2009%2F06%2F17%2F401%2Ffour-phases-test-of-unit-testing%2F', title: '+Four+Phases+Test+of+Unit+Testing+' })"/></div>
<p><a href="http://feedads.g.doubleclick.net/~a/Vd1N93XAmbYDr_q-dAYGTSoG9OM/0/da"><img src="http://feedads.g.doubleclick.net/~a/Vd1N93XAmbYDr_q-dAYGTSoG9OM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Vd1N93XAmbYDr_q-dAYGTSoG9OM/1/da"><img src="http://feedads.g.doubleclick.net/~a/Vd1N93XAmbYDr_q-dAYGTSoG9OM/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Prajwal?a=j78g5ReabHg:0gn1lGBQJt4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=j78g5ReabHg:0gn1lGBQJt4:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=j78g5ReabHg:0gn1lGBQJt4:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=j78g5ReabHg:0gn1lGBQJt4:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=j78g5ReabHg:0gn1lGBQJt4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Prajwal?i=j78g5ReabHg:0gn1lGBQJt4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=j78g5ReabHg:0gn1lGBQJt4:-njXHGV8hqY"><img src="http://feeds.feedburner.com/~ff/Prajwal?i=j78g5ReabHg:0gn1lGBQJt4:-njXHGV8hqY" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Prajwal/~4/j78g5ReabHg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://prajwal-tuladhar.net.np/2009/06/17/401/four-phases-test-of-unit-testing/feed/</wfw:commentRss>
		<feedburner:origLink>http://prajwal-tuladhar.net.np/2009/06/17/401/four-phases-test-of-unit-testing/</feedburner:origLink></item>
		<item>
		<title>Damn! There is a difference between HTTP POST and HTTP PUT</title>
		<link>http://feedproxy.google.com/~r/Prajwal/~3/our9UwLbgDo/</link>
		<comments>http://prajwal-tuladhar.net.np/2009/05/31/397/there-is-a-difference-between-http-post-and-http-put/#comments</comments>
		<pubDate>Sun, 31 May 2009 09:14:20 +0000</pubDate>
		<dc:creator>Prajwal Tuladhar</dc:creator>
		
		<category><![CDATA[REST]]></category>

		<guid isPermaLink="false">http://prajwal-tuladhar.net.np/?p=397</guid>
		<description><![CDATA[HTTP 1.1 specifications has defined number of request methods like: GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT, OPTIONS. But generally, GET and POST are two widely used and de-facto request methods due to the restrictions set by the server as well as client in most of the scenarios. As a web developer, I do know [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.w3.org/Protocols/rfc2616/rfc2616.html">HTTP 1.1</a> specifications has defined number of <a href="http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods">request methods</a> like: GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT, OPTIONS. But generally, GET and POST are two widely used and de-facto request methods due to the restrictions set by the server as well as client in most of the scenarios. As a web developer, I do know that these methods exist but like most of the web developers I had focused only on POST and GET because normally, other methods besides GET and POST are not supported by most web servers.</p>
<p>It&#8217;s been few sessions that I have started playing with document based storage technology, <a title="CouchDB" href="http://couchdb.apache.org/">CouchDB</a> which is *naturally* based on the <a href="http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm">REST</a> philosophy. There is a really nice <a href="http://books.couchdb.org/relax/why-couchdb">quote</a> in CouchDB book site &#8220;Django may be built for the Web, but CouchDB is built of the Web&#8221;.</p>
<p>Everything was going fine until there was a command for creating database that utilizes HTTP PUT method:<br />
<pre>$ curl -X PUT http://127.0.0.1:5984:/new_db</pre><br />
<pre>The response is: {&quot;ok&quot;:true}</pre><br />
So, I was wondering what will happen if I use POST because my preception was that POST and PUT are <em>really</em> not so much different:<br />
<pre>$ curl -X POST http://127.0.0.1:5984:/new_db</pre><br />
<pre>Response: {&quot;error&quot;:&quot;not_found&quot;, &quot;reason&quot;: &quot;missing&quot;}</pre><br />
Booom! I was wrong!</p>
<p>As usual I google on the web and was pretty happy to find that it was not only me who was confused about PUT versus POST debate <img src='http://prajwal-tuladhar.net.np/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>W3C has <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.6">defined</a> following functions of POST:</p>
<ul>
<li>Annotation of existing resources;</li>
<li>Posting a message to a bulletin board, newsgroup, mailing list, or similar group of articles;</li>
<li>Providing a block of data, such as the result of submitting a form, to a data-handling process;</li>
<li>Extending a database through an append operation.</li>
</ul>
<p>Let&#8217;s focus only on first function of POST for now. It clearly states that POST should be used for <em>existing</em> resources.</p>
<p>In my case, http://127.0.0.1:5984:/new_db has not existed yet so, using POST to create is against the specification.</p>
<p>But again trying to differentiate PUT and POST as: PUT for creating new resource and POST for updating existing one would be awful mistake. One can view PUT as a SQL insert operation. When a specified URI is defined, it will create resource there if the resource does not exist or replace the existing one.</p>
<p>But POST is quite flexible and can perform more operations as compared to PUT. POST sends data to the specified URI but how it will be processed is entirely dependent on the server. The action performed by the POST method might not result in a resource that can be identified by a URI. In this case, either 200 (OK) or 204 (No Content) is the appropriate response status, depending on whether or not the response includes an entity that describes the result.</p>
<p>According to the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.6">HTTP 1.1 specification</a>:</p>
<blockquote><p>The fundamental difference between the POST and PUT requests is reflected in the different meaning of the Request-URI. The URI in a POST request identifies the resource that will handle the enclosed entity. That resource might be a data-accepting process, a gateway to some other protocol, or a separate entity that accepts annotations. In contrast, the URI in a PUT request identifies the entity enclosed with the request &#8212; the user agent knows what URI is intended and the server MUST NOT attempt to apply the request to some other resource. If the server desires that the request be applied to a different URI, it MUST send a 301 (Moved Permanently) response; the user agent MAY then make its own decision regarding whether or not to redirect the request.</p></blockquote>
<h3>Examples:</h3>
<ul>
<li>PUT =&gt; http://mysocialapp/users/{username} =&gt; createUser</li>
<li>PUT =&gt; http://mysocialapp/users/{username} =&gt; updateUser</li>
<li>POST =&gt; http://mysocialapp/users/{username}/posts =&gt; createPost</li>
<li>PUT =&gt; http://mysocialapp/users/{username}/posts/{post_id} =&gt; updatePost</li>
</ul>
<p>The URI and client will be ultimately responsible for handling above requests URI. If we look at the POST example, there is no way one can map the URI for every posts being created so, POST is idempotent and non-cacheable. While first and second example shows that PUT can be used not only to create resource but also to update it. But this solely depends on who is responsible for creating the new resource&#8217;s URI: client or the server. If client is responsible, then it should response 201 (&#8221;created&#8221;) when new resource is created and when the resource URI already exists, it should use POST method. If the server is responsible, it should respond 401 (&#8221;unauthorized&#8221;). If I try to create same database &#8220;new_db&#8221; using:<br />
<pre>$ curl -X POST http://127.0.0.1:5984:/new_db then CouchDB returns {&quot;error&quot;: &quot;database_already_exists&quot;, &quot;reason&quot;:&quot;Database &quot;another_test_db&quot; already exists&quot;}</pre><br />
Lastly, it would be better if <a href="http://www.ics.uci.edu/~fielding/">Roy T. Fielding</a>’s <a href="http://www.imc.org/atom-protocol/mail-archive/msg05425.html">response</a> on PUT is also considered:</p>
<blockquote><p>FWIW, PUT does not mean store.  I must have repeated that a million times in webdav and related lists.  HTTP defines the intended semantics of the communication &#8212; the expectations of each party. The protocol does not define how either side fulfills those expectations, and it makes damn sure it doesn&#8217;t prevent a server from having absolute authority over its own resources.  Also, resources are known to change over time, so if a server accepts an invalid Atom entry via PUT one second and then immediately thereafter decides to change it to a valid entry for later GETs, life is grand.</p></blockquote>
<h3>Some useful links + resources:</h3>
<ul>
<li><a title="http://www.w3.org/QA/2008/10/understanding-http-put.html" href="http://www.w3.org/QA/2008/10/understanding-http-put.html">http://www.w3.org/QA/2008/10/understanding-http-put.html</a></li>
<li><a title="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.5" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.5">http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.5</a></li>
<li><a title="http://www.elharo.com/blog/software-development/web-development/2005/12/08/post-vs-put/" href="http://www.elharo.com/blog/software-development/web-development/2005/12/08/post-vs-put/">http://www.elharo.com/blog/software-development/web-development/2005/12/08/post-vs-put/</a></li>
<li><a href="http://www.infoq.com/articles/subbu-allamaraju-rest">http://www.infoq.com/articles/subbu-allamaraju-rest</a> [Really nice article about REST- <strong>Recommended!</strong>]</li>
</ul>
<p>Please do correct me if I am wrong <img src='http://prajwal-tuladhar.net.np/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
<div id="st200812023983" class="st-taf"><br/><script src="http://cdn.socialtwist.com/200812023983/script.js"></script><img style="border:0;margin:0;padding:0;" src="http://images.socialtwist.com/200812023983/button.png" onmouseout="hideHoverMap(this)" onmouseover="showHoverMap(this, '200812023983',  'http%3A%2F%2Fprajwal-tuladhar.net.np%2F2009%2F05%2F31%2F397%2Fthere-is-a-difference-between-http-post-and-http-put%2F', 'Damn%21+There+is+a+difference+between+HTTP+POST+and+HTTP+PUT')" onclick="cw(this, {id:'200812023983',link: 'http%3A%2F%2Fprajwal-tuladhar.net.np%2F2009%2F05%2F31%2F397%2Fthere-is-a-difference-between-http-post-and-http-put%2F', title: '+Damn%21+There+is+a+difference+between+HTTP+POST+and+HTTP+PUT+' })"/></div>
<p><a href="http://feedads.g.doubleclick.net/~a/HXdS-e-hHO7Hi_8zSVnX08Wyhw8/0/da"><img src="http://feedads.g.doubleclick.net/~a/HXdS-e-hHO7Hi_8zSVnX08Wyhw8/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/HXdS-e-hHO7Hi_8zSVnX08Wyhw8/1/da"><img src="http://feedads.g.doubleclick.net/~a/HXdS-e-hHO7Hi_8zSVnX08Wyhw8/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Prajwal?a=our9UwLbgDo:n8cY_ZOO_Vg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=our9UwLbgDo:n8cY_ZOO_Vg:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=our9UwLbgDo:n8cY_ZOO_Vg:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=our9UwLbgDo:n8cY_ZOO_Vg:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=our9UwLbgDo:n8cY_ZOO_Vg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Prajwal?i=our9UwLbgDo:n8cY_ZOO_Vg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=our9UwLbgDo:n8cY_ZOO_Vg:-njXHGV8hqY"><img src="http://feeds.feedburner.com/~ff/Prajwal?i=our9UwLbgDo:n8cY_ZOO_Vg:-njXHGV8hqY" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Prajwal/~4/our9UwLbgDo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://prajwal-tuladhar.net.np/2009/05/31/397/there-is-a-difference-between-http-post-and-http-put/feed/</wfw:commentRss>
		<feedburner:origLink>http://prajwal-tuladhar.net.np/2009/05/31/397/there-is-a-difference-between-http-post-and-http-put/</feedburner:origLink></item>
		<item>
		<title>There gotta be correction</title>
		<link>http://feedproxy.google.com/~r/Prajwal/~3/xmaTB9d6ttc/</link>
		<comments>http://prajwal-tuladhar.net.np/2009/05/27/393/there-gotta-be-correction/#comments</comments>
		<pubDate>Thu, 28 May 2009 01:58:16 +0000</pubDate>
		<dc:creator>Prajwal Tuladhar</dc:creator>
		
		<category><![CDATA[iSpeak]]></category>

		<guid isPermaLink="false">http://prajwal-tuladhar.net.np/?p=393</guid>
		<description><![CDATA[No doubt that smart phones are the next PC and their use will grow at exponential rate iPhone along with its innovative AppStore has changed the dynamism of this industry. Apple has rejuvenated once boring mobile platform with the introduction of platform that lets third party developers to write applications and eventually make money. With [...]]]></description>
			<content:encoded><![CDATA[<p>No doubt that smart phones are the next PC and their use will grow at exponential rate iPhone along with its innovative AppStore has changed the dynamism of this industry. Apple has rejuvenated once boring mobile platform with the introduction of platform that lets third party developers to write applications and eventually make money. With the success of AppStore, others like Microsoft, Nokia, RIM, Palm and Google are following or have taken some similar steps. So, one can expect do-or-die battle for the dominance of yet to grow and lucrative smart phone industry.</p>
<p>If we analyze the current events that have been taking place in this industry with the pre-mature phase of PC industry, we can find some similarities. The PC industry flourished with the introduction of GUI computers from Apple with the ability for 3rd party developers to write an application for. Prior to as well as after introduction of Apple OS, there were various vendors including Microsoft, IBM, DEC and so on offering similar services. But at last, as it normally happens in the information economy, only one emerged as the dominant force, it was Microsoft at that time. The success of Microsoft during PC battle was not just because of Microsoft Windows and/or DOS was superior to other available platforms, but Microsoft had and still have support of  wide array of hardware and software vendors. Apple and other vendors lost the PC war because of that particular reason.</p>
<p><a href="http://farm3.static.flickr.com/2363/2408688070_813305aec4.jpg?v=1214246155"><img class="alignnone" src="http://farm3.static.flickr.com/2363/2408688070_813305aec4.jpg?v=1214246155" alt="" width="496" height="500" /></a></p>
<p>Now lets come to current smart phone war. There are so many vendors offering or soon to be offering their own OS along with application platforms like Apple iPhone + AppStore, Google Android + MarketPlace, Palm Pre, Windows Mobile + Windows Marketplace, RIM + AppWorld, Nokia + Ovi and may be we will hear more in the near future. For now, as a developer it&#8217;s much easier to choose a smart phone platform to develop for (most in the US choose iPhone with Android trailing by long margin). Just imagine what will happen once all major vendors provide similar platforms after sometime. <strong>Which platform will you choose and what about interoperability?</strong> Certainly for large companies this won&#8217;t be a big issue as they have and they can afford to provide their applications for respective platforms. <strong>But what about those small developers and entrepreneurs and even for someone trying to get into mobile phone development?</strong> It will be just be crazy and/or practically impossible to offer certain services in all platforms.</p>
<p>I think we are going in somewhat wrong direction. With so much hype of iPhone and Android, along with other upcoming platforms especially Palm Pre, developers are forgetting about interoperability that the Internet and WWW have taught us and what Web 2.0 have delivered us. We are again going back to same PC era and writing applications for vendor specific platforms. Smart phone and as a whole mobile industry should focus providing their APIs respecting the concept of WWW. It&#8217;s true that browsers are available in almost all smart phones but which application will you choose when one is offered as a native one and while other being offered pointing to some URL like htpp://m.time.com or m.cnn.com and so on. In most of the cases, users will rightly choose former.</p>
<p>I am not saying platforms that enable developers to write vendor specific application is wrong but  one needs to fear that after sometime, it will be quite hard to offer applications for each and every platforms. But I am optimistic that one dominant player will emerge as victorious in the current smart phone battle and it will be the next Microsoft for PC and/or Google for Internet search.</p>
<p>My Bet: certainly not Apple even though iPhone + AppStore  provide the most superior platform for now <img src='http://prajwal-tuladhar.net.np/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p>
<div id="st200812023983" class="st-taf"><br/><script src="http://cdn.socialtwist.com/200812023983/script.js"></script><img style="border:0;margin:0;padding:0;" src="http://images.socialtwist.com/200812023983/button.png" onmouseout="hideHoverMap(this)" onmouseover="showHoverMap(this, '200812023983',  'http%3A%2F%2Fprajwal-tuladhar.net.np%2F2009%2F05%2F27%2F393%2Fthere-gotta-be-correction%2F', 'There+gotta+be+correction')" onclick="cw(this, {id:'200812023983',link: 'http%3A%2F%2Fprajwal-tuladhar.net.np%2F2009%2F05%2F27%2F393%2Fthere-gotta-be-correction%2F', title: '+There+gotta+be+correction+' })"/></div>
<p><a href="http://feedads.g.doubleclick.net/~a/5YGVBotoIOevHavab_CbXI4zvYo/0/da"><img src="http://feedads.g.doubleclick.net/~a/5YGVBotoIOevHavab_CbXI4zvYo/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/5YGVBotoIOevHavab_CbXI4zvYo/1/da"><img src="http://feedads.g.doubleclick.net/~a/5YGVBotoIOevHavab_CbXI4zvYo/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Prajwal?a=xmaTB9d6ttc:cWsrtj_6Mhc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=xmaTB9d6ttc:cWsrtj_6Mhc:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=xmaTB9d6ttc:cWsrtj_6Mhc:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=xmaTB9d6ttc:cWsrtj_6Mhc:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=xmaTB9d6ttc:cWsrtj_6Mhc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Prajwal?i=xmaTB9d6ttc:cWsrtj_6Mhc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=xmaTB9d6ttc:cWsrtj_6Mhc:-njXHGV8hqY"><img src="http://feeds.feedburner.com/~ff/Prajwal?i=xmaTB9d6ttc:cWsrtj_6Mhc:-njXHGV8hqY" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Prajwal/~4/xmaTB9d6ttc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://prajwal-tuladhar.net.np/2009/05/27/393/there-gotta-be-correction/feed/</wfw:commentRss>
		<feedburner:origLink>http://prajwal-tuladhar.net.np/2009/05/27/393/there-gotta-be-correction/</feedburner:origLink></item>
		<item>
		<title>What Killed Smalltalk could also kill Ruby – Nice Keynote by Bob Martin</title>
		<link>http://feedproxy.google.com/~r/Prajwal/~3/zxmQpaJh080/</link>
		<comments>http://prajwal-tuladhar.net.np/2009/05/09/390/what-killed-smalltalk-could-also-kill-ruby-nice-keynote-by-bob-martin/#comments</comments>
		<pubDate>Sat, 09 May 2009 17:06:42 +0000</pubDate>
		<dc:creator>Prajwal Tuladhar</dc:creator>
		
		<category><![CDATA[Links]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[iSpeak]]></category>

		<category><![CDATA[rails]]></category>

		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://prajwal-tuladhar.net.np/2009/05/09/390/what-killed-smalltalk-could-also-kill-ruby-nice-keynote-by-bob-martin/</guid>
		<description><![CDATA[This is an interesting keynote presentation by Robert Martin delivered during RailsConf 2009. According to Robert Martin, Smalltalk was the most superior language of its time and even with such unique features and even being the epicenter for introducing Pattern based development, Test Driven approach and various OO principles we are following, Smalltalk was never [...]]]></description>
			<content:encoded><![CDATA[<p>This is an interesting <a href="http://railsconf.blip.tv/file/2089545/">keynote presentation</a> by Robert Martin delivered during <a href="http://en.oreilly.com/rails2009/">RailsConf 2009</a>. According to <a href="http://www.objectmentor.com/omTeam/martin_r.html">Robert Martin</a>, <a href="http://en.wikipedia.org/wiki/Smalltalk">Smalltalk</a> was the most superior language of its time and even with such unique features and even being the epicenter for introducing Pattern based development, <a href="http://en.wikipedia.org/wiki/Test-driven_development">Test Driven</a> approach and various OO principles we are following, Smalltalk was never successful with mainstream developers and eventually extinct with the popularity of JAVA in early mid 1990s. He believes that failure of Smalltalk users to ignore problems commonly faced by enterprises and attitude of Smalltalk users in being more superior than other platform developers were one of the crucial reasons that killed SmallTalk. He further expressed during the keynote that if Ruby and Rails community fail and/or ignore problems faced by enterprises then, there is a chance what happened to Smalltalk could also happen to Ruby.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="550" height="390" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://blip.tv/play/AYGAlmaGvAQ" /><embed type="application/x-shockwave-flash" width="550" height="390" src="http://blip.tv/play/AYGAlmaGvAQ"></embed></object></p>
<p>I think the video is a must watch if you a Ruby developer and/or want to jump to Ruby/Rails band wagon. There’s no doubt that Rails is one of the leading web frameworks that have embed the concept of test driven development at its core and Ruby developers have always been in the fore front adopting agile development strategies. But whenever I read some blog posts/articles and writings by Ruby enthusiasts and developers, I feel some kind of rebel and attitude of superiority in their expression which is somewhat same as mentioned in the keynote. Ironically, most of the Ruby syntax is also inspired from Smalltlk with small blend of C; that’s why Ruby is also called reincarnation of Smalltalk but lets hope Ruby won’t be next Smalltalk and as Microsoft new initiative <strong><a title="Make Web Not War" href="http://www.youtube.com/watch?v=cCApcSq1ke0">Make Web Not War</a>.</strong></p>
<div id="st200812023983" class="st-taf"><br/><script src="http://cdn.socialtwist.com/200812023983/script.js"></script><img style="border:0;margin:0;padding:0;" src="http://images.socialtwist.com/200812023983/button.png" onmouseout="hideHoverMap(this)" onmouseover="showHoverMap(this, '200812023983',  'http%3A%2F%2Fprajwal-tuladhar.net.np%2F2009%2F05%2F09%2F390%2Fwhat-killed-smalltalk-could-also-kill-ruby-nice-keynote-by-bob-martin%2F', 'What+Killed+Smalltalk+could+also+kill+Ruby+%26ndash%3B+Nice+Keynote+by+Bob+Martin')" onclick="cw(this, {id:'200812023983',link: 'http%3A%2F%2Fprajwal-tuladhar.net.np%2F2009%2F05%2F09%2F390%2Fwhat-killed-smalltalk-could-also-kill-ruby-nice-keynote-by-bob-martin%2F', title: '+What+Killed+Smalltalk+could+also+kill+Ruby+%26ndash%3B+Nice+Keynote+by+Bob+Martin+' })"/></div>
<p><a href="http://feedads.g.doubleclick.net/~a/TdG8v9Yy7oca7cJk7RZi_12x0o8/0/da"><img src="http://feedads.g.doubleclick.net/~a/TdG8v9Yy7oca7cJk7RZi_12x0o8/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/TdG8v9Yy7oca7cJk7RZi_12x0o8/1/da"><img src="http://feedads.g.doubleclick.net/~a/TdG8v9Yy7oca7cJk7RZi_12x0o8/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Prajwal?a=zxmQpaJh080:GMCoSuhfYz0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=zxmQpaJh080:GMCoSuhfYz0:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=zxmQpaJh080:GMCoSuhfYz0:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=zxmQpaJh080:GMCoSuhfYz0:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=zxmQpaJh080:GMCoSuhfYz0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Prajwal?i=zxmQpaJh080:GMCoSuhfYz0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=zxmQpaJh080:GMCoSuhfYz0:-njXHGV8hqY"><img src="http://feeds.feedburner.com/~ff/Prajwal?i=zxmQpaJh080:GMCoSuhfYz0:-njXHGV8hqY" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Prajwal/~4/zxmQpaJh080" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://prajwal-tuladhar.net.np/2009/05/09/390/what-killed-smalltalk-could-also-kill-ruby-nice-keynote-by-bob-martin/feed/</wfw:commentRss>
		<feedburner:origLink>http://prajwal-tuladhar.net.np/2009/05/09/390/what-killed-smalltalk-could-also-kill-ruby-nice-keynote-by-bob-martin/</feedburner:origLink></item>
		<item>
		<title>Book Review: House of Cards - A Tale of Hubris and Wretched Excess on Wall</title>
		<link>http://feedproxy.google.com/~r/Prajwal/~3/XzGyaXuGVh0/</link>
		<comments>http://prajwal-tuladhar.net.np/2009/05/01/389/book-review-house-of-cards-a-tale-of-hubris-and-wretched-excess-on-wall/#comments</comments>
		<pubDate>Sat, 02 May 2009 04:28:34 +0000</pubDate>
		<dc:creator>Prajwal Tuladhar</dc:creator>
		
		<category><![CDATA[iSpeak]]></category>

		<guid isPermaLink="false">http://prajwal-tuladhar.net.np/2009/05/01/389/book-review-house-of-cards-a-tale-of-hubris-and-wretched-excess-on-wall/</guid>
		<description><![CDATA[
Cover via Amazon

&#160;
Finally, I completed reading House of Cards - A Tale of Hubris and Wretched Excess on Wall Street by William D. Cohan  I accept that I may not have enough background knowledge for understanding each and every terms mentioned in this book and even for writing book review but I am petty [...]]]></description>
			<content:encoded><![CDATA[<div style="margin: 1em; width: 141px; display: block; float: right" class="zemanta-img" jquery1241232787231="17703"><a href="http://www.amazon.com/House-Cards-Hubris-Wretched-Excess/dp/0385528264%3FSubscriptionId%3D0G81C5DAZ03ZR9WH9X82%26tag%3Dzemanta-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0385528264"><img style="border-bottom: medium none; border-left: medium none; display: block; border-top: medium none; border-right: medium none" alt="Cover of &quot;House of Cards: A Tale of Hubri..." src="http://ecx.images-amazon.com/images/I/51W1qaZU0UL._SL200_.jpg" width="131" height="200" /></a>
<p style="font-size: 0.8em" class="zemanta-img-attribution"><a href="http://www.amazon.com/House-Cards-Hubris-Wretched-Excess/dp/0385528264%3FSubscriptionId%3D0G81C5DAZ03ZR9WH9X82%26tag%3Dzemanta-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0385528264">Cover via Amazon</a></p>
</p></div>
<p>&#160;</p>
<p>Finally, I completed reading <a title="House of Cards - A Tale of Hubris and Wretched Excess on Wall Street" href="http://www.amazon.com/House-Cards-Hubris-Wretched-Excess/dp/0385528264/">House of Cards - A Tale of Hubris and Wretched Excess on Wall Street</a> by William D. Cohan <img src='http://prajwal-tuladhar.net.np/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> I accept that I may not have enough background knowledge for understanding each and every terms mentioned in this book and even for writing book review but I am petty sure that now I have general knowing about the state of <a href="http://en.wikipedia.org/wiki/Wall_Street">Wall Street</a> and financial mess they have nurtured in the form of sub prime mortgages and other complicated financial instruments like derivatives (I swear I don’t know what the fuck is this).</p>
<p>Cohan is a former senior Wall Street <a class="zem_slink" title="Investment banking" href="http://en.wikipedia.org/wiki/Investment_banking" rel="wikipedia">investment banker</a>, author of <em>The Last Tycoons</em> and as a whole a respected writer and/or journalist.&#160; I am really impressed by the way this book is written. The sequence of the events and excitement of consequences produced by them is what let me to complete this book in such a short time interval. </p>
<p>The book describes about the whole life cycle (from the birth and impressive rise to the dramatic collapse) of once proud investment bank <a href="http://en.wikipedia.org/wiki/Bear_Stearns">Bear Stearns</a> that became the first major casualty of the global financial crisis or credit crunch and consequently triggering the global financial system in the edge of collapse. Bear Stearns was eventually acquired by <a href="http://en.wikipedia.org/wiki/JPMorgan_Chase_%26_Co.">JPMorgan Chase</a> in the <a href="http://www.marketoracle.co.uk/Article4051.html">fire sale</a> price for just $2, later adjusted to $10 after shareholder lawsuit (Just a month or so ago it was trading above $100).</p>
<p>Here are some of the major events / points from the book:</p>
<ul>
<li>Bear Stearns had had leverage ratio of nearly 40 times i.e. it was borrowing $40 by showing liquid asset of $1. Not only Bear Stearns, AIG (Always Investing Garbage Hmm..Did I write something wrong:) ), Lehman Brothers and most financial institutions and investment banks were leveraged in the same way. </li>
<li><strong>Confident is the name of the game in the Wall Street.</strong> Just couple of weeks before the collapse of Bear Stearns, it had $18 Billion cash in hand. But once news about its potential survival and toxic assets in its balance sheet began to leak, there was run for money by its clients and no one was ready to do business with Bear. </li>
<li>Though Bear Stearns was a public company, its management and overall control was in the hand of few people namely <a href="http://en.wikipedia.org/wiki/Ace_Greenberg">Ace Greenberg</a>, <a href="http://en.wikipedia.org/wiki/Jimmy_Cayne">Jimmy Cayne</a> and <a href="http://en.wikipedia.org/wiki/Alan_Schwartz">Alan D. Schwart</a>. The failure of Bear was not only due to its business model but managerial missteps and personal rivalry about controlling the firm were also one of the causes. </li>
<li>Its quite shocking to know that most of the investment banks rely on over night funding for their daily transactions. </li>
<li>The <a href="http://en.wikipedia.org/wiki/Rating_agencies">rating agencies</a> like <a href="http://en.wikipedia.org/wiki/Standard_%26_Poor%27s">Standard &amp; Poor&#8217;s</a>, <a href="http://en.wikipedia.org/wiki/Moody%27s">Moody&#8217;s</a> and <a href="http://en.wikipedia.org/wiki/Fitch_Ratings">Fitch Ratings</a> are the bitch of Wall Street firms and also one of the <a href="http://www.nytimes.com/2007/11/02/business/02norris.html?_r=1&amp;ref=business">major villains</a> of this crisis. </li>
<li>Ironically, the executives of the failed firms like Bear Stearns and Lehman brothers were <a href="http://tpmcafe.talkingpointsmemo.com/2008/03/17/the_feds_forced_marriage_of_be/">highest paid</a>. But overall, all Wall Street executives normally were make millions even after the crisis (Remember <a href="http://www.nytimes.com/2009/03/15/business/15AIG.html?hp">AIG bonus saga</a>). Wall Street has always be known for its excessive pay and risky investments especially after the de-regulation initiated during Clinton Administration.</li>
</ul>
<p><a title="You will find only bear nowadays" href="http://www.flickr.com/photos/mapplegate/493240888/"><img style="margin: 0px 15px 0px 0px; display: inline" align="left" src="http://farm1.static.flickr.com/213/493240888_0df2131d7b.jpg?v=1237576987" /></a> </p>
<p>Certainly the above list do not fully capitalize what this book explains. I have to say, I never thought it would be so interesting to read a book about finance world. But I believe that every person in the world is being directly or indirectly affected by the current crisis should have at least rough idea about how <a href="http://en.wikipedia.org/wiki/Financial_Crisis_2008">crisis</a> of such magnitude completely took the world by surprise. As currently I am living in New York, which being the home of Wall Street can be considered as the epicenter of the current mess and one of the most <a href="http://www.nydailynews.com/money/2008/10/21/2008-10-21_mayor_bloomberg_economic_crisis_already_.html">affected</a> state so, getting to know about the financial crisis is always nice.</p>
<div style="margin-top: 10px; height: 15px" class="zemanta-pixie"></div>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>And I can conclude what I learn in just one statement:</p>
<blockquote><p>Investment banking is an unregulated black magic that let you to believe you are making chunk of profit that is kinda NULL in reality.</p>
</blockquote>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:5cbae9e6-3376-4b44-957a-dc03b43f5383" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/book+review" rel="tag">book review</a>,<a href="http://technorati.com/tags/financial+crisis" rel="tag">financial crisis</a>,<a href="http://technorati.com/tags/bear+stearns" rel="tag">bear stearns</a>,<a href="http://technorati.com/tags/wall+street" rel="tag">wall street</a></div>
<div id="st200812023983" class="st-taf"><br/><script src="http://cdn.socialtwist.com/200812023983/script.js"></script><img style="border:0;margin:0;padding:0;" src="http://images.socialtwist.com/200812023983/button.png" onmouseout="hideHoverMap(this)" onmouseover="showHoverMap(this, '200812023983',  'http%3A%2F%2Fprajwal-tuladhar.net.np%2F2009%2F05%2F01%2F389%2Fbook-review-house-of-cards-a-tale-of-hubris-and-wretched-excess-on-wall%2F', 'Book+Review%3A+House+of+Cards+-+A+Tale+of+Hubris+and+Wretched+Excess+on+Wall')" onclick="cw(this, {id:'200812023983',link: 'http%3A%2F%2Fprajwal-tuladhar.net.np%2F2009%2F05%2F01%2F389%2Fbook-review-house-of-cards-a-tale-of-hubris-and-wretched-excess-on-wall%2F', title: '+Book+Review%3A+House+of+Cards+-+A+Tale+of+Hubris+and+Wretched+Excess+on+Wall+' })"/></div>
<p><a href="http://feedads.g.doubleclick.net/~a/bcZJGXN3Fa0CQeI_AHe120ogW78/0/da"><img src="http://feedads.g.doubleclick.net/~a/bcZJGXN3Fa0CQeI_AHe120ogW78/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/bcZJGXN3Fa0CQeI_AHe120ogW78/1/da"><img src="http://feedads.g.doubleclick.net/~a/bcZJGXN3Fa0CQeI_AHe120ogW78/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Prajwal?a=XzGyaXuGVh0:quA3hX_bIOk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=XzGyaXuGVh0:quA3hX_bIOk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=XzGyaXuGVh0:quA3hX_bIOk:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=XzGyaXuGVh0:quA3hX_bIOk:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=XzGyaXuGVh0:quA3hX_bIOk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Prajwal?i=XzGyaXuGVh0:quA3hX_bIOk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=XzGyaXuGVh0:quA3hX_bIOk:-njXHGV8hqY"><img src="http://feeds.feedburner.com/~ff/Prajwal?i=XzGyaXuGVh0:quA3hX_bIOk:-njXHGV8hqY" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Prajwal/~4/XzGyaXuGVh0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://prajwal-tuladhar.net.np/2009/05/01/389/book-review-house-of-cards-a-tale-of-hubris-and-wretched-excess-on-wall/feed/</wfw:commentRss>
		<feedburner:origLink>http://prajwal-tuladhar.net.np/2009/05/01/389/book-review-house-of-cards-a-tale-of-hubris-and-wretched-excess-on-wall/</feedburner:origLink></item>
		<item>
		<title>Vicious cycle of unsatisfactory code</title>
		<link>http://feedproxy.google.com/~r/Prajwal/~3/y8L0Z6Ficck/</link>
		<comments>http://prajwal-tuladhar.net.np/2009/04/27/384/vicious-cycle-of-unsatisfactory-code/#comments</comments>
		<pubDate>Tue, 28 Apr 2009 03:37:20 +0000</pubDate>
		<dc:creator>Prajwal Tuladhar</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[iSpeak]]></category>

		<guid isPermaLink="false">http://prajwal-tuladhar.net.np/?p=384</guid>
		<description><![CDATA[Software engineering and programming are such an inquisitive fields that there are always unexplained avenues for gaining improvement. I may not have proper authority to fully capitalize the previous statement because being relatively new to programming (couple of years or so of professional career), there are so many unexplored horizons of software development that I [...]]]></description>
			<content:encoded><![CDATA[<p>Software engineering and programming are such an inquisitive fields that there are always unexplained avenues for gaining improvement. I may not have proper authority to fully capitalize the previous statement because being relatively new to programming (couple of years or so of professional career), there are so many unexplored horizons of software development that I still need to explore.</p>
<p>But every time I write some code and after sometime, I personally feel that the code I wrote sometime ago is really awful and dirty. I have to admit that most of my personal projects that I did alone was kinda failure and/or bizarre  and no doubt they have taught me lessons I will never ever forget in my life.</p>
<p>I reviewed the code I wrote just few months ago and I was able to extract so many mistakes and would be bugs that I wrote that code again. And may be after few months, I will do same again. But this cycle of writing bad code and after certain time getting to feel how erroneous me and my code does make me quite happy and I can  make self comparison how am I improving as a programmer that does not just code but write clean and testable code <img src='http://prajwal-tuladhar.net.np/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . But I am really loving this <strong><em>vicious cycle of unsatisfactory code</em></strong>.</p>
<p><a href="http://farm4.static.flickr.com/3110/2657063096_1511679911_d.jpg"><img class="alignnone" title="Vicious cycle - Flickr" src="http://farm4.static.flickr.com/3110/2657063096_1511679911_d.jpg" alt="" width="468" height="443" /></a></p>
<p style="margin-bottom: 0in;">If you are new and kinda enthusiastic programmer then, I guess you have also experience similar and/or related cycle of dissatisfaction and are always searching to learn and implement something new. It would be really nice if you can share your experience too.</p>
<div id="st200812023983" class="st-taf"><br/><script src="http://cdn.socialtwist.com/200812023983/script.js"></script><img style="border:0;margin:0;padding:0;" src="http://images.socialtwist.com/200812023983/button.png" onmouseout="hideHoverMap(this)" onmouseover="showHoverMap(this, '200812023983',  'http%3A%2F%2Fprajwal-tuladhar.net.np%2F2009%2F04%2F27%2F384%2Fvicious-cycle-of-unsatisfactory-code%2F', 'Vicious+cycle+of+unsatisfactory+code')" onclick="cw(this, {id:'200812023983',link: 'http%3A%2F%2Fprajwal-tuladhar.net.np%2F2009%2F04%2F27%2F384%2Fvicious-cycle-of-unsatisfactory-code%2F', title: '+Vicious+cycle+of+unsatisfactory+code+' })"/></div>
<p><a href="http://feedads.g.doubleclick.net/~a/PJ9hJwHbktfZi0qbaQHbIfNPoKw/0/da"><img src="http://feedads.g.doubleclick.net/~a/PJ9hJwHbktfZi0qbaQHbIfNPoKw/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/PJ9hJwHbktfZi0qbaQHbIfNPoKw/1/da"><img src="http://feedads.g.doubleclick.net/~a/PJ9hJwHbktfZi0qbaQHbIfNPoKw/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Prajwal?a=y8L0Z6Ficck:4DUk2hakuZk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=y8L0Z6Ficck:4DUk2hakuZk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=y8L0Z6Ficck:4DUk2hakuZk:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=y8L0Z6Ficck:4DUk2hakuZk:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=y8L0Z6Ficck:4DUk2hakuZk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Prajwal?i=y8L0Z6Ficck:4DUk2hakuZk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=y8L0Z6Ficck:4DUk2hakuZk:-njXHGV8hqY"><img src="http://feeds.feedburner.com/~ff/Prajwal?i=y8L0Z6Ficck:4DUk2hakuZk:-njXHGV8hqY" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Prajwal/~4/y8L0Z6Ficck" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://prajwal-tuladhar.net.np/2009/04/27/384/vicious-cycle-of-unsatisfactory-code/feed/</wfw:commentRss>
		<feedburner:origLink>http://prajwal-tuladhar.net.np/2009/04/27/384/vicious-cycle-of-unsatisfactory-code/</feedburner:origLink></item>
		<item>
		<title>Four rules of simple design</title>
		<link>http://feedproxy.google.com/~r/Prajwal/~3/qtZrFmOkzpU/</link>
		<comments>http://prajwal-tuladhar.net.np/2009/04/26/383/four-rules-of-simple-design/#comments</comments>
		<pubDate>Mon, 27 Apr 2009 03:08:38 +0000</pubDate>
		<dc:creator>Prajwal Tuladhar</dc:creator>
		
		<category><![CDATA[Patterns]]></category>

		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://prajwal-tuladhar.net.np/2009/04/26/383/four-rules-of-simple-design/</guid>
		<description><![CDATA[Yeah again I am quoting some interesting text from Clean Code  
It’s about four simple rules by Kent Beck on simple design:

Runs all the tests
Contains no duplications
Expresses the intent of the programmers
Minimizes the number of classes and methods

I agree with al the three rules but the fourth one seems little difficult to follow especially [...]]]></description>
			<content:encoded><![CDATA[<p>Yeah again I am quoting some interesting text from <a title="Clean Code: A Handbook of Agile Software Craftsmanship (Robert C. Martin Series)" href="http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882">Clean Code</a> <img src='http://prajwal-tuladhar.net.np/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>It’s about four simple rules by <a title="Kent Beck" href="http://en.wikipedia.org/wiki/Kent_Beck">Kent Beck</a> on simple design:</p>
<ul>
<li>Runs all the tests</li>
<li>Contains no duplications</li>
<li>Expresses the intent of the programmers</li>
<li>Minimizes the number of classes and methods</li>
</ul>
<p>I agree with al the three rules but the fourth one seems little difficult to follow especially if you are also following the <a title="Single Responsibility Principle" href="http://en.wikipedia.org/wiki/Single_responsibility_principle">Single Responsibility Principle</a>. But since its is listed in the last, I assume it should be given less priority. What do you think?</p>
<div id="st200812023983" class="st-taf"><br/><script src="http://cdn.socialtwist.com/200812023983/script.js"></script><img style="border:0;margin:0;padding:0;" src="http://images.socialtwist.com/200812023983/button.png" onmouseout="hideHoverMap(this)" onmouseover="showHoverMap(this, '200812023983',  'http%3A%2F%2Fprajwal-tuladhar.net.np%2F2009%2F04%2F26%2F383%2Ffour-rules-of-simple-design%2F', 'Four+rules+of+simple+design')" onclick="cw(this, {id:'200812023983',link: 'http%3A%2F%2Fprajwal-tuladhar.net.np%2F2009%2F04%2F26%2F383%2Ffour-rules-of-simple-design%2F', title: '+Four+rules+of+simple+design+' })"/></div>
<p><a href="http://feedads.g.doubleclick.net/~a/ngDmOhz5oY7JGxHGXT9qXhn8wtA/0/da"><img src="http://feedads.g.doubleclick.net/~a/ngDmOhz5oY7JGxHGXT9qXhn8wtA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/ngDmOhz5oY7JGxHGXT9qXhn8wtA/1/da"><img src="http://feedads.g.doubleclick.net/~a/ngDmOhz5oY7JGxHGXT9qXhn8wtA/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Prajwal?a=qtZrFmOkzpU:0CgXWP7KY-g:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=qtZrFmOkzpU:0CgXWP7KY-g:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=qtZrFmOkzpU:0CgXWP7KY-g:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=qtZrFmOkzpU:0CgXWP7KY-g:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=qtZrFmOkzpU:0CgXWP7KY-g:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Prajwal?i=qtZrFmOkzpU:0CgXWP7KY-g:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=qtZrFmOkzpU:0CgXWP7KY-g:-njXHGV8hqY"><img src="http://feeds.feedburner.com/~ff/Prajwal?i=qtZrFmOkzpU:0CgXWP7KY-g:-njXHGV8hqY" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Prajwal/~4/qtZrFmOkzpU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://prajwal-tuladhar.net.np/2009/04/26/383/four-rules-of-simple-design/feed/</wfw:commentRss>
		<feedburner:origLink>http://prajwal-tuladhar.net.np/2009/04/26/383/four-rules-of-simple-design/</feedburner:origLink></item>
		<item>
		<title>Differentiating OO and Structured Code</title>
		<link>http://feedproxy.google.com/~r/Prajwal/~3/rQL1sbdwNcw/</link>
		<comments>http://prajwal-tuladhar.net.np/2009/04/22/380/differentiating-oo-and-structured-code/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 04:33:54 +0000</pubDate>
		<dc:creator>Prajwal Tuladhar</dc:creator>
		
		<category><![CDATA[Patterns]]></category>

		<category><![CDATA[object oriented design]]></category>

		<guid isPermaLink="false">http://prajwal-tuladhar.net.np/?p=380</guid>
		<description><![CDATA[I know we have have hearing, learning and reading so many things about OO and procedural code from the day we are onto the world of OO. But I just figured out one nice point differentiating between them found in the book Clean Code: A Handbook of Agile Software Craftsmanship by Robert C. Martin aka [...]]]></description>
			<content:encoded><![CDATA[<p>I know we have have hearing, learning and reading so many things about OO and procedural code from the day we are onto the world of OO. But I just figured out one nice point differentiating between them found in the book <a href="http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882">Clean Code: A Handbook of Agile Software Craftsmanship</a> by <a href="http://blog.objectmentor.com/">Robert C. Martin aka Uncle Bob</a>.</p>
<blockquote><p><strong>Procedural code (code using data structures) makes it easy to add new features without changing the existing data structures. OO code, on the other hand, makes it easy to add new classes without changing existing features.</strong></p></blockquote>
<p>I think above single statement is more than enough if one wants to know the real difference between OO and procedural code. And again you gotta to have some OO experience in order to understand the depth of the statement.</p>
<p>So far, I have been satisfied with the book (completed around 10 chapters) and if you are interested in making your code clean (in the sense of usability and design), then I strongly recommend the <a title="Clean Code: A Handbook of Agile Software Craftsmanship" href="http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882">book</a>.</p>
<div id="st200812023983" class="st-taf"><br/><script src="http://cdn.socialtwist.com/200812023983/script.js"></script><img style="border:0;margin:0;padding:0;" src="http://images.socialtwist.com/200812023983/button.png" onmouseout="hideHoverMap(this)" onmouseover="showHoverMap(this, '200812023983',  'http%3A%2F%2Fprajwal-tuladhar.net.np%2F2009%2F04%2F22%2F380%2Fdifferentiating-oo-and-structured-code%2F', 'Differentiating+OO+and+Structured+Code')" onclick="cw(this, {id:'200812023983',link: 'http%3A%2F%2Fprajwal-tuladhar.net.np%2F2009%2F04%2F22%2F380%2Fdifferentiating-oo-and-structured-code%2F', title: '+Differentiating+OO+and+Structured+Code+' })"/></div>
<p><a href="http://feedads.g.doubleclick.net/~a/Fck45U-crV70-L61eqnk2VZYMGg/0/da"><img src="http://feedads.g.doubleclick.net/~a/Fck45U-crV70-L61eqnk2VZYMGg/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Fck45U-crV70-L61eqnk2VZYMGg/1/da"><img src="http://feedads.g.doubleclick.net/~a/Fck45U-crV70-L61eqnk2VZYMGg/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Prajwal?a=rQL1sbdwNcw:fzoKh75w774:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=rQL1sbdwNcw:fzoKh75w774:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=rQL1sbdwNcw:fzoKh75w774:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=rQL1sbdwNcw:fzoKh75w774:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=rQL1sbdwNcw:fzoKh75w774:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Prajwal?i=rQL1sbdwNcw:fzoKh75w774:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=rQL1sbdwNcw:fzoKh75w774:-njXHGV8hqY"><img src="http://feeds.feedburner.com/~ff/Prajwal?i=rQL1sbdwNcw:fzoKh75w774:-njXHGV8hqY" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Prajwal/~4/rQL1sbdwNcw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://prajwal-tuladhar.net.np/2009/04/22/380/differentiating-oo-and-structured-code/feed/</wfw:commentRss>
		<feedburner:origLink>http://prajwal-tuladhar.net.np/2009/04/22/380/differentiating-oo-and-structured-code/</feedburner:origLink></item>
		<item>
		<title>Custom event handling with Prototype</title>
		<link>http://feedproxy.google.com/~r/Prajwal/~3/G_I5a_fsQ4Q/</link>
		<comments>http://prajwal-tuladhar.net.np/2009/03/29/378/custom-event-handling-with-prototype/#comments</comments>
		<pubDate>Sun, 29 Mar 2009 09:10:48 +0000</pubDate>
		<dc:creator>Prajwal Tuladhar</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[PrototypeJS]]></category>

		<guid isPermaLink="false">http://prajwal-tuladhar.net.np/?p=378</guid>
		<description><![CDATA[The maturity and development of JavaScript has certainly led to more efficient handling nowadays. Remember those days when IE and Netscape had different event handling mechanisms. Well, the event handling mechanism is still different in IE and non-IE browsers, the popularity of JS libraries like Prototype, jQuery, YUI have certainly helped the web developers to [...]]]></description>
			<content:encoded><![CDATA[<p>The maturity and development of JavaScript has certainly led to more efficient handling nowadays. Remember those days when IE and Netscape had different event handling mechanisms. Well, the event handling mechanism is still different in IE and non-IE browsers, the popularity of JS libraries like Prototype, jQuery, YUI have certainly helped the web developers to fill that gap. One of the main reasons I love to use these libraries (PrototypsJS especially) is that native event handling really sucks. Forget about custom events, just in order to implement event in unobstrsuive way without those libraries you would require to consider event objects differently for IE and non-IE browsers something like this:</p>
<pre name="code" class="js">

document.getElementsByTagName(&quot;input&quot;)[0].onkeypress = function(e)	{
	// If no event object exists, then grab the global (IE-only) one
	e = e || window.event;
	return e.keyCode != 13;		//Do nothing when Enter is pressed
}
</pre>
<p>Its just a simple tiny example but one can imagine the potential complexity that could arise in nowadays&#8217; site with petty high use of JS.</p>
<p>I did know that custom event handling exist in Prototype but I believe in <a title="YAGNI" href="http://en.wikipedia.org/wiki/You_Ain%27t_Gonna_Need_It">YAGNI</a> and never realized its potential. But as I am working in a project with massive JS and Ajax use, finally I have seen and used how custom events can be used to invoke to control encapsulate built-in JS events and use them in quite a flexible way.</p>
<p>While searching on the web about thistopic I found some really nice articles.</p>
<ul>
<li><a href="http://www.truerwords.net/articles/web-tech/custom_events.html">Creating Custom Events with JavaScript: Decoupling</a></li>
<li><a href="http://www.dustindiaz.com/custom-events/">Publishing Custom Events in JavaScript</a></li>
</ul>
<p>This <a href="http://www.dustindiaz.com/custom-events/">last article</a> has tried to explain normal and cusom events as:</p>
<blockquote><p>When we describe normal events to our peers as a series of interactions, we generally say something like &#8220;For this tab menu, I want to swap the colors, then change the message on ‘click’ of the tab.&#8221;. Or if that sounds too awkward. We’ll say &#8220;When the user ‘clicks’ on the tab, I want to swap the colors and change the message.&#8221;</p>
<p>I can see it swindling in your brain already. Sure enough, the first thing that would normally come to a scripters mind is…. &#8220;I’ll assign a ‘click’ event to the tab that fires a function which will swap the colors, then change the message&#8221;. Fair enough. That totally works and that’s the way most people do it.</p>
<p>A custom event in this same model can be something you, yes you, get to make up. Looking at our tab/click/swapColor/changeMessage illustration, we can easily turn this into an event called onTabChange. In return, anytime our tab menu changes state, we can notify our listeners/subscribers that this event occured; then do whatever the heck we want on the fly.</p></blockquote>
<p>Just following the above explanation, I have come with a simple example: A test scenario where a check box determines whether to enable or disable the onchange events for elements with CSS like .input. When the checkbox is enabled, particular onchange event for particular elements are also enabled and vice-versa.</p>
<p><a href="http://farm4.static.flickr.com/3661/3394777624_ed51681686_o.png"><img class="alignnone" src="http://farm4.static.flickr.com/3661/3394777624_ed51681686_o.png" alt="" width="470" height="175" /></a></p>
<h3>Here is the HTML Code:</h3>
<pre name="code" class="html">

&lt;fieldset&gt;
	&lt;legend&gt;
		JS Custom Events
	&lt;/legend&gt;
	&lt;div&gt;
		&lt;input type=&quot;checkbox&quot; value=&quot;1&quot; id=&quot;enableInputEvents&quot; /&gt;&amp;nbsp;Enable events for text box and combo box&lt;br/&gt;
	&lt;/div&gt;
	&lt;div id=&quot;inputs_elements&quot;&gt;
		Text Box 1:&amp;nbsp;&lt;input type=&quot;text&quot; id=&quot;textbox1&quot; value=&quot;&quot; class=&quot;input&quot; /&gt;&lt;br/&gt;
		Text Box 2:&amp;nbsp;&lt;input type=&quot;text&quot; id=&quot;textbox2&quot; value=&quot;&quot; /&gt;&lt;br/&gt;
		Select Search Engine: &lt;select id=&quot;search-engine-selector&quot; class=&quot;input&quot;&gt;
			&lt;option value=&quot;&quot;&gt;Go to&lt;/option&gt;
			&lt;option value=&quot;http://www.google.com&quot;&gt;Google&lt;/option&gt;
			&lt;option value=&quot;http://www.yahoo.com&quot;&gt;Yahoo!&lt;/option&gt;
			&lt;option value=&quot;http://www.live.com&quot;&gt;Live&lt;/option&gt;
		&lt;/select&gt;
	&lt;/div&gt;
&lt;/fieldset&gt;
</pre>
<h3>And JavaScript code for firing custom events:</h3>
<pre name="code" class="js">

Event.observe(document, &#039;dom:loaded&#039;, function()	{
	$(&#039;enableInputEvents&#039;).observe(&#039;click&#039;, function(e)	{
		document.fire(&#039;CheckBox:Enabled&#039;, {checked: $(&#039;enableInputEvents&#039;).checked});
	});
});

document.observe(&#039;CheckBox:Enabled&#039;, function(e)	{
	Event.stop(e);
	if (e.memo.checked)	{
		console.log(&quot;all elements with CSS class input are ENABLED&quot;);
		$$(&#039;.input&#039;).each(function(t)	{
			t.observe(&#039;change&#039;, function()	{
				alert(t.value);
			});
		});
	}
	else	{
		console.log(&quot;all elements with CSS class input are DISABLED&quot;);
		$$(&#039;.input&#039;).invoke(&#039;stopObserving&#039;);
	}
});
</pre>
<p>Custom event handling in Prototype is a bit different than other JS libraries. And CheckBox:Enabled is a special notation type for firing custom events. <a href="http://www.prototypejs.org/api/element/methods/fire">Prototype API</a> call this notation as namespace:eventname o avoid custom event names conflicting with non-standard native DOM events such as mousewheel and DOMMouseScroll.</p>
<h3>When the Checkbox is enabled</h3>
<p><a href="http://farm4.static.flickr.com/3577/3394777746_5f28683225_o.png"><img class="alignnone" src="http://farm4.static.flickr.com/3577/3394777746_5f28683225_o.png" alt="" width="611" height="469" /></a></p>
<h3>When the Checkbox is disabled</h3>
<p><a href="http://farm4.static.flickr.com/3634/3394778066_9610803868_o.png"><img class="alignnone" src="http://farm4.static.flickr.com/3634/3394778066_9610803868_o.png" alt="" width="429" height="463" /></a></p>
<div id="st200812023983" class="st-taf"><br/><script src="http://cdn.socialtwist.com/200812023983/script.js"></script><img style="border:0;margin:0;padding:0;" src="http://images.socialtwist.com/200812023983/button.png" onmouseout="hideHoverMap(this)" onmouseover="showHoverMap(this, '200812023983',  'http%3A%2F%2Fprajwal-tuladhar.net.np%2F2009%2F03%2F29%2F378%2Fcustom-event-handling-with-prototype%2F', 'Custom+event+handling+with+Prototype')" onclick="cw(this, {id:'200812023983',link: 'http%3A%2F%2Fprajwal-tuladhar.net.np%2F2009%2F03%2F29%2F378%2Fcustom-event-handling-with-prototype%2F', title: '+Custom+event+handling+with+Prototype+' })"/></div>
<p><a href="http://feedads.g.doubleclick.net/~a/uij9bFc-hWWSv16k2jb3S_9CDj4/0/da"><img src="http://feedads.g.doubleclick.net/~a/uij9bFc-hWWSv16k2jb3S_9CDj4/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/uij9bFc-hWWSv16k2jb3S_9CDj4/1/da"><img src="http://feedads.g.doubleclick.net/~a/uij9bFc-hWWSv16k2jb3S_9CDj4/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Prajwal?a=G_I5a_fsQ4Q:fYrGoop0rXI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=G_I5a_fsQ4Q:fYrGoop0rXI:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=G_I5a_fsQ4Q:fYrGoop0rXI:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=G_I5a_fsQ4Q:fYrGoop0rXI:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=G_I5a_fsQ4Q:fYrGoop0rXI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Prajwal?i=G_I5a_fsQ4Q:fYrGoop0rXI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=G_I5a_fsQ4Q:fYrGoop0rXI:-njXHGV8hqY"><img src="http://feeds.feedburner.com/~ff/Prajwal?i=G_I5a_fsQ4Q:fYrGoop0rXI:-njXHGV8hqY" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Prajwal/~4/G_I5a_fsQ4Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://prajwal-tuladhar.net.np/2009/03/29/378/custom-event-handling-with-prototype/feed/</wfw:commentRss>
		<feedburner:origLink>http://prajwal-tuladhar.net.np/2009/03/29/378/custom-event-handling-with-prototype/</feedburner:origLink></item>
		<item>
		<title>Flexible function call in JavaScript</title>
		<link>http://feedproxy.google.com/~r/Prajwal/~3/7FhKS1VmgNo/</link>
		<comments>http://prajwal-tuladhar.net.np/2009/03/28/373/flexible-function-call-in-javascript/#comments</comments>
		<pubDate>Sun, 29 Mar 2009 01:19:43 +0000</pubDate>
		<dc:creator>Prajwal Tuladhar</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[PrototypeJS]]></category>

		<guid isPermaLink="false">http://prajwal-tuladhar.net.np/?p=373</guid>
		<description><![CDATA[If you have used popular JavaScript libraries like PrototypeJS, jQuery and so on (I have used only PrototypeJS and Adobe Spry), you may have noticed the flexibility of calling their API class and methods. Something like this while using PrototyeJS AJAX API:


new Ajax.Request(url, {
	onSuccess: function(response)	{
		//do something
	}
	onException: function(response, exception)	{
		//do something
	}
	onFailure: function()	{
		//do something
	}
});

I have figured out that [...]]]></description>
			<content:encoded><![CDATA[<p>If you have used popular JavaScript libraries like PrototypeJS, jQuery and so on (I have used only PrototypeJS and Adobe Spry), you may have noticed the flexibility of calling their API class and methods. Something like this while using PrototyeJS AJAX API:</p>
<pre name="code" class="javascript">

new Ajax.Request(url, {
	onSuccess: function(response)	{
		//do something
	}
	onException: function(response, exception)	{
		//do something
	}
	onFailure: function()	{
		//do something
	}
});
</pre>
<p>I have figured out that creating a method that can handle such call is certainly not so hard and in my opinion, it does provide some level of flexibility in the code.<br />
Here is the same code:</p>
<pre name="code" class="javascript">

function clickIt(options)	{
	this.message = &quot;&quot;;
	this.afterClick = function()	{};

	for (var key in options) {
        this[key] = options[key];
    }

	this._execute = function()	{
		alert(this.message);
		this.afterClick();
	}

	this._execute();
}
</pre>
<p>The above method accepts a single object as an argument with two properties: message and afterClick and this._execute() is a kinda private method (JavaScript does not have an explicit access modifier). Now to call the above function:</p>
<pre name="code" class="javascript">

Event.observe(window, &#039;load&#039;, function()	{
	$(&#039;iclick&#039;).observe(&#039;click&#039;, function(e)	{
		Event.stop(e);
		new clickIt({
			message: &quot;This is some message&quot;,
			afterClick: function()	{
				if (confirm(&quot;Are you sure&quot;))	{
					window.location.replace(this.href);
				}
			}
		});
	});
});
</pre>
<p>Since <strong>{}</strong> is regarded as object in JavaScript so one can use it to make a function/class more flexible and extensible. But since, users calling this class will have no knowledge what arguments are acceptable so, documentation plays crucial role (If you are creating an API then, the success and usability of that API heavily depends on the quality of documentation that acts as valid contract between interface and implementation code).</p>
<div id="st200812023983" class="st-taf"><br/><script src="http://cdn.socialtwist.com/200812023983/script.js"></script><img style="border:0;margin:0;padding:0;" src="http://images.socialtwist.com/200812023983/button.png" onmouseout="hideHoverMap(this)" onmouseover="showHoverMap(this, '200812023983',  'http%3A%2F%2Fprajwal-tuladhar.net.np%2F2009%2F03%2F28%2F373%2Fflexible-function-call-in-javascript%2F', 'Flexible+function+call+in+JavaScript')" onclick="cw(this, {id:'200812023983',link: 'http%3A%2F%2Fprajwal-tuladhar.net.np%2F2009%2F03%2F28%2F373%2Fflexible-function-call-in-javascript%2F', title: '+Flexible+function+call+in+JavaScript+' })"/></div>
<p><a href="http://feedads.g.doubleclick.net/~a/XocZlXxIKZmJPVm7HDoEWlqk6yI/0/da"><img src="http://feedads.g.doubleclick.net/~a/XocZlXxIKZmJPVm7HDoEWlqk6yI/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/XocZlXxIKZmJPVm7HDoEWlqk6yI/1/da"><img src="http://feedads.g.doubleclick.net/~a/XocZlXxIKZmJPVm7HDoEWlqk6yI/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Prajwal?a=7FhKS1VmgNo:xOvuTMfItT8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=7FhKS1VmgNo:xOvuTMfItT8:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=7FhKS1VmgNo:xOvuTMfItT8:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=7FhKS1VmgNo:xOvuTMfItT8:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/Prajwal?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=7FhKS1VmgNo:xOvuTMfItT8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Prajwal?i=7FhKS1VmgNo:xOvuTMfItT8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Prajwal?a=7FhKS1VmgNo:xOvuTMfItT8:-njXHGV8hqY"><img src="http://feeds.feedburner.com/~ff/Prajwal?i=7FhKS1VmgNo:xOvuTMfItT8:-njXHGV8hqY" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Prajwal/~4/7FhKS1VmgNo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://prajwal-tuladhar.net.np/2009/03/28/373/flexible-function-call-in-javascript/feed/</wfw:commentRss>
		<feedburner:origLink>http://prajwal-tuladhar.net.np/2009/03/28/373/flexible-function-call-in-javascript/</feedburner:origLink></item>
	</channel>
</rss>
