<?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>Kanian77's Weblog</title>
	<atom:link href="http://kanian77.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://kanian77.wordpress.com</link>
	<description>MVC,PHP, and some more</description>
	<lastBuildDate>Fri, 24 Jun 2011 14:19:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='kanian77.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Kanian77's Weblog</title>
		<link>http://kanian77.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://kanian77.wordpress.com/osd.xml" title="Kanian77&#039;s Weblog" />
	<atom:link rel='hub' href='http://kanian77.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Simple Javascript MVC (2)</title>
		<link>http://kanian77.wordpress.com/2011/06/24/simple-javascript-mvc-2/</link>
		<comments>http://kanian77.wordpress.com/2011/06/24/simple-javascript-mvc-2/#comments</comments>
		<pubDate>Fri, 24 Jun 2011 13:53:49 +0000</pubDate>
		<dc:creator>kanian77</dc:creator>
				<category><![CDATA[MVC]]></category>
		<category><![CDATA[MVC and the web]]></category>
		<category><![CDATA[Obserser Pattern]]></category>
		<category><![CDATA[Pub/Sub]]></category>

		<guid isPermaLink="false">http://kanian77.wordpress.com/?p=72</guid>
		<description><![CDATA[The previous version of the code just showed some &#8220;proof of concept&#8221; about using pub/sub to implement MVC in javascript. The AmplifyJS framework was used for its Pub/Sub implementation. To make what is going on a little bit clearer I isolated the pub/sub code into an Observer object. I also formalised the MVC triad into [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kanian77.wordpress.com&amp;blog=2054282&amp;post=72&amp;subd=kanian77&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The previous version of the code just showed some &#8220;proof of concept&#8221; about using pub/sub to implement MVC in javascript. The AmplifyJS framework was used for its Pub/Sub implementation.<br />
To make what is going on a little bit clearer I isolated the pub/sub code into an Observer object. I also formalised the MVC triad into the Model, View and Controller objects.<br />
View decorates the Observer object with some view specific functionanlity, while Controller and Model are still mere Observers.<br />
Next step: maybe try and use the Command pattern.</p>
<p>Observer:<br />
<code><br />
/* requires AmplifyJS */</p>
<p> Observer = function (aEventsToPublish, aEventsToSubscribeTo){<br />
           var pubsub = amplify;<br />
           var events = [];</p>
<p>           obj = function(){ };<br />
           obj.prototype.addEvent = function(sEvent){events[sEvent]=true};<br />
           obj.prototype.removeEvent = function(sEvent){if(events[sEvent]) delete events[sEvent]};<br />
           obj.prototype.publish = function(sEvent,oData){</p>
<p>              if(events[sEvent]){</p>
<p>                   pubsub.publish(sEvent, oData);<br />
           }<br />
       };</p>
<p>           obj.prototype.init = function(aEventsToPublish, aEventsToSubscribeTo){<br />
                    if(aEventsToPublish)<br />
                       {<br />
                           for(var i=0; i&lt;aEventsToPublish.length;i++)<br />
                               {<br />
                                   this.addEvent(aEventsToPublish[i]);<br />
                               }<br />
                       }<br />
                   if(aEventsToSubscribeTo)<br />
                       {<br />
                           for(i=0; i&lt;aEventsToSubscribeTo.length;i++)<br />
                               {<br />
                                   pubsub.subscribe(aEventsToSubscribeTo[i].event, aEventsToSubscribeTo[i].handler);</p>
<p>                               }</p>
<p>                       }<br />
               }<br />
          obj.prototype.init(aEventsToPublish, aEventsToSubscribeTo);<br />
           return obj;</p>
<p>       };<br />
</code></p>
<p>View:<br />
<code><br />
/* requires AmplifyJS */</p>
<p> View = function (aTriggers, aEventsToPublish, aEventsToSubscribeTo){</p>
<p>            var view = new Observer( aEventsToPublish, aEventsToSubscribeTo);</p>
<p>           view.init = function (aTriggers,aEventsToPublish, aEventsToSubscribeTo ){<br />
               view.prototype.init(aEventsToPublish, aEventsToSubscribeTo);</p>
<p>               //peform view specific initialisation.<br />
               var i=0;<br />
               if(aTriggers)<br />
                       {<br />
                           for(i=0; i&lt;aTriggers.length;i++)<br />
                               {<br />
                                  eval(&#039;this[aTriggers[&#039;+i+&#039;][&#039;+0+&#039;]]&#039; +&#039;=function(){view.prototype.publish(&quot;&#039;+aTriggers[i][1]+&#039;&quot;)}&#039;);<br />
                               }<br />
                       }<br />
           }<br />
          view.init(aTriggers,aEventsToPublish, aEventsToSubscribeTo);<br />
           return view;<br />
       };<br />
</code></p>
<p>Find the remainder of the code <a href="https://www.assembla.com/code/pusubmvc/subversion/nodes/branches/v2?rev=5">here</a><a href="http://kanian77.wordpress.com/2011/06/21/simple-javascript-mvc/"></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kanian77.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kanian77.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kanian77.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kanian77.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kanian77.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kanian77.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kanian77.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kanian77.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kanian77.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kanian77.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kanian77.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kanian77.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kanian77.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kanian77.wordpress.com/72/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kanian77.wordpress.com&amp;blog=2054282&amp;post=72&amp;subd=kanian77&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kanian77.wordpress.com/2011/06/24/simple-javascript-mvc-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e1cea03b59b7d4d488bd796e423551e8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kanian77</media:title>
		</media:content>
	</item>
		<item>
		<title>Simple Javascript MVC</title>
		<link>http://kanian77.wordpress.com/2011/06/21/simple-javascript-mvc/</link>
		<comments>http://kanian77.wordpress.com/2011/06/21/simple-javascript-mvc/#comments</comments>
		<pubDate>Tue, 21 Jun 2011 13:15:41 +0000</pubDate>
		<dc:creator>kanian77</dc:creator>
				<category><![CDATA[MVC]]></category>
		<category><![CDATA[MVC and the web]]></category>
		<category><![CDATA[Pub/Sub]]></category>

		<guid isPermaLink="false">http://kanian77.wordpress.com/?p=63</guid>
		<description><![CDATA[OK, so I take forever to finish the MVC framework I talked about here I have been lazy&#8230; But I still come back to something I mentioned in the previous post: The approach I take tends to warrant the use of the Publish/Subscribe pattern. So what I did is use the Publish?subscribe pattern everywhere I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kanian77.wordpress.com&amp;blog=2054282&amp;post=63&amp;subd=kanian77&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>OK, so I take forever to finish the MVC framework I talked about <a href="http://kanian77.wordpress.com/2009/12/15/mvc-in-the-browser/">here</a> I have been lazy&#8230; But I still come back to something I mentioned in the previous post:<br />
The approach I take tends to warrant the use of the Publish/Subscribe pattern.<br />
So what I did is use the Publish?subscribe pattern everywhere I could, that is any time messages needed to be passed between entities. Here our entities are the MVC triad. Contraints as to which can communicate with with which can easily be implemented in the code.<br />
To not reinvent the wheel, I use <a href="http://amplifyjs.com/api/pubsub/">AmplifyJS </a> for the Publish?Subscribe functionality.</p>
<p>Around this pattern, the Controller, the View and the Model are built.<br />
Here you have an example model:</p>
<p><code><br />
numnber_of_clicks_model = (function (){<br />
           var pubsub = amplify;<br />
           var _number = 0;<br />
           NUMBER_INCREMENTED = 'NUMBER_INCREMENTED';<br />
           obj = {<br />
               'incrementCounterHandler': function (){++_number; pubsub.publish(NUMBER_INCREMENTED, {'number': _number}) },<br />
               'decrementCounterHandler': function (){_number = (_number&gt;0) ? --_number: 0;  pubsub.publish(NUMBER_INCREMENTED, {'number': _number})  }<br />
           pubsub.subscribe('INCREMENT_COUNTER',obj.incrementCounterHandler);<br />
           pubsub.subscribe('DECREMENT_COUNTER',obj.decrementCounterHandler);<br />
           return obj; }());<br />
</code></p>
<p>Download it here: https://subversion.assembla.com/svn/pusubmvc/</p>
<p>The files may look big in size, but really, only jquery.js and amplify.js are needed. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kanian77.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kanian77.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kanian77.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kanian77.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kanian77.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kanian77.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kanian77.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kanian77.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kanian77.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kanian77.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kanian77.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kanian77.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kanian77.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kanian77.wordpress.com/63/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kanian77.wordpress.com&amp;blog=2054282&amp;post=63&amp;subd=kanian77&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kanian77.wordpress.com/2011/06/21/simple-javascript-mvc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e1cea03b59b7d4d488bd796e423551e8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kanian77</media:title>
		</media:content>
	</item>
		<item>
		<title>Javascript Test Driven Development (TDD) book excerpt</title>
		<link>http://kanian77.wordpress.com/2010/11/17/javascript-test-driven-development-tdd-book-excerpt/</link>
		<comments>http://kanian77.wordpress.com/2010/11/17/javascript-test-driven-development-tdd-book-excerpt/#comments</comments>
		<pubDate>Wed, 17 Nov 2010 09:11:33 +0000</pubDate>
		<dc:creator>kanian77</dc:creator>
				<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[Observer Pattern]]></category>

		<guid isPermaLink="false">http://kanian77.wordpress.com/?p=61</guid>
		<description><![CDATA[You can find an excellent book excerpt on Javascript TDD here on net.tutsplus.com . Even more interesting is that it uses an implementation of the observer pattern for the tutorial. Good reading!<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kanian77.wordpress.com&amp;blog=2054282&amp;post=61&amp;subd=kanian77&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>You can find an excellent book excerpt on Javascript TDD <a href="http://www.google.co.za/url?sa=t&amp;source=blogsearch&amp;cd=4&amp;ved=0CC0QmAEwAw&amp;url=http%3A%2F%2Fnet.tutsplus.com%2Ftutorials%2Fjavascript-ajax%2Ftest-driven-javascript-development-in-practice%2F&amp;rct=j&amp;q=javascript&amp;ei=9pfjTLraCo6bOuP0-ZIB&amp;usg=AFQjCNGMvolpjjiUhTOjMmgO_lZt0-xvLA&amp;sig2=_iBoz6LUZwgGKJMge4BZew&amp;cad=rja">here </a> on net.tutsplus.com . Even more interesting is that it uses an implementation of the observer pattern for the tutorial.<br />
Good reading!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kanian77.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kanian77.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kanian77.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kanian77.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kanian77.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kanian77.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kanian77.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kanian77.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kanian77.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kanian77.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kanian77.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kanian77.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kanian77.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kanian77.wordpress.com/61/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kanian77.wordpress.com&amp;blog=2054282&amp;post=61&amp;subd=kanian77&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kanian77.wordpress.com/2010/11/17/javascript-test-driven-development-tdd-book-excerpt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e1cea03b59b7d4d488bd796e423551e8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kanian77</media:title>
		</media:content>
	</item>
		<item>
		<title>Prototypal inheritance in Javascript</title>
		<link>http://kanian77.wordpress.com/2009/12/28/prototypal-inheritance-in-javascript/</link>
		<comments>http://kanian77.wordpress.com/2009/12/28/prototypal-inheritance-in-javascript/#comments</comments>
		<pubDate>Mon, 28 Dec 2009 09:37:34 +0000</pubDate>
		<dc:creator>kanian77</dc:creator>
				<category><![CDATA[MVC and the web]]></category>

		<guid isPermaLink="false">http://kanian77.wordpress.com/?p=52</guid>
		<description><![CDATA[In their book "Pro Javascript Design Patterns", Ross Harmes and Dustin Diaz  expose a complication of  prototypal inheritance in javascript linked to updates of compound "prototypal" properties. To solve the same problem Ben Nadel advocates the use of super constructor call from within the sub-class constructor in order to create all the parent object properties in the child object properties. I looked into "Pro Javascript Design Patterns" and at Ben's solution and came with this first attempt at a solution.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kanian77.wordpress.com&amp;blog=2054282&amp;post=52&amp;subd=kanian77&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In their book &#8220;Pro Javascript Design Patterns&#8221;, Ross Harmes and Dustin Diaz  expose a complication of  prototypal inheritance in javascript linked to updates of compound &#8220;prototypal&#8221; properties. By &#8220;prototypal&#8221; properties I mean properties that belong to one of the prototypes  in the object&#8217;s prototype chain.</p>
<p>They give the example:</p>
<blockquote>
<div id="_mcePaste">var CompoundObject = {</div>
<div id="_mcePaste">string1: &#8216;default value&#8217;,</div>
<div id="_mcePaste">childObject:{bool: true, num: 10}</div>
<div id="_mcePaste">}</div>
<div id="_mcePaste">var compoundObjectClone = clone(CompoundObject);</div>
<div id="_mcePaste">// Bad! Changes the value of CompoundObject.childObject.num.</div>
<div id="_mcePaste">compoundObjectClone.childObject.num = 5;</div>
</blockquote>
<p>They propose a solution in the book that entails using a factory method to creates the inner compound property on the cloned object:</p>
<blockquote><p>CompoundObject.childObject = CompoundObject.createChildObject();</p>
<p>var compoundObjectClone = clone(CompoundObject);</p>
<p>compoundObjectClone.childObject = CompoundObject.createChildObject();</p>
<p>compoundObjectClone.childObject.num = 5;</p></blockquote>
<p>To solve the same problem <a href="http://www.bennadel.com/index.cfm?dax=blog:1566.view" target="_blank">Ben Nadel</a> advocates the use of super constructor call from within the sub-class constructor in order to create all the parent object properties in the child object properties. That is, the child has its own copies of the parent&#8217;s properties. His solution works fine even if it is kind of indiscriminate when it comes to which and when a parent property should be created at the child level.</p>
<p>I looked into &#8221;Pro Javascript Design Patterns&#8221; and at Ben&#8217;s solution and came up with two, albeit less simple, solutions to the same problem.</p>
<p>In one of them, the clone function of &#8220;Pro Javascript Design Patterns&#8221; is modified to create specified properties of the &#8220;prototype object&#8221; directly on the child object. This way &#8220;prototype-chain walking&#8221; stop at the child itself and does not ascend to the prototype object.</p>
<p>In another solution, the prototype object itself is defined by an immediately executed function in the scope of which the problematic property is defined as a var. It&#8217;s a closure and it cannot be accessed by &#8220;dot notation&#8221;. We then return an object literal that contains accessor and mutator functions. The accessor checks if the property accessed is on the object or on it&#8217;s prototype. If on the prototype, it returns a copy, not a reference. The mutator sets the property directly on the literal object.</p>
<p>Now, for a longer explanation. Here we have the  first attempt at a solution. In it, we use the &#8220;clone&#8221; function shown in &#8220;Pro Javascript Design Patterns&#8221; and modify it as such:</p>
<blockquote><p>function clone(object,instance_members) {</p>
<p>function F() {}</p>
<p>F.prototype = object;</p>
<p>var _f = new F;</p>
<p>_f.prototype = object;</p>
<p><strong>// instance_members specifies those members of the object parameter that are supposed</strong></p>
<p><strong>// to be copied by value instead of by reference.</strong></p>
<p><strong>// We specify instance level member this way. It helps in keeping modifications</strong></p>
<p><strong>// to the similar properties on the prototype to cascade to the copies.</strong></p>
<p><strong>// Members of the object parameter that are not so specified can be thought of</strong></p>
<p><strong>// as shared members.</strong></p>
<p><strong> if(arguments.length&gt;1)</strong></p>
<p><strong> {</strong></p>
<p><strong> if(!(&#8216;[object Array]&#8216; === Object.prototype.toString.call(instance_members)))</strong></p>
<p><strong> {</strong></p>
<p><strong> throw new Error(&#8220;the second argument to clone function must be an array of strings&#8221;);</strong></p>
<p><strong> }</strong></p>
<p><strong> for(i=0;i&lt;instance_members.length;i++)</strong></p>
<p><strong> {</strong></p>
<p><strong> _f[instance_members[i]] = deep_copy(object[instance_members[i]]);</strong></p>
<p><strong> }</strong></p>
<p><strong> }</strong></p>
<p>return _f;</p>
<p>}</p></blockquote>
<p>The modified clone function can be used in this manner:</p>
<blockquote><p>var CompoundObject = {</p>
<p>string1: &#8216;default value&#8217;,</p>
<p>childObject: {</p>
<p>bool: true,</p>
<p>num: 10</p>
<p>},</p>
<p>getString: function(){</p>
<p>return this.string1;</p>
<p>}</p>
<p>}</p>
<p>var compoundObjectClone = clone(CompoundObject);</p>
<p>//we specify  instance level members in the array parameter</p>
<p><strong>var obj2 = clone(CompoundObject,['childObject']);</strong></p>
<p>// Bad! Changes the value of CompoundObject.childObject.num.</p>
<p>// However it will not affect obj2 created earlier since it&#8217;s childObject parameter</p>
<p>// is set at the instance level.</p>
<p>compoundObjectClone.childObject.num = 5;</p>
<p>// obj3 is created from the modified compound object.</p>
<p>var obj3 = clone(CompoundObject);</p>
<p>alert(&#8220;compoundObjectClone = &#8220;+compoundObjectClone.childObject.num)</p>
<p>alert(&#8220;obj2 = &#8220;+obj2.childObject.num)</p>
<p>alert(&#8220;obj3 = &#8220;+obj3.childObject.num)</p></blockquote>
<p>I came up with another solution using closures and the original clone function of  &#8221;Pro Javascript Design Patterns&#8221;:</p>
<blockquote><p>var CompoundObject = <strong>(function()</strong></p>
<p><strong>{</strong></p>
<p><strong> this.string1 = &#8220;default string&#8221;;</strong></p>
<p><strong> var childObject = {</strong></p>
<p><strong> bool: true,</strong></p>
<p><strong> num: 10</strong></p>
<p><strong> };</strong></p>
<p><strong> return {</strong></p>
<p><strong> getChildObject:  function(){</strong></p>
<p><strong> if(!this.hasOwnProperty(&#8216;childObject&#8217;))</strong></p>
<p><strong> {return deep_copy(childObject);}</strong></p>
<p><strong> return this.childObject</strong></p>
<p><strong> },</strong></p>
<p><strong> setChildObject:function(cobj){</strong></p>
<p><strong> this.childObject = cobj;</strong></p>
<p><strong> }</strong></p>
<p><strong> }</strong></p>
<p><strong>})();</strong></p></blockquote>
<p>In the definition of the object that we want to use as prototype, we define the problematic compound object as a &#8220;var&#8221; so that it is not visible outside the prototype object&#8217;s definition. Moreover we use accessor and mutator methods to manipulate its value.</p>
<p>We can now set the value of the compound object on a child object without changing the prototype property:</p>
<blockquote><p>var compoundObjectClone = clone(CompoundObject);</p>
<p>var obj2 = clone(CompoundObject);</p>
<p>alert(obj2.getChildObject().num);</p>
<p><strong>var cobj = obj2.getChildObject();</strong></p>
<p><strong>cobj.num=5;</strong></p>
<p><strong>obj2.setChildObject(cobj);</strong></p>
<p>alert(&#8216;obj2.getChildObject().num = &#8216;+<strong>obj2.getChildObject().num</strong>);</p>
<p>var obj3 = clone(CompoundObject);</p>
<p>alert(&#8216;obj3.getChildObject().num = &#8216;+obj3.getChildObject().num);</p></blockquote>
<p>With this solution, the object used as prototype is responsible for ensuring it&#8217;s own integrity.</p>
<p>The deep_copy function used in the code comes from <a href="http://javascript.about.com/od/objectorientedjavascript/a/oop17.htm" target="_blank">Stephen Chapman</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kanian77.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kanian77.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kanian77.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kanian77.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kanian77.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kanian77.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kanian77.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kanian77.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kanian77.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kanian77.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kanian77.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kanian77.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kanian77.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kanian77.wordpress.com/52/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kanian77.wordpress.com&amp;blog=2054282&amp;post=52&amp;subd=kanian77&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kanian77.wordpress.com/2009/12/28/prototypal-inheritance-in-javascript/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e1cea03b59b7d4d488bd796e423551e8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kanian77</media:title>
		</media:content>
	</item>
		<item>
		<title>MVC In The Browser</title>
		<link>http://kanian77.wordpress.com/2009/12/15/mvc-in-the-browser/</link>
		<comments>http://kanian77.wordpress.com/2009/12/15/mvc-in-the-browser/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 16:25:30 +0000</pubDate>
		<dc:creator>kanian77</dc:creator>
				<category><![CDATA[MVC]]></category>
		<category><![CDATA[MVC and the web]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[client]]></category>

		<guid isPermaLink="false">http://kanian77.wordpress.com/2009/12/15/mvc-in-the-browser/</guid>
		<description><![CDATA[I have started a &#8220;booklet&#8221; on client-side MVC. It&#8217;s a work in progress. Suggestion are welcomed. Find it at http://www.scribd.com/doc/24130790/MVC-In-The-Browser update: I have posted a very simple implementation of MVC here<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kanian77.wordpress.com&amp;blog=2054282&amp;post=37&amp;subd=kanian77&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have started a &#8220;booklet&#8221; on client-side MVC. It&#8217;s a work in progress. Suggestion are welcomed.<br />
Find it at http://www.scribd.com/doc/24130790/MVC-In-The-Browser </p>
<p>update: I have posted a very simple implementation of MVC <a href="http://kanian77.wordpress.com/2011/06/24/simple-javascript-mvc-2/">here</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kanian77.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kanian77.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kanian77.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kanian77.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kanian77.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kanian77.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kanian77.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kanian77.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kanian77.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kanian77.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kanian77.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kanian77.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kanian77.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kanian77.wordpress.com/37/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kanian77.wordpress.com&amp;blog=2054282&amp;post=37&amp;subd=kanian77&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kanian77.wordpress.com/2009/12/15/mvc-in-the-browser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e1cea03b59b7d4d488bd796e423551e8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kanian77</media:title>
		</media:content>
	</item>
		<item>
		<title>MVC and The Web</title>
		<link>http://kanian77.wordpress.com/2008/09/04/vi-mvc-and-the-web/</link>
		<comments>http://kanian77.wordpress.com/2008/09/04/vi-mvc-and-the-web/#comments</comments>
		<pubDate>Thu, 04 Sep 2008 01:33:31 +0000</pubDate>
		<dc:creator>kanian77</dc:creator>
				<category><![CDATA[MVC and the web]]></category>
		<category><![CDATA[Add new tag]]></category>

		<guid isPermaLink="false">http://kanian77.wordpress.com/?p=25</guid>
		<description><![CDATA[MVC was originally applied in a desktop application environment where the application resides on the computer with wich the user is interacting.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kanian77.wordpress.com&amp;blog=2054282&amp;post=25&amp;subd=kanian77&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="margin-bottom:0;" lang="fr-FR" align="left"><span style="color:#000000;"><span style="font-size:small;"><strong></strong>MVC was originally applied in a desktop application environment where the application resides on the computer with wich the user is interacting.</span></span></p>
<p style="margin-bottom:0;" lang="fr-FR" align="left"><span style="color:#000000;"><span style="font-size:small;">While interacting with a web application, the user is sending requests to a distant server through his browser (the client). The server possess the necessary ressources to respond to the user&#8217;s request. The user receives the server&#8217;s  response on its browser window.  Thus when developers wan to apply the MVC pattern to a web application, they have to take into consideration the client/server environment in which the application operates.</span></span></p>
<p style="margin-bottom:0;" align="left"><span lang="fr-FR"><span style="color:#000000;"><span style="font-size:small;"><span>We will cite</span><strong> </strong></span><span style="font-size:x-small;"><span style="font-family:Times New Roman,serif;">Lech MADEYSKI, Michał STOCHMIAŁEK</span></span></span></span><sup><span lang="fr-FR"><span style="font-size:x-small;"><span style="font-family:Times New Roman,serif;"><span style="color:#000000;"><a class="sdfootnoteanc" name="sdfootnote1anc" href="#sdfootnote1sym"><sup>1</sup></a></span></span></span></span></sup><span lang="fr-FR"><span style="font-size:xx-small;"><span style="font-family:Times New Roman,serif;"><span style="color:#000000;"> <strong>: </strong></span></span></span></span></p>
<p style="margin-bottom:0;" align="left"><em><span lang="fr-FR"><span style="font-size:small;"><span style="color:#000000;"> </span></span></span></em></p>
<ul>
<li><em><span lang="fr-FR"><span style="font-size:small;"><span style="color:#000000;"><span>The</span></span></span></span></em><em> HTTP protocol, the technological foundation of web applications, is stateless.</em></li>
<li><em>Each command is executed independently, without any knowledge of the commands that<br />
came before it.</em></li>
<li><em>Web application’s responsibility is to keep the state between requests.</em></li>
<li><em> Conversation between user and application can be initiated only by the user.</em></li>
<li><em>Control flow of web applications is driven by user requests. It usually consists of<br />
complex sequence of interactions between the user and server.</em></li>
</ul>
<p style="margin-bottom:0;" align="left">
<p><span style="font-style:normal;"><span lang="fr-FR"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;"><span style="color:#000000;">A typical MVC application can be represented by this diagram</span></span></span></span></span><sup><span style="font-style:normal;"><span lang="fr-FR"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;"><span style="color:#000000;"><a class="sdfootnoteanc" name="sdfootnote1anc" href="#sdfootnote1sym"><sup>2</sup></a></span></span></span></span></span></sup><a class="sdfootnotesym" name="sdfootnote1sym" href="#sdfootnote1anc"><br />
</a></p>
<p style="margin-bottom:0;" align="left">
<p style="margin-bottom:0;font-style:normal;" lang="fr-FR" align="left"><a href="http://kanian77.files.wordpress.com/2008/09/mvc.jpg"><img class="alignnone size-full wp-image-26" src="http://kanian77.files.wordpress.com/2008/09/mvc.jpg?w=375&#038;h=247" alt="" width="375" height="247" /></a></p>
<p style="margin-bottom:0;font-style:normal;" lang="fr-FR" align="left"><span style="color:#000000;"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">There exist different solutions to using MVC in a web application. For example server side MVC or MVC/Model 2 will host the Controller, the View and the Model on the server.</span></span></span></p>
<p style="margin-bottom:0;font-style:normal;" lang="fr-FR" align="left">
<p style="margin-bottom:0;font-style:normal;" lang="fr-FR" align="left"><span style="color:#000000;"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"><strong>Server side MVC or  MVC/Model 2</strong></span></span></span></p>
<p style="margin-bottom:0;" align="left"><span style="font-style:normal;"><span lang="fr-FR"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;"><span style="color:#000000;">The simplest way to use MVC in a web application is to put the Controller , the View and the Model  on the server. The user request will be transmitted by the web client as a request to the server that will pass it to the controller. The controller will interpret the user request as a command to the model ( CRUD operations). The controller will make the result of the operation available to the view. The view can then send a response to the web client for display. Here the client will be considered We can represent the process by the following diagram</span></span></span></span></span><sup><span style="font-style:normal;"><span lang="fr-FR"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;"><span style="color:#000000;"><a class="sdfootnoteanc" name="sdfootnote1anc" href="#sdfootnote1sym"><sup>3</sup></a></span></span></span></span></span></sup></p>
<div><a href="http://kanian77.files.wordpress.com/2008/09/mvc_model21.jpg"><img class="alignnone size-full wp-image-28" src="http://kanian77.files.wordpress.com/2008/09/mvc_model21.jpg?w=425&#038;h=216" alt="" width="425" height="216" /></a></div>
<p style="margin-bottom:0;" lang="fr-FR" align="left"><span style="color:#000000;"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">This approach  to adapte MVC to a web environment was  termed the MVC/Model 2 design pattern. </span></span></span></p>
<p style="margin-bottom:0;" align="left"><span lang="fr-FR"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;"><span style="color:#000000;">On the Apache Struts website </span></span></span></span><sup><span lang="fr-FR"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;"><span style="color:#000000;"><a class="sdfootnoteanc" name="sdfootnote1anc" href="#sdfootnote1sym"><sup>4</sup></a></span></span></span></span></sup><span lang="fr-FR"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;"><span style="color:#000000;"> we can read:</span></span></span></span></p>
<p style="margin-bottom:0;" lang="fr-FR" align="left">
<p style="margin-bottom:0;" align="left"><em><span lang="fr-FR"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;"><span style="color:#000000;"> In the MVC/Model 2 design pattern, application flow is mediated by a central Controller. The 	Controller delegates requests &#8211; in our case, HTTP requests &#8211; to an appropriate handler. The 	handlers are tied to a Model, and each handler acts as an adapter between the request and the 	Model. The Model represents, or encapsulates, an application&#8217;s business logic or state. Control 	is usually then forwarded back through the Controller to the appropriate View. The forwarding 	can be determined by consulting a set of mappings, usually loaded from a database or 	configuration file.</span></span></span></span></em><sup><em><span lang="fr-FR"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;"><span style="color:#000000;"><a class="sdfootnoteanc" name="sdfootnote2anc" href="#sdfootnote2sym"><sup>5</sup></a></span></span></span></span></em></sup></p>
<p style="margin-bottom:0;font-style:normal;" lang="fr-FR" align="left"><span style="color:#000000;"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">In fact with this pattern there are two communication cycles between the different components of the MVC triad that may arise:</span></span></span></p>
<ul>
<li>
<p style="margin-bottom:0;" align="left"><span style="font-style:normal;"><span lang="fr-FR"><span style="font-size:small;"><span style="color:#000000;">The 	<span style="font-family:Times New Roman,serif;">« User → Controller 	→ View → User » cycle in which the User interaction 	with the application is sent to the Controller as HTTP request. The 	Controller chooses the View to show to the User based on the request 	parameters.Finally it updates the View and returns it as a response 	to the User.</span></span></span></span></span></p>
</li>
<li>
<p style="margin-bottom:0;font-style:normal;" lang="fr-FR" align="left"><span style="color:#000000;"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">The 	« User → Controller → Model → View → User » 	cycle in which the User interaction with the application is sent to 	the Controller as HTTP request. The Controller access the Model and 	updates it. It chooses the View to show to the User based on the 	request parameters.Finally it updates the View to reflect the Model 	change and returns it as a response to the User.</span></span></span></p>
</li>
</ul>
<p style="margin-bottom:0;" lang="fr-FR" align="left"><span style="color:#000000;"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"><strong>Mixed client-side and server-side MVC</strong></span></span></span></p>
<p class="sdfootnote"><span><span lang="fr-FR"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;"><span style="color:#000000;">The client processing power is used to carry on user data validation or view change that do not require accessing the server side Controller and/or Model.</span></span></span></span></span><sup><span><span lang="fr-FR"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;"><span style="color:#000000;"><a class="sdfootnoteanc" name="sdfootnote1anc" href="#sdfootnote1sym"><sup>6</sup></a></span></span></span></span></span></sup><a class="sdfootnotesym" name="sdfootnote1sym" href="#sdfootnote1anc"><br />
</a></p>
<div id="sdfootnote1"><a href="http://kanian77.files.wordpress.com/2008/09/mvc_mixed.jpg"><img class="alignnone size-full wp-image-29" src="http://kanian77.files.wordpress.com/2008/09/mvc_mixed.jpg?w=291&#038;h=138" alt="" width="291" height="138" /></a></div>
<p style="margin-bottom:0;font-style:normal;" lang="fr-FR" align="left"><span style="color:#000000;"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">With this solution there are three communication cycles between the different components of the apllication:</span></span></span></p>
<ul>
<li>
<p style="margin-bottom:0;" align="left"><span style="font-style:normal;"><span lang="fr-FR"><span style="font-size:small;"><span style="color:#000000;"><span><span style="font-family:TimesNewRomanPS-ItalicMT,serif;">The 	« User </span><span style="font-family:TimesNewRomanPS-ItalicMT,cursive;">→ </span><span style="font-family:TimesNewRomanPS-ItalicMT,serif;">Controller 	(Client) </span><span style="font-family:TimesNewRomanPS-ItalicMT,cursive;">→ </span><span style="font-family:TimesNewRomanPS-ItalicMT,serif;">View (Client) </span><span style="font-family:TimesNewRomanPS-ItalicMT,cursive;">→</span></span><span style="font-family:TimesNewRomanPS-ItalicMT,serif;">User » 	cycle:</span></span></span></span></span></p>
</li>
</ul>
<p style="margin-left:0.64cm;margin-bottom:0;font-style:normal;" lang="fr-FR" align="left"><span style="color:#000000;"><span style="font-family:TimesNewRomanPS-ItalicMT,serif;"><span style="font-size:small;">In this case the user action is intercepted by the client-side Controller which decides that only the client-side View( the UI) is affected by the User&#8217;s action. The client-side Controller will update the client-side View that will make the modifications visible to the User.</span></span></span></p>
<ul>
<li>
<p style="margin-bottom:0;font-style:normal;" lang="fr-FR" align="left"><span style="color:#000000;"><span style="font-family:TimesNewRomanPS-ItalicMT,serif;"><span style="font-size:small;">The 	« User → Controller (Client) → Controller(Server) 	→View (Server) → View (Client)→User » cycle:</span></span></span></p>
</li>
</ul>
<p style="margin-left:0.64cm;margin-bottom:0;font-style:normal;" lang="fr-FR" align="left"><span style="color:#000000;"><span style="font-family:TimesNewRomanPS-ItalicMT,serif;"><span style="font-size:small;">Here the User action is intercepted by the client-side Controller which decides to send them as HTTP request to the server-side Controller. The server-side Controller will update the server-side View and send it to the client-side View. For example, this communication cycle can be used when a User wants to change  the application presentation (layout). </span></span></span></p>
<ul>
<li>
<p style="margin-bottom:0;font-style:normal;" lang="fr-FR" align="left"><span style="color:#000000;"><span style="font-family:TimesNewRomanPS-ItalicMT,serif;"><span style="font-size:small;">The 	« User → Controller (Client) → Controller(Server) → 	Model → View (Server) → View(Client) → User » 	cycle:</span></span></span></p>
</li>
</ul>
<p style="margin-left:0.64cm;margin-bottom:0;" align="left"><span style="font-style:normal;"><span lang="fr-FR"><span style="font-size:small;"><span style="font-family:TimesNewRomanPS-ItalicMT,serif;"><span style="color:#000000;">Is similar to the precedent. The difference here is that the server-side controller decides that the Model should be updated and updates the server-side View that will be sent to the client-side View and finally displayed to the User.</span></span></span></span></span><sup><span style="font-style:normal;"><span lang="fr-FR"><span style="font-size:small;"><span style="font-family:TimesNewRomanPS-ItalicMT,serif;"><span style="color:#000000;"><a class="sdfootnoteanc" name="sdfootnote1anc" href="#sdfootnote1sym"><sup>7</sup></a></span></span></span></span></span></sup></p>
<p style="margin-bottom:0;" align="left"><strong><span lang="fr-FR"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;"><span style="color:#000000;">Mixed client-side and server-side MVC (2)</span></span></span></span></strong><sup><strong><span lang="fr-FR"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;"><span style="color:#000000;"><a class="sdfootnoteanc" name="sdfootnote1anc" href="#sdfootnote1sym"><sup>8</sup></a></span></span></span></span></strong></sup></p>
<div id="sdfootnote1">
<p class="sdfootnote"><a class="sdfootnotesym" name="sdfootnote1sym" href="#sdfootnote1anc"><br />
</a></p>
</div>
<div id="sdfootnote1">
<p style="margin-bottom:0;"><a href="http://kanian77.files.wordpress.com/2008/09/mvc_mixed2.jpg"><img class="alignnone size-full wp-image-30" src="http://kanian77.files.wordpress.com/2008/09/mvc_mixed2.jpg?w=423&#038;h=112" alt="" width="423" height="112" /></a></p>
<p style="margin-bottom:0;" lang="fr-FR" align="left"><span style="color:#000000;"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">With this approach the client-side Model contains a copy of the data the user wants to access. It is the client-side Model responsability to communicate with the server-side Controller when the server-side Model needs to be updated or accessed.</span></span></span></p>
<p class="sdfootnote"><strong><span lang="fr-FR"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;"><span style="color:#000000;">Mixed client-side and server-side MVC (3)</span></span></span></span></strong></p>
<p class="sdfootnote"><a href="http://kanian77.files.wordpress.com/2008/09/mvc_mixed3.jpg"><img class="alignnone size-full wp-image-31" src="http://kanian77.files.wordpress.com/2008/09/mvc_mixed3.jpg?w=329&#038;h=166" alt="" width="329" height="166" /></a></p>
<p class="sdfootnote">One can imagine and develop web applications where only part the M of the MVC lives on the server. Morales-Chaparo et al call this approach RIA MVC. This allows for part of the less critical operations involving the model to happen at the client. A request is sent to server only when the client-side Model needs access to the server-side Model.</p>
<p class="sdfootnote">&#8212;&#8212;-</p>
<p class="sdfootnote">Note:</p>
<p class="sdfootnote">I believe that more and more web applications developpers will chose this &#8220;almost all client-side web MVC pattern&#8221;. Already, some javascript frameworks are openly claiming adhering to the MVC pattern (<a href="http://www.javascriptMVC.com" target="_blank">javascriptMVC</a>).</p>
<p class="sdfootnote">&#8212;&#8212;-</p>
<p class="sdfootnote" style="margin-left:0;text-indent:0;" lang="fr-FR"><span style="color:#000000;"><span style="font-size:x-small;"><br />
</span></span></p>
</div>
<p class="sdfootnote">
<div id="sdfootnote1">
<p style="margin-bottom:0;" align="left"><em><a class="sdfootnotesym" name="sdfootnote1sym" href="#sdfootnote1anc">1</a><span><span lang="fr-FR"><span style="color:#000000;"><span style="font-size:small;"> </span><span style="font-size:x-small;">ARCHITECTURAL DESIGN OF 	MODERN WEB APPLICATIONS</span><span style="font-size:small;">, </span><span style="font-size:x-small;"><span style="font-family:Times New Roman,serif;">Lech 	MADEYSKI, Michał STOCHMIAŁEK, Wroclaw University of Technology, 	Poland.</span></span></span></span></span></em></p>
<p><a class="sdfootnotesym" name="sdfootnote1sym" href="#sdfootnote1anc"><br />
</a><a class="sdfootnotesym" name="sdfootnote1sym" href="#sdfootnote1anc"> 2</a><span style="color:#000080;"><span style="text-decoration:underline;"><a href="http://osteele.com/archives/2004/08/web-mvc"> Web MVC, http://osteele.com/archives/2004/08/web-mvc</a></span></span> ,Oliver Steele, 2004</div>
<div id="sdfootnote1">
<p class="sdfootnote" style="margin-left:0;text-indent:0;" lang="fr-FR"><a class="sdfootnotesym" name="sdfootnote1sym" href="#sdfootnote1anc">3</a><span lang="fr-FR"><span style="font-size:x-small;"><span style="color:#000000;"> Understanding JavaServer Pages Model 2 architecture, Exploring the 	MVC design pattern, Govind Seshadri,</span></span></span><span style="color:#000000;"><span style="font-size:x-small;"> JavaWorld.com, 12/29/99</span></span></p>
<div id="sdfootnote1">
<p class="sdfootnote"><a class="sdfootnotesym" name="sdfootnote1sym" href="#sdfootnote1anc">4</a> Apache 	Struts, <span style="color:#000080;"><span style="text-decoration:underline;"><a href="http://struts.apache.org/">http://struts.apache.org/</a></span></span>, 	 is a  framework for creating enterprise-ready Java web applications</p>
</div>
<div id="sdfootnote2">
<p class="sdfootnote"><a class="sdfootnotesym" name="sdfootnote2sym" href="#sdfootnote2anc">5 </a>http://struts.apache.org/primer.html#mvc</p>
</div>
<div id="sdfootnote2"><a class="sdfootnotesym" name="sdfootnote1sym" href="#sdfootnote1anc">6</a><span lang="fr-FR"><span style="font-size:x-small;"><span style="color:#000000;">MVC Web design patterns and Rich Internet Applications, Morales-Chaparro, R.; Linaje, M.; Preciado, J. C.; Sánchez-Figueroa F.</span></span></span><span style="color:#000000;"><span style="font-size:x-small;"> QUERCUS Software Engineering Group, Escuela Politécnica. Universidad de Extremadura</span></span></div>
<p style="margin-bottom:0;"><a class="sdfootnotesym" name="sdfootnote1sym" href="#sdfootnote1anc">7</a><span style="font-size:x-small;"> ibid</span></p>
<p><a class="sdfootnotesym" name="sdfootnote1sym" href="#sdfootnote1anc">8 </a>ibid</div>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/kanian77.wordpress.com/25/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/kanian77.wordpress.com/25/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kanian77.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kanian77.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kanian77.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kanian77.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kanian77.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kanian77.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kanian77.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kanian77.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kanian77.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kanian77.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kanian77.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kanian77.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kanian77.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kanian77.wordpress.com/25/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kanian77.wordpress.com&amp;blog=2054282&amp;post=25&amp;subd=kanian77&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kanian77.wordpress.com/2008/09/04/vi-mvc-and-the-web/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e1cea03b59b7d4d488bd796e423551e8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kanian77</media:title>
		</media:content>

		<media:content url="http://kanian77.files.wordpress.com/2008/09/mvc.jpg" medium="image" />

		<media:content url="http://kanian77.files.wordpress.com/2008/09/mvc_model21.jpg" medium="image" />

		<media:content url="http://kanian77.files.wordpress.com/2008/09/mvc_mixed.jpg" medium="image" />

		<media:content url="http://kanian77.files.wordpress.com/2008/09/mvc_mixed2.jpg" medium="image" />

		<media:content url="http://kanian77.files.wordpress.com/2008/09/mvc_mixed3.jpg" medium="image" />
	</item>
		<item>
		<title>The Benefits and Drawbacks of using The MVC Pattern</title>
		<link>http://kanian77.wordpress.com/2008/09/03/the-benefits-and-drawbacks-of-using-the-mvc-pattern/</link>
		<comments>http://kanian77.wordpress.com/2008/09/03/the-benefits-and-drawbacks-of-using-the-mvc-pattern/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 23:54:27 +0000</pubDate>
		<dc:creator>kanian77</dc:creator>
				<category><![CDATA[MVC and the web]]></category>

		<guid isPermaLink="false">http://kanian77.wordpress.com/?p=22</guid>
		<description><![CDATA[The Benefits of using The MVC Pattern<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kanian77.wordpress.com&amp;blog=2054282&amp;post=22&amp;subd=kanian77&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="margin-bottom:0;" align="left"><strong><span style="font-size:small;"><span style="font-family:TimesNewRoman,serif;">IV The Benefits of using The MVC Pattern</span></span></strong><sup><strong><span style="font-size:small;"><span style="font-family:TimesNewRoman,serif;"><a class="sdfootnoteanc" name="sdfootnote1anc" href="#sdfootnote1sym"><sup>1</sup></a></span></span></strong></sup></p>
<ul>
<li> Different views and controllers can be substituted to provide alternate user interfaces for the same model.</li>
<li> Multiple simultaneous views of the same model</li>
<li> The change propagation mechanism insures that all views simultaneously reflect the current state of the model.</li>
<li>Changes affecting just the user interface of the application  become easier to make.</li>
<li> With MVC it can be easier to test the core of the application, as encapsulated by the model.</li>
</ul>
<p style="margin-bottom:0;" align="left"><strong><span style="font-size:small;"><span style="font-family:TimesNewRoman,serif;">V The problems of MVC</span></span></strong><sup><strong><span style="font-style:normal;"><span style="font-size:small;"><span style="font-family:TimesNewRoman,serif;"><a class="sdfootnoteanc" name="sdfootnote2anc" href="#sdfootnote2sym"><sup>2</sup></a></span></span></span></strong></sup></p>
<ul>
<li>There&#8217;s increased complexity as an apllication may use other 	patterns at the same time as MVC.</li>
<li>The view and the controller are closely coupled wich makes 	modification to one affect the other.</li>
<li>Changes to the model interface will necessitate changes to 	the controller and the view.</li>
<li>When the model is active frequent changes to model can result 	in excessive updates of the corresponding views.</li>
</ul>
<div id="sdfootnote1">
<p class="sdfootnote"><a class="sdfootnotesym" name="sdfootnote1sym" href="#sdfootnote1anc">1 </a></p>
<p style="margin-bottom:0;" align="left"><span><span style="font-size:x-small;"><span style="font-family:TimesNewRoman,serif;">Model View Controller explication page of the phpWACT framework, http://www.phpwact.org/pattern/model_view_controller</span></span></span></p>
<p class="sdfootnote"><span style="font-size:x-small;"></span></p>
</div>
<div id="sdfootnote2">
<p style="margin-bottom:0;" align="left"><a class="sdfootnotesym" name="sdfootnote2sym" href="#sdfootnote2anc">2</a><span><span style="font-size:x-small;"><span style="font-family:TimesNewRoman,serif;">ibid</span></span></span></p>
</div>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/kanian77.wordpress.com/22/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/kanian77.wordpress.com/22/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kanian77.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kanian77.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kanian77.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kanian77.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kanian77.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kanian77.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kanian77.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kanian77.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kanian77.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kanian77.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kanian77.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kanian77.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kanian77.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kanian77.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kanian77.wordpress.com&amp;blog=2054282&amp;post=22&amp;subd=kanian77&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kanian77.wordpress.com/2008/09/03/the-benefits-and-drawbacks-of-using-the-mvc-pattern/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e1cea03b59b7d4d488bd796e423551e8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kanian77</media:title>
		</media:content>
	</item>
		<item>
		<title>How does MVC work?</title>
		<link>http://kanian77.wordpress.com/2008/09/03/iii-how-does-mvc-work/</link>
		<comments>http://kanian77.wordpress.com/2008/09/03/iii-how-does-mvc-work/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 23:42:52 +0000</pubDate>
		<dc:creator>kanian77</dc:creator>
				<category><![CDATA[MVC and the web]]></category>

		<guid isPermaLink="false">http://kanian77.wordpress.com/?p=20</guid>
		<description><![CDATA[When the user interacts with an application designed using the MVC principles, the Model, the View, and the Controller communicate together to give the user the ability to interact with the Model and perceive the expected results.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kanian77.wordpress.com&amp;blog=2054282&amp;post=20&amp;subd=kanian77&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="margin-bottom:0;font-style:normal;" align="left"><span style="font-family:TimesNewRoman,Italic,serif;"><span style="font-size:small;"><strong><br />
</strong></span></span></p>
<p style="margin-bottom:0;font-style:normal;" align="left"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">When the user interacts with an application designed using the MVC principles,  the Model, the View, and the Controller communicate together  to give the user the ability to interact with the Model and perceive the expected results.</span></span></p>
<p style="margin-bottom:0;font-style:normal;" align="left"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">There are many ways in which the Model, the View and the Controller can work together as explained by  Trygve Reenskaug in his paper.</span></span></p>
<p style="margin-bottom:0;font-style:normal;" align="left">
<p style="margin-bottom:0;font-style:normal;" align="left"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"><strong>III.1 The passive model </strong></span></span></p>
<p style="margin-bottom:0;font-style:normal;" align="left"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">Here the Model reacts only to the Controller&#8217;s requests and View&#8217;s requests (if any). That is the Model would modify or retrieve data it represents only on the initiative of the Controller or the View. So upon the user&#8217;s request the controller would transmit the command to the Model and notify the View of a change in the Model&#8217;s state. The View could then request the changes to the Model or the Controller could trasmit those changes to the View. The Model is thus passive.</span></span></p>
<p style="margin-bottom:0;font-style:normal;" align="left">
<p style="margin-bottom:0;font-style:normal;" align="left"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"><strong>III.2 The active model </strong></span></span></p>
<p style="margin-bottom:0;font-style:normal;" align="left"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">If  the data represented by the Model can change as a result of actions from objects other than its View or Controller, then there must be a way for the Model to notify its View of the change. A communication channel must exist between the Model and its View.  In such case, the Model must initiate communication with the View. The Model is said to be active.</span></span></p>
<p style="margin-bottom:0;font-style:normal;" align="left">
<p style="margin-bottom:0;font-style:normal;" align="left"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"><strong>III.3 The communication between the View and the Controller</strong></span></span></p>
<p style="margin-bottom:0;" align="left"><span style="font-style:normal;"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;">As explained in </span></span><span lang="en-ZA"><span style="font-size:small;"><span style="font-family:TimesNewRoman,serif;">Steve Burbeck 1992 paper on MVC and Smalltalk:</span></span></span></span></p>
<p style="margin-bottom:0;" align="left"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;"><em><span>Each view is associated with a unique controller and vice versa.  Instance variables in each 	maintain this tight coupling.  A view&#8217;s instance variable <strong>controller</strong> points at its controller, 	and a controller&#8217;s instance variable <strong>view</strong> points at its associated view.  And, because both 	must communicate with their model, each has an instance 	variable model which points to the 	model object.  So, although the model is limited to sending self changed:,  both 	the view and 	the controller can send messages directly to each other and to their model.</span></em></span></span></p>
<p style="margin-bottom:0;" align="left"><span style="font-size:small;"><span style="font-family:TimesNewRoman,serif;">In this excerpt <em>&#8216;self changed&#8217;</em> is the message that the active model sends to its views to tell them that its state has been modified.</span></span></p>
<p style="margin-bottom:0;" align="left">
<p style="margin-bottom:0;" align="left"><span style="font-family:TimesNewRoman,serif;"><span style="font-size:small;">&#8212;&#8212;&#8212;-</span></span></p>
<p style="margin-bottom:0;" align="left"><span style="font-family:TimesNewRoman,serif;"><span style="font-size:small;"><strong>Note:</strong></span></span></p>
<p style="margin-bottom:0;" align="left"><span style="font-family:TimesNewRoman,serif;"><span style="font-size:small;">The tight coupling of the view and the controller have pushed some implementers of the MVC pattern in the GUI world to combine the view and the controller into one element called the View, whereas the model is called the Document. Such a pattern is then called the Document View pattern</span></span><sup><a class="sdfootnoteanc" name="sdfootnote1anc" href="#sdfootnote1sym"><sup>1</sup></a></sup><span style="font-size:small;"><span style="font-family:TimesNewRoman,serif;"> </span></span></p>
<p style="margin-bottom:0;" align="left"><span style="font-family:TimesNewRoman,serif;"><span style="font-size:small;">&#8212;&#8212;&#8212;&#8211; </span></span></p>
<p style="margin-bottom:0;" align="left">
<div id="sdfootnote1">
<p style="margin-bottom:0;" align="left"><a class="sdfootnotesym" name="sdfootnote1sym" href="#sdfootnote1anc">1</a><span><span style="font-size:x-small;"><span style="font-family:TimesNewRoman,serif;"> Model View Controller explication page of the phpWACT framework, 	http://www.phpwact.org/pattern/model_view_controller</span></span></span></p>
</div>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/kanian77.wordpress.com/20/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/kanian77.wordpress.com/20/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kanian77.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kanian77.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kanian77.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kanian77.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kanian77.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kanian77.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kanian77.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kanian77.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kanian77.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kanian77.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kanian77.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kanian77.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kanian77.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kanian77.wordpress.com/20/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kanian77.wordpress.com&amp;blog=2054282&amp;post=20&amp;subd=kanian77&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kanian77.wordpress.com/2008/09/03/iii-how-does-mvc-work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e1cea03b59b7d4d488bd796e423551e8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kanian77</media:title>
		</media:content>
	</item>
		<item>
		<title>MVC and Object Orientation</title>
		<link>http://kanian77.wordpress.com/2008/09/03/16/</link>
		<comments>http://kanian77.wordpress.com/2008/09/03/16/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 23:34:38 +0000</pubDate>
		<dc:creator>kanian77</dc:creator>
				<category><![CDATA[MVC and the web]]></category>

		<guid isPermaLink="false">http://kanian77.wordpress.com/?p=16</guid>
		<description><![CDATA[From what we read so far we understand that MVC separates the presentation of data, the handling of data, and the intepretation of user actions into different layers.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kanian77.wordpress.com&amp;blog=2054282&amp;post=16&amp;subd=kanian77&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="margin-bottom:0;font-style:normal;" align="left"><span style="font-family:TimesNewRoman,Italic,serif;"><span style="font-size:small;"><strong>II. MVC and Object Orientation</strong></span></span></p>
<p style="margin-bottom:0;" align="left"><span style="font-style:normal;"><span style="font-size:small;"><span style="font-family:TimesNewRoman,serif;">From <a href="http://kanian77.wordpress.com/2008/09/03/very-brief-history-of-mvc/" target="_blank">what we read so far</a> we understand that MVC separates the presentation of data, the handling of data, and the intepretation of user actions into different layers. One of the stated benefits by </span></span><span style="font-size:small;"><span style="font-family:Times New Roman,serif;">Trygve Reenskaug is the fact that data could be presented from mutiple perspectives. This means that, since the presentation (View) and the description of the data (Model) are embodied into different loosely coupled  layers or components,  the same data can be presented to the user in many different ways. That is, the data is not tied to the way it is being shown to the user. Moreover, let&#8217;s read this excerpt from </span></span><span lang="en-ZA"><span style="font-size:small;"><span style="font-family:TimesNewRoman,serif;"><a href="http://www.google.co.za/url?sa=t&amp;source=web&amp;ct=res&amp;cd=1&amp;url=http%3A%2F%2Fst-www.cs.uiuc.edu%2Fusers%2Fsmarch%2Fst-docs%2Fmvc.html&amp;ei=mBq_SLDlLoWgQITkoSk&amp;usg=AFQjCNGp2Y00vYssncqCh0OFSx4pyeUdHQ&amp;sig2=ai6Qb9HkzESAM7mFLvsX7Q" target="_blank">Steve Burbeck&#8217;s text</a>:</span></span></span><span style="font-size:small;"><span style="font-family:Times New Roman,serif;"> </span></span></span></p>
<p style="margin-bottom:0;" align="left"><span><span style="font-size:small;"><span style="font-family:Times New Roman,serif;"><span style="font-style:normal;"> </span><em>The formal separation of these three tasks is an important notion that is particularly suited to 	Smalltalk-80 where the basic behavior can be embodied in abstract objects: View, Controller, 	Model and Object.  The MVC behavior is then inherited, added to, and modified as necessary to 	provide a flexible and powerful system.</em></span></span></span></p>
<p style="margin-bottom:0;font-style:normal;" align="left"><span style="font-family:TimesNewRoman,Italic,serif;"><span style="font-size:small;">We see how MVC is well suited to be implemented using object oriented techniques. As a matter of facts, Trygve Reenskaugh in his Models-Views-controllers note writes on models:</span></span></p>
<p style="margin-bottom:0;" align="left"><span style="font-size:small;"><span style="font-family:Times New Roman,serif;"><span style="font-style:normal;"> </span><em>The models are represented in the computer as a collection of data together with the methods</em></span></span></p>
<p style="margin-bottom:0;" align="left"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;"><em> necessary to process these data.</em></span></span></p>
<p style="margin-bottom:0;font-style:normal;" align="left"><span style="font-family:Times New Roman,serif;"><span style="font-size:small;">Now if this is not the description of an object, then what is it? Now if  models can be  understood as objects in MVC, why not think of Views and Controller as other classes of objects? The fact is that a lot of systems using the MVC pattern also use the object oriented pattern. How well do both patterns fit together and how to better use them together? These are the questions that the developper of such systems and frameworks have probably tried to answer. Let us just remember that both patterns have been applied  successfully in Smalltalk-80, with the object orientation supporting the MVC pattern. </span></span></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/kanian77.wordpress.com/16/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/kanian77.wordpress.com/16/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kanian77.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kanian77.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kanian77.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kanian77.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kanian77.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kanian77.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kanian77.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kanian77.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kanian77.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kanian77.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kanian77.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kanian77.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kanian77.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kanian77.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kanian77.wordpress.com&amp;blog=2054282&amp;post=16&amp;subd=kanian77&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kanian77.wordpress.com/2008/09/03/16/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e1cea03b59b7d4d488bd796e423551e8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kanian77</media:title>
		</media:content>
	</item>
		<item>
		<title>Very Brief History Of MVC</title>
		<link>http://kanian77.wordpress.com/2008/09/03/very-brief-history-of-mvc/</link>
		<comments>http://kanian77.wordpress.com/2008/09/03/very-brief-history-of-mvc/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 23:25:59 +0000</pubDate>
		<dc:creator>kanian77</dc:creator>
				<category><![CDATA[MVC and the web]]></category>
		<category><![CDATA[javascript and mvc]]></category>

		<guid isPermaLink="false">http://kanian77.wordpress.com/?p=13</guid>
		<description><![CDATA[In a paper published by Trygve Reenskaug in 2007, he explained when and why was the MVC pattern created.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kanian77.wordpress.com&amp;blog=2054282&amp;post=13&amp;subd=kanian77&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I. Very Brief History Of MVC</p>
<p>In a<a href="http://www.google.co.za/url?sa=t&amp;source=web&amp;ct=res&amp;cd=1&amp;url=http%3A%2F%2Ffolk.uio.no%2Ftrygver%2F2007%2FMVC_Originals.pdf&amp;ei=whm_SPjsHIPO0gWm6pBv&amp;usg=AFQjCNGUju-NmoG6JwYpEkFYtJtxagmj-g&amp;sig2=c1uh76IQ5N3EafMqbsSKrA" target="_blank"> paper</a> published by Trygve Reenskaug in 2007, he explained when and why was the MVC pattern created. Here is what he said:</p>
<p align="justify"><em>&#8220;I made the first implementation and wrote the original MVC reports while I</p>
<p>was a visiting scientist at Xerox Palo Alto Research Laboratory (PARC) in</p>
<p>1978/79. MVC was created as an obvious solution to the general problem of</p>
<p>giving users control over their information as seen from multiple perspectives.</p>
<p>MVC has created a surprising amount of interest.&#8221;</em></p>
<p>It is important to note that the pattern in it first days did not carry the name of MVC, but rather the lengthy name of THING-MODEL-VIEW-EDITOR as it was described in a note entitled « THING-MODEL-VIEW-EDITOR -.an <a href="http://www.google.co.za/url?sa=t&amp;source=web&amp;ct=res&amp;cd=1&amp;url=http%3A%2F%2Ffolk.uio.no%2Ftrygver%2F1979%2Fmvc-1%2F1979-05-MVC.pdf&amp;ei=uxy_SKbBOZ3wQezinC4&amp;usg=AFQjCNFi6C7IZs_aY8eVH_UV8L2_QEy8Yw&amp;sig2=ipqC8-V4V0GXoe9bi_Sv4A">Example from a planningsystem</a> » published in May 1979.</p>
<p>However, just a few month later, in December 1979, the terms Model,View, and Controller were adopted by Reenskaug in the MODELS &#8211; VIEWS – CONTROLLERS note. In this note Trygve Reenskaug discuss the meaning of the M, V and C of MVC. He describes the Model by these words:</p>
<p align="justify"><em>&#8220; Models represent knowledge. A model could be a single object (rather uninteresting), or it</p>
<p>could be some structure of objects. &#8221;</em></p>
<p>He explains that:</p>
<p align="justify"><em>&#8220;A view is a (visual) representation of its model. It would ordinarily highlight certain attributes</p>
<p>of the model and suppress others. It is thus acting as a presentation filter.&#8221;</em></p>
<p>Finally he states that:</p>
<p align="justify"><em>&#8220;A controller is the link between a user and the system. (&#8230;)</p>
<p>The controller receives such user output, translates it into the appropriate</p>
<p>messages and pass these messages on to one or more of the views.&#8221;</em></p>
<p>After Trygve Reenskaug left Xerox PARC, Jim Althoff and others implemented a version of MVC for the Smalltalk-80 class library, whose first public release happened in 1983. If fact in their « The Language and its Implementation », a book on Smalltalk-80, Aele Goldberg (who had discussed the renaming of THING-MODEL-VIEW-EDITOR to Model-View-Controller with Reenskaug ) and David Robson present MVC and its use in Smalltalk.</p>
<p>A <a href="http://www.google.co.za/url?sa=t&amp;source=web&amp;ct=res&amp;cd=1&amp;url=http%3A%2F%2Fst-www.cs.uiuc.edu%2Fusers%2Fsmarch%2Fst-docs%2Fmvc.html&amp;ei=mBq_SLDlLoWgQITkoSk&amp;usg=AFQjCNGp2Y00vYssncqCh0OFSx4pyeUdHQ&amp;sig2=ai6Qb9HkzESAM7mFLvsX7Q" target="_blank">description</a> of the MVC pattern as implemented in Smalltalk-80 v2.5 written by Steve Burbeck in 1992 (a 1987 version exists) presents it with these words:</p>
<p align="justify"><em>&#8220;In the MVC paradigm the user input, the modeling of the external world, and the visual feedback to the user are explicitly separated and handled by three types of object, each specialized for its task. The view manages the graphical and/or textual output to the portion of the bitmapped display that is allocated to its application. The controller interprets the mouse and keyboard inputs from the user, commanding the model and/or the view to change as appropriate. Finally, the model manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller).&#8221; </em></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/kanian77.wordpress.com/13/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/kanian77.wordpress.com/13/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kanian77.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kanian77.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kanian77.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kanian77.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kanian77.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kanian77.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kanian77.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kanian77.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kanian77.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kanian77.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kanian77.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kanian77.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kanian77.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kanian77.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kanian77.wordpress.com&amp;blog=2054282&amp;post=13&amp;subd=kanian77&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kanian77.wordpress.com/2008/09/03/very-brief-history-of-mvc/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e1cea03b59b7d4d488bd796e423551e8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kanian77</media:title>
		</media:content>
	</item>
	</channel>
</rss>
