<?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>Daymo framework</title>
	<atom:link href="http://daymoframework.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://daymoframework.wordpress.com</link>
	<description>Less coding, clear seperation of responsibilities</description>
	<lastBuildDate>Fri, 26 Aug 2011 13:39:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='daymoframework.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Daymo framework</title>
		<link>http://daymoframework.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://daymoframework.wordpress.com/osd.xml" title="Daymo framework" />
	<atom:link rel='hub' href='http://daymoframework.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Why Style rules over Frameworks and Methods</title>
		<link>http://daymoframework.wordpress.com/2010/08/21/why-style-rules-over-frameworks-and-methods/</link>
		<comments>http://daymoframework.wordpress.com/2010/08/21/why-style-rules-over-frameworks-and-methods/#comments</comments>
		<pubDate>Sat, 21 Aug 2010 17:18:24 +0000</pubDate>
		<dc:creator>Peter Kaptein</dc:creator>
				<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Frameworks]]></category>

		<guid isPermaLink="false">http://daymoframework.wordpress.com/?p=223</guid>
		<description><![CDATA[&#8220;Frameworks are the shit&#8221; Developer Frameworks like Cairngorn, Mate, PureMVC, Robotlegs all have a number of believers using those frameworks in their projects. The main motivations are: Consistency, a unified way of working and project setup, leading to a better project base and making the project easier to transfer to other teams Easier to do [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daymoframework.wordpress.com&amp;blog=13960036&amp;post=223&amp;subd=daymoframework&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone" src="http://www.stylestring.com/wp-content/uploads/2009/11/Style_FashionVictim-HaremPants.jpg" alt="" width="500" height="400" /></p>
<h2>&#8220;Frameworks are the shit&#8221;</h2>
<p>Developer Frameworks like Cairngorn, Mate, PureMVC, Robotlegs all have a number of believers using those frameworks in their projects. The main motivations are:</p>
<ol>
<li><strong>Consistency, a unified way of working and project setup</strong>, leading to a better project base and making the project easier to transfer to other teams</li>
<li><strong>Easier to do Project- and Code Transfer</strong>, as you use standards, the ones coming after you will be able to understand and pick up the project easier</li>
<li><strong>Reducing development time </strong>due to the basic problems and nitty-gritty type of stuf like loading and handling data already solved</li>
<li><strong>Increased robustness and scalability</strong>, due to the use of more advanced design patterns</li>
</ol>
<h2>The illusion of &#8220;standards&#8221;</h2>
<p><a href="http://daymoframework.files.wordpress.com/2010/08/picture-301.png"><img class="alignnone size-full wp-image-224" title="Picture 301" src="http://daymoframework.files.wordpress.com/2010/08/picture-301.png?w=594" alt=""   /></a></p>
<p>&#8220;Standards&#8221; like &#8220;Swiz&#8221; and the likes in coding have a life span of 3 to 5 years. Within that time period new &#8220;standards&#8221; arise and become the new shit. So where your project might have been according the &#8220;standard&#8221; of two years ago, that &#8220;standard&#8221; is now probably no longer supported in your organization and any newbee has basically to learn something that has become close to obsolete except for the die-hards.</p>
<p>As any framework introduced their own &#8220;standard&#8221; as they usually emerge from some company using some specific way of working, this &#8220;standard&#8221; is only a &#8220;standard&#8221; within it&#8217;s own closed universe.</p>
<h2>Where Frameworks work</h2>
<p>Frameworks work when they solve a very specific (set) of problems. Like: &#8220;showing stuff in 3D in Flash&#8221; which is for instance provided by Papervision3D and Away3D or &#8220;load a zipped file and unzip it in Flash&#8221; like</p>
<h2>Daymo</h2>
<p>Since Daymo started as a &#8220;Framework&#8221;, you will find that term back in the Blog name. As the project &#8211; in which Daymo is evolving &#8211; progressed, the concept of a framework of the likes of Swiz and Robotlogs has been dropped in an early stage. Also any other framework &#8220;helping&#8221; the project has been cut out, unless it delivered visible results like the Charting components in Flex. Many of the reasons are listed in this post.</p>
<h2>The illusion of better projects and better code</h2>
<p>Any Framework that &#8220;helps you&#8221; coding in a different way is adding an extra layer of complexity on your project. And frameworks of the likes of Swize and Robotlegs specific also break with the benefits of Strong Typing and the good that an environment like Flex Builder and FDT offer you: when you break something in your code, or when you want to follow objects back to their origin, you can.</p>
<p>With defintitions in <a href="http://wiki.github.com/robotlegs/robotlegs-framework/best-practices#injectionsyntax">Robotlegs</a> and <a href="http://swizframework.jira.com/wiki/display/SWIZ/Dependency+Injection">Swiz</a> for injection: [Inject( source="userService" )] and this [Inject( source="userModel.currentUser" )] the reference to an object and variable is made via a String value referring to some bean defined somewhere in your project.</p>
<p>With that, in one blow, you kill the benefits of Strong Typing, as you can no longer guarantee if the variable you inject is of the same type or not. You might as well go back to:</p>
<pre>var myVar : * ; <span style="color:#008000;">
// accepts just any type of value,
// like we did in AS2</span>
</pre>
<p>and back to:</p>
<pre>function myFunction(myValue: *)
{
    var something:* = myValue;<span style="color:#008000;"> // Whatever</span>

    <span style="color:#008000;">// Let's try</span>
    if (something == 1 || something =="one")
    {
        <span style="color:#008000;">// Some action</span>
    }
}
</pre>
<p>Also: Injection and Autowiring is already a known principle in the Flex framework, using the [Bindable] tag and assigning the [Bindable] variable to an item in MXML code.</p>
<pre><span style="color:#008000;">// ActionScript class: MyValueObject</span>
[Bindable]
public static var myVariable:String="";

<span style="color:#008000;">// Flex MXML class somewhere else in your project</span>
<span style="color:#008000;">// Binding is in this example done via the
// static variable myVariable
// which will automatically our Label
// when the value changes</span>
&lt;mx:Label text="{MyValueObject.<em>myVariable</em>}"&gt;
</pre>
<p>Anywhere else, where MXML binding does not work, you use events and when needed &#8211; between classes not on the display list for instance &#8211; you use Event Dispatchers in Static variables.</p>
<pre><span style="color:#008000;">// Global event dispatcher</span><span style="color:#008000;"> in class MyGlobalDispatcher</span>
public static var dispatcher:EventDispatcher =
        new EventDispatcher();

<span style="color:#008000;">// Add static functions to add and remove eventlisteners</span>
<span style="color:#008000;">// [...]</span>

<span style="color:#008000;">// Somewhere else in your project:</span>
MyGlobalDispatcher.<em>addEventListener</em>(
         MyEvent.EVENTTYPE, myCallbackClass);

<span style="color:#008000;">// And somewhere else in your project</span>
MyGlobalDispatcher.<em>dispatchEvent</em>(
         new MyEvent(MyEvent.EVENTTYPE));
</pre>
<p>In the end, the extra layer of yet another way of programming and organizing things in an already existing framework, makes a project worse, as you have learn and understand not only the OOP principles and Design Patterns used, the structure in which the code has been setup, the foundation framework you are already using when using Flex or Flash or Java or any other language, but also the new and introduced &#8220;language&#8221; that frameworks like Swiz, Robotlegs and the likes are adding.</p>
<p>And you can not do things half when you choose a framework like that. It is either everything or nothing. Not partially. Why else use it?</p>
<h2>The illusion of reduction of development time</h2>
<p>All above mentioned Frameworks have a learning curve. Depending on how heavy they lean on specific &#8220;Design Principles&#8221; and &#8220;Design Patterns&#8221; and how specific these principles and patterns are used and how insane, rigid and single-minded the person was creating that specific approach  this learning curve can be very steep.</p>
<p>Each person stepping on a specific Framework Bandwagon will have to learn the specific rules and limitations of that way of working. Regardless of how good a coder he or she is, this will take time.</p>
<p>Apart from learning the framework, he or she might also have to learn the specific way of building projects and classes that you use: adding more learning time.</p>
<p>In the end, the main question is: what do you try to solve?</p>
<h2>One trick ponies &#8211; One size does not fit all</h2>
<p>Frameworks in general emerge from solid re-factoring in one or a number of successive projects towards a more solid and unified process. A specific approach to solving a specific problem is reworked and reworked until it is solid and consistent. This is completely swell, but does not mean that that specific approach will fly for all problems you will encounter in new projects.</p>
<p>A Framework is always limited due to the way it came to existence. And thus a (sometimes very sophisticated) one trick pony.</p>
<h2>Pretzels and code bloating</h2>
<p><img class="alignnone" src="http://evfreebies.com/wp-content/uploads/2010/02/free-auntie-annes-pretzel-day.jpg" alt="" width="513" height="449" /></p>
<p>Preztels fold back on themselves. Instead of following a straight line, the string of dough is weaved. Where simpel OOP might allow you to use short cuts and straignt lines to your goal, like calling Static Functions, using Singletons and Multitons, dispatching Events over your applicaton or via centralized Event Dispatchers, Frameworks &#8211; in many cases &#8211; force you to do some folding and bending to make it work according to the very specific rules that that framework enforces on you.</p>
<p>Where an experienced coder might be able to make these pretzels look nice, a less experienced user of that framework might end up with something like this:</p>
<p><img class="alignnone" src="http://daymoframework.files.wordpress.com/2010/08/img_7795.jpg?w=320&#038;h=240" alt="" width="320" height="240" /></p>
<p>It looks kind of like a pretzel, but is not quite what was intended by the person who invented the original or optimized the design.</p>
<p>Code bloating is where something that you could have easily done with one or two classes suddenly requires four or more because &#8220;the framework requires you to use&#8221;:</p>
<ol>
<li>A Mediator for your Class</li>
<li>A Proxy to the Mediator</li>
<li>An Event (class) for your Proxy</li>
<li>An Event Handler for the Mediator responding to the Proxy</li>
<li>An Event Handler for your Class, responding to the Mediator</li>
<li>A Service for your Proxy, talking with a Web Service on the backend</li>
<li>An Event (class) for the Service</li>
<li>An Event Handler for the Proxy responding to the Service</li>
</ol>
<p>As this is a hypothetical example, it is not uncommon to find these kind of constructions to &#8220;abstract&#8221; your code and your classes and &#8220;increase scalability&#8221; of your application.</p>
<h2>&#8220;Blue is the new green&#8221;</h2>
<p><a href="http://daymoframework.files.wordpress.com/2010/08/picture-302.png"><img class="alignnone size-full wp-image-225" title="Picture 302" src="http://daymoframework.files.wordpress.com/2010/08/picture-302.png?w=594" alt=""   /></a></p>
<p>Every Framework is sensitive for the fashion of that year. Like shoulder pads came up in the 1980&#8242;s dissapeared in the 1990&#8242;s and had some kind of revival in 2008 / 2009, Frameworks suffer the same problem. &#8220;Swiz&#8221; is the new &#8220;PureMVS&#8221; is the new &#8220;Cairngorn&#8221;. And maybe &#8220;Cairngorn Light&#8221; will become the new &#8220;Swiz&#8221; five years from now, starting a whole new cycle all over.</p>
<p>In the end &#8211; when you take all the fashion driven (self)marketing bla bla away &#8211; you very likely end up with code cramped and twisted and twirled in a very specific way, only understandable for the very few people who also did something with Method &#8220;X&#8221; and Framework &#8220;Y&#8221; and very likely totally useless three years from now when Method &#8220;P&#8221; and Framework &#8220;Q&#8221; are the whole new shit.</p>
<h2>Methods change</h2>
<p>Methods change as you and your team and your organization learns and grows. While it makes sens to document your way of working, it might be counter-productive to stick to long to one specific method as they evolved from one specific chain of events.</p>
<h2>If code consistency, project scalability and application stability are your goals: make them your priority</h2>
<p>Frameworks and Methods and new fashions are not the holy answer to every prayer. They usually introduce some nice new insights that you might like and might like to use, but the rest is very likely only going to slow you down.</p>
<p>Instead:</p>
<ol>
<li>Define your main goals as a team.</li>
<li>Find solutions in the basic stuff your programming language offer you.</li>
<li>Build clean classes.</li>
<li>Document your approach.</li>
</ol>
<p>This will help much more than &#8220;using Framework XYZ&#8221;</p>
<h2>&#8220;Style&#8221; is <span style="text-decoration:underline;">how</span> you do it</h2>
<p>Style has nothing to do with &#8220;what is hot&#8221;. It takes the best elements from everything and combines that to a new whole. Instead of following new fashions and fads with blind belief, Style follows it&#8217;s own way.</p>
<h2>Simplify your coding, refactor and clean up your projects</h2>
<p>If you want to do the company you work for a service, follow some basic rules.</p>
<ol>
<li>If you can follow a straight line, do so.</li>
<li>If you can simplify your code, do so.</li>
<li>If you can avoid any 3rd party bullshit, do so.</li>
<li>If you can re-use some neat little tricks you built up in the past, do so.</li>
<li>If you think it will help to clean up your code and refactor your classes, do so.</li>
</ol>
<h2>Wanna do shortcuts? Build libraries, reduce your classes and refactor your code</h2>
<p>In any project you solve very specific problems. Here is how you increase speed:</p>
<ol>
<li>Isolate your smart solutions into specialized classes in special corners of your code project.</li>
<li>Strive for re-usability.</li>
<li>Make sure you can refind your solutions when you are in a new project.</li>
<li>Refactor your special code until there is nothing more to refactor.</li>
<li>Reduce your classes in your project by working Smart instead of by Copy And Paste.</li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/daymoframework.wordpress.com/223/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/daymoframework.wordpress.com/223/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/daymoframework.wordpress.com/223/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/daymoframework.wordpress.com/223/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/daymoframework.wordpress.com/223/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/daymoframework.wordpress.com/223/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/daymoframework.wordpress.com/223/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/daymoframework.wordpress.com/223/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/daymoframework.wordpress.com/223/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/daymoframework.wordpress.com/223/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/daymoframework.wordpress.com/223/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/daymoframework.wordpress.com/223/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/daymoframework.wordpress.com/223/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/daymoframework.wordpress.com/223/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daymoframework.wordpress.com&amp;blog=13960036&amp;post=223&amp;subd=daymoframework&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://daymoframework.wordpress.com/2010/08/21/why-style-rules-over-frameworks-and-methods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cffc2ff7b980a5f5f76c22bddba4f361?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">peter kaptein</media:title>
		</media:content>

		<media:content url="http://www.stylestring.com/wp-content/uploads/2009/11/Style_FashionVictim-HaremPants.jpg" medium="image" />

		<media:content url="http://daymoframework.files.wordpress.com/2010/08/picture-301.png" medium="image">
			<media:title type="html">Picture 301</media:title>
		</media:content>

		<media:content url="http://evfreebies.com/wp-content/uploads/2010/02/free-auntie-annes-pretzel-day.jpg" medium="image" />

		<media:content url="http://daymoframework.files.wordpress.com/2010/08/img_7795.jpg?w=300" medium="image" />

		<media:content url="http://daymoframework.files.wordpress.com/2010/08/picture-302.png" medium="image">
			<media:title type="html">Picture 302</media:title>
		</media:content>
	</item>
		<item>
		<title>A crash course in Timeboxing</title>
		<link>http://daymoframework.wordpress.com/2010/08/21/a-crash-course-in-time-boxing/</link>
		<comments>http://daymoframework.wordpress.com/2010/08/21/a-crash-course-in-time-boxing/#comments</comments>
		<pubDate>Sat, 21 Aug 2010 16:28:22 +0000</pubDate>
		<dc:creator>Peter Kaptein</dc:creator>
				<category><![CDATA[Project management]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[de-scoping]]></category>
		<category><![CDATA[descoping]]></category>
		<category><![CDATA[project management]]></category>
		<category><![CDATA[scoping]]></category>
		<category><![CDATA[Scrum]]></category>
		<category><![CDATA[Time boxing]]></category>
		<category><![CDATA[Timeboxing]]></category>

		<guid isPermaLink="false">http://daymoframework.wordpress.com/?p=196</guid>
		<description><![CDATA[Time Boxing takes a practical hands-on approach to things that needs done, based on team work, reduction of dependencies and using priorities as the main driver.
This article describes one practical approach to Time Boxing covering as much as possible all different aspects of running a project with Time Boxing<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daymoframework.wordpress.com&amp;blog=13960036&amp;post=196&amp;subd=daymoframework&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>By Peter Kaptein, August 21, 2010<br />
Images (C) Peter Kaptein</em><em><br />
[First draft]<br />
</em></p>
<p><em><a href="http://daymoframework.files.wordpress.com/2010/08/picture-294.png"><img class="alignnone size-full wp-image-214" title="Picture 294" src="http://daymoframework.files.wordpress.com/2010/08/picture-294.png?w=594" alt=""   /></a><br />
</em></p>
<h2>What?</h2>
<p>Timeboxing&#8230; (see <a href="http://en.wikipedia.org/wiki/Timeboxing">full Wikipedia entry</a> here)</p>
<blockquote><p>&#8230;is a <a title="Time management" href="http://en.wikipedia.org/wiki/Time_management">time management</a> technique common in <a title="Project planning" href="http://en.wikipedia.org/wiki/Project_planning">planning projects</a> (typically for <a title="Software development" href="http://en.wikipedia.org/wiki/Software_development">software development</a>), where the schedule is divided into a number of separate time periods (<strong>timeboxes</strong>,   normally two to six weeks long), with each part having its own   deliverables, deadline and budget. Timeboxing is a core aspect of <a title="Rapid application development" href="http://en.wikipedia.org/wiki/Rapid_application_development">rapid application development</a> (RAD) <a title="Software development process" href="http://en.wikipedia.org/wiki/Software_development_process">software development processes</a> such as <a title="Dynamic Systems Development Method" href="http://en.wikipedia.org/wiki/Dynamic_Systems_Development_Method">dynamic systems development method</a> (DSDM) and <a title="Agile software development" href="http://en.wikipedia.org/wiki/Agile_software_development">agile software development</a>.</p>
<p>Timeboxes are used as a form of <a title="Risk management" href="http://en.wikipedia.org/wiki/Risk_management">risk management</a>,   especially for tasks that may easily extend past their deadlines.</p></blockquote>
<p>The Wikipedia article also mentioned (August 21, 2010 &#8211; edited by me after writing the nuances down below):</p>
<blockquote><p>The   end date [deadline] is set in stone and may not be changed. If the team exceeds  the  date, the work is considered a failure and is cancelled or  rescheduled.  Some timebox methods allow the team to adjust the scope of  the task in  order to meet the deadline.</p></blockquote>
<p>Which is not covering the real issues.</p>
<h2>What Timeboxing covers</h2>
<ol>
<li>The <strong>Deadlines</strong> are usually linked to a <strong>delivery date</strong> or <strong>release date </strong>which is linked to <strong>product launches</strong> in the market and/or <strong>promises to the End Client</strong>. Not delivering on time can result to:
<ol>
<li>loss of credibility (to the market)</li>
<li>loss of clients (when the competition is high and you do not deliver, they move somewhere else)</li>
<li>probable loss of revenue (by not selling or compensating for late delivery).</li>
</ol>
</li>
<li>&#8220;<strong>Cancelling the work</strong>&#8221; is <strong>not an option</strong> when this &#8220;work&#8221; covers crucial Application Requirements.</li>
<li>If the team <strong>exceeds the deadline</strong>, the team <strong>failed</strong> in <strong>proper planning</strong> and / or <strong>effective execution</strong> of the plan. This can be the result of:
<ol>
<li><strong>The wrong people on the wrong job</strong> (lack of experience, lack of commitment / drive / motivation, lack of speed)</li>
<li><strong>Underestimation of the</strong> (complexity of the) <strong>requirements</strong></li>
</ol>
</li>
<li>If the team exceeds the deadline, the <strong>following actions might be taken</strong> after conferring with the Client:
<ol>
<li><strong>Dropping requirements</strong> of lower impact (the ones that will not be directly missed by the user)</li>
<li><strong>Working overtime</strong> to compensate for the time lost</li>
<li><strong>Moving the deadline</strong></li>
</ol>
</li>
</ol>
<p>Time Boxing takes a  practical hands-on approach to things that needs done, based on team  work, reduction of dependencies and using priorities as the main driver. There is no one &#8220;written in stone &#8211; always leading to success&#8221; way to do it and this article only shows the middle of the road to &#8220;Timebox&#8221; your project. Each team will find it&#8217;s own way and balance.</p>
<p>As planning, scoping and estimating the needed time per requirement is the work of a human and based on predictions based on past experiences, Timeboxing requires care in how it is executed.</p>
<p>Some more general articles and insights can be found here:</p>
<ol>
<li><a href="http://litemind.com/time-boxing/">15 Time Boxing strategies</a> to get things done &#8211; Litemind</li>
<li><a href="http://blogs.msdn.com/b/jmeier/archive/2007/10/21/how-to-use-time-boxing-for-getting-results.aspx">How to use Time Boxing</a> for getting results &#8211; J.D. Meier</li>
<li><a href="http://www.davecheong.com/2006/07/26/time-boxing-is-an-effective-getting-things-done-strategy/">Dave Cheong on Time Boxing</a></li>
</ol>
<h2>In practice</h2>
<p><a href="http://daymoframework.files.wordpress.com/2010/08/picture-300.png"><img class="alignnone size-full wp-image-221" title="Picture 300" src="http://daymoframework.files.wordpress.com/2010/08/picture-300.png?w=594" alt=""   /></a></p>
<p>With timeboxing a project, you divide that project up in smaller &#8220;logical units&#8221; where each &#8220;logical unit&#8221;:</p>
<ol>
<li> Contains a <strong>specific set of requirements</strong> which are <strong>related</strong> to:
<ol>
<li><strong>Each other</strong> due to mutual dependencies, or because they are based on the same  base-classes and grouping them will increase efficiency when developed  in the same session</li>
<li><strong>The goals set for the Development Cycle</strong> it will be developed in</li>
</ol>
</li>
<li>Has a <strong>specific amount of hours</strong> assigned to it</li>
<li>Gets <strong>assigned to a team of maximally two people<br />
</strong></li>
<li>Has a <strong>clear deadline</strong></li>
</ol>
<p>These logical units are:</p>
<ol>
<li><strong>Development Cycles</strong>, each representing a clear phase and goal to be made (&#8220;Phase 1: basic functionalities&#8221;, &#8220;Phase 2: implementation of interaction models&#8221;, &#8220;Phase 3: loading and parsing external data&#8221;)</li>
<li><strong>Requirement Clusters</strong>, each containing a specific set of interrelated requirements, selected and tuned to help fulfill the specific goals set for the Development Cycle these Requirement Clusters are part of.</li>
</ol>
<p>Looking at the time span, Time Boxes for:</p>
<ol>
<li><strong>Development Cycles</strong> should be <strong>contained in a maximum of 4 weeks</strong>.</li>
<li><strong>Requirement Clusters</strong> should <strong>not exceed the limit of 40 hours or 5 working days</strong>.</li>
</ol>
<h2>Scoping</h2>
<p>With any project you have:</p>
<ol>
<li><strong>Deadlines</strong> and <strong>time constraints</strong></li>
<li><strong>Requested</strong> and <strong>required</strong> functionalities</li>
<li><strong>Available</strong> and <strong>unavailable</strong> <strong>people</strong> and <strong>capabilities</strong></li>
<li><strong>Dependencies</strong> on <strong>other parts</strong> or <strong>people</strong> (you might have no direct control over)</li>
<li><strong>People</strong> being <strong>dependent on you</strong> for their part of the project</li>
</ol>
<p>When scoping a project, you need to know:</p>
<ol>
<li>The <strong>priorities</strong> of the requested and required functionalities (see <a href="http://en.wikipedia.org/wiki/MoSCoW_Method">MoSCoW</a>)</li>
<li>The <strong>amount of hours</strong> each functionality will likely take to build</li>
<li><strong>How the work done</strong> for one group of functionalities will <strong>influence</strong> the work required for <strong>another</strong> set of <strong>functionalities</strong></li>
<li><strong>What </strong><strong>amount of work</strong> needs to be done to <strong>prepare</strong> the project / the foundations of the project (code base, frameworks, libraries)</li>
<li>The <strong>deadlines</strong> of the project</li>
<li><strong>Dependencies</strong> regarding <strong>others</strong></li>
<li><strong>Dependencies</strong> of others regarding <strong>you</strong></li>
</ol>
<p>When scoping:</p>
<ol>
<li>Do the most <strong>essential</strong> and most <strong>difficult</strong> parts <strong>first</strong>.</li>
<li>Take as many <strong>quick wins</strong> / visible results <strong>next</strong></li>
<li><strong>Avoid</strong> the parts which are <strong>dependent</strong> on still <strong>unfinished</strong> work by <strong>others</strong></li>
<li><strong>Prepare</strong> the <strong>building</strong> <strong>blocks</strong> <strong>other</strong> people are <strong>dependent</strong> on later in the project</li>
<li>Work <strong>progressively</strong> <strong>towards</strong> the elements which are <strong>lower</strong> on the <strong>priority</strong> <strong>list</strong> in the following order:
<ol>
<li>Essential things (these are usually the things you do to build the code-base that will function as the starting point for the application)</li>
<li>Must have things</li>
<li>Should have</li>
<li>Would have</li>
<li>Nice to have (when there is time left)</li>
</ol>
</li>
</ol>
<h2>De-scoping</h2>
<p>De-scoping is the process where your start scrapping functionalities to either make the deadline or stay within budget.</p>
<p>De-scoping takes place:</p>
<ol>
<li><strong>Before the project starts</strong> &#8211; based on feedback sessions with the client</li>
<li><strong>During the project</strong> &#8211; based on experiences and unforeseen issues that slow down progress or turn out to be impossible in the given time.</li>
</ol>
<p>De-scoping is done killing &#8220;Nice to have&#8221; functionalities first and working up to &#8220;Should have&#8221; and &#8220;Would have&#8221;. Only in very exceptional cases the &#8220;Must haves&#8221; are addressed in de-scoping.</p>
<h2>Main differences with Scrum</h2>
<p><a href="http://en.wikipedia.org/wiki/Scrum_%28development%29">Scrum</a> offers a specific approach to Timeboxing, where funny names are added and used, management is usually done on micro-level and per requirement and all team members state in daily stand up meetings what they have finished the day before, what they are planning to do today and what problems are preventing him or her from achieving the goal.</p>
<p>The main differences with Scrum are these:</p>
<ol>
<li><strong>Time Boxes</strong> (in the shape of Development Cycles and Requirement Clusters) <strong>are leading units</strong>.</li>
<li><strong>Real time Communication to the Team Leader</strong> or Facilitator instead of at the end of beginning of each day.</li>
<li><strong>No real need for Daily Scrums or Stand up meetings</strong>. If and when problems occur, team members will ask for help. As communication could and should be done direct and real time, team members who need to know, are informed real time as well, either directly or via the Team Leader.</li>
<li><strong>Focus on Deadlines, Goals, Development Cycles and Requirement Clusters</strong>. As each member has a clear set of Requirements to fulfill, management and self management is on deadlines for each Requirement Cluster.</li>
</ol>
<h2>Working from generic to detailed specifications</h2>
<p><a href="http://daymoframework.files.wordpress.com/2010/08/picture-293.png"><img class="alignnone size-full wp-image-213" title="Picture 293" src="http://daymoframework.files.wordpress.com/2010/08/picture-293.png?w=594" alt=""   /></a></p>
<p>Each Development Cycle should deliver a Working Proof of Concept that could be shipped if required.</p>
<p>This means that you:</p>
<ol>
<li><strong>Aim at the broad and overall picture first</strong>: implementing all the main building blocks of the application ans strive to deliver a working result representing the core application as soon as possibile</li>
<li><strong>Aim for the low hanging fruit first</strong>: which are the specifications and requirements which show the most results with the least amount of effort</li>
</ol>
<p>Each next Development Cycle is either / or:</p>
<ol>
<li><strong>Adding more detail to your implementation each next Development Cycle</strong>: working from the requirements which are essential for functioning towards the requirements that make life easier and the application more flashy.</li>
<li><strong>Adding the requirements which you did not implement the previous Development Cycles</strong></li>
</ol>
<h2>Why?</h2>
<p>Timeboxing is intended to simplify planning, by reducing dependencies and taking blocks of related tasks as units of measurement instead of individual tasks, but also by stearing clearly on &#8220;getting things done&#8221; on the set deadlines.</p>
<p>It:</p>
<ol>
<li>Delivers <strong>clearly defined results </strong>at the end of each Development Cycle</li>
<li>Allows you to <strong>get rid of micro-management </strong>and to navigate the project to clear &#8220;macro level&#8221; goals.</li>
<li>Allows you to <strong>respond faster and more dynamically to changing parameters</strong> (people falling from the team, changing priorities)</li>
<li>Gives you a possibility to <strong>reach specific goals more effectively</strong> due to grouping and different way of planning than using a &#8220;requirement by requirement&#8221; approach.</li>
</ol>
<h2>How?</h2>
<p>There are several approaches coming together in defining and assigning your time boxes. Here is a practical breakdown of most elements.</p>
<ol>
<li><strong>Organize</strong> your <strong>requirements</strong>
<ol>
<li><strong>List</strong> them</li>
<li><strong>Group</strong> them</li>
<li><strong>Prioritize</strong> them into the following priorities &#8211; working from &#8220;quick wins&#8221; and &#8220;highly visible&#8221; functionalities to a more and more granular level. (Also additionally see <a href="http://en.wikipedia.org/wiki/MoSCoW_Method">MoSCoW</a> for &#8220;Must Have, Should Have, Could Have, Would Have&#8221; filtering)
<ol>
<li>What is needed <strong>RIGHT NOW</strong> (<strong>Must Have</strong>)
<ol>
<li>To be able to build the application</li>
<li>To test specific functionalities</li>
<li>Because others in the (other) project group are directly dependent of it</li>
<li>Because the end user explicitly called for it</li>
<li>Because the application is useless without it</li>
</ol>
</li>
<li>What is required <strong>LATER</strong> (but still before release:<strong> Must Have</strong>)
<ol>
<li>To refine specific functionalities</li>
<li>To cover specific exceptions</li>
</ol>
</li>
<li>What <strong>CAN BE DELAYED</strong> (until after release: <strong>Should Have</strong>)<strong> </strong>
<ol>
<li>Containing very specific functionalities the end user will not immediately miss</li>
</ol>
</li>
</ol>
</li>
<li><strong>Specify</strong> the amount of hours required per requirement</li>
</ol>
</li>
<li><strong>Create time boxes</strong>
<ol>
<li><strong>Select a group of requirements<br />
</strong></li>
<li><strong>Select the </strong><strong> requirements </strong>(at that moment unfinished) based on:
<ol>
<li>The <strong>highest ranking</strong> / priority in that group</li>
<li><strong>Dependencies </strong>- in many cases functionalities &#8220;chain up&#8221;, meaning that you can not start one without finishing the other<strong> </strong></li>
<li><strong>Related functionalities</strong> &#8211; sometimes functionalities &#8220;sprout from others&#8221; meaning that when you finish &#8220;A&#8221;, functionaliteis &#8220;B&#8221;, &#8220;C&#8221; and &#8220;D&#8221; are very easy to build next<strong><br />
</strong></li>
</ol>
</li>
<li><strong>Cluster</strong> those requirements into a new group (your Requirement Cluster Time Box)</li>
</ol>
<ol>
<li><strong>Keep it real</strong> and take at least 50% to 100% of the  estimated time a  person &#8220;thinks&#8221; he or she needs to perform the task  when all goes well (ideal programming time). Things go wrong.  Wrong  turns are taken. Something that could be done in 1 hour can  explode in a  task consuming an entire day. Building in buffers helps compensating  the moments this happens.</li>
<li><strong>Take your team and the experience levels into account</strong>. Some  team members are fast like lightning. Others need more time due to  several reasons including experience, working pace and thinking pace.  Slow workers are not necessarily unexperienced or stupid.</li>
</ol>
<ol>
<li><strong>Add up</strong> the total amount of hours required to finish that time box</li>
<li><strong>Work in total units of days and people</strong>, not hours. For example:
<ol>
<li>Time box &#8220;A&#8221; is 40 hours x 2 people.</li>
<li>Time box &#8220;B&#8221; is 2o hours x 1 person.</li>
</ol>
</li>
<li><strong>Keep it coherent/keep it sane</strong>. Do not add requirements to a Requirement Cluster Time Box that do not make any sense except for &#8220;filling it up&#8221; or &#8220;because you need to put it somewhere&#8221;.</li>
<li><strong>Put collaterals</strong> (stuff you can not put anywhere else) <strong>in a &#8220;collateral&#8221; Cluster / Time Box.</strong></li>
<li><strong>Split a time box</strong> when the total amount of hours per team member <strong>is more than 40 hours</strong></li>
<li><strong>Limit the maximum amount of people on one Time Box to 2</strong> unless there is a good reason to team up 3 or more</li>
</ol>
</li>
<li><strong>Make a plan</strong>
<ol>
<li><strong>Define your development cycles</strong>
<ol>
<li><strong>By stating the goal or goals to be made</strong> in that cycle (&#8220;Basic  functionlities defined&#8221;, &#8220;ready for integration test&#8221;, &#8220;ready for user  acceptence test, phase 1&#8243;)</li>
</ol>
</li>
</ol>
<ol>
<li><strong>Define your time lines</strong>:
<ol>
<li><strong>In cycles</strong>, numbering from &#8220;cycle 1&#8243;</li>
<li><strong>In time spans per cycle</strong>, counting either / or:
<ol>
<li>The number of days (for short cycles)</li>
<li>The number of weeks (for long cycles)</li>
</ol>
</li>
<li><strong>In boxes of weeks</strong>, including the cycle (&#8220;cycle 1&#8243;) and stating the week: (&#8220;week 1&#8243;). Examples:
<ol>
<li>&#8220;Cycle 1, week 2&#8243;- where week 2 is the second week of Cycle 1</li>
<li>&#8220;Cycle 2, week 1&#8243;- where week 1 is the first week of Cycle 2</li>
<li>&#8220;Cycle 5, week 2&#8243; &#8211; where week 2 is the second week of Cycle 5</li>
</ol>
</li>
</ol>
</li>
<li><strong>Organize</strong> your Time Boxes across time <strong>in order of dependency and urgency</strong>. (Most urgent first, least urgent last)
<ol>
<li>Where <strong>urgency</strong> is:
<ol>
<li>Required <strong>NOW</strong></li>
<li>Required <strong>LATER</strong></li>
<li><strong>CAN BE DELAYED</strong></li>
</ol>
</li>
<li>And <strong>organization</strong> (ordering) is <strong>based on</strong>:
<ol>
<li><strong>Clearly defined goals </strong>you have discussed with the client. (These goals are be draw down as Cycles)</li>
</ol>
</li>
</ol>
<ol>
<li>Where you use<strong> Time boxes </strong>as<strong> Units of Time</strong> with which you:
<ol>
<li><strong>&#8220;Paper prototype&#8221; </strong>the planning (use a wall, yellow notes and tape)</li>
<li><strong>Define the number of weeks or days</strong> required for each cycle, based on the number of poeple you have</li>
</ol>
</li>
</ol>
</li>
<li><strong>Do not be afraid to re-shuffle</strong> based on new insights</li>
</ol>
</li>
<li><strong>Assign Time Boxes</strong> to people, per round<strong><br />
</strong></p>
<ol>
<li><strong>Let your team choose their specific Requirement Cluster Time Boxes</strong> &#8211; based on their experience and preferences</li>
<li><strong>Only choose when your team does not</strong> &#8211; there are always the less popular functionalities, comparable with garbage cleaning.</li>
<li><strong>Reward</strong> the team member who did garbage cleaning the last time in the next round</li>
</ol>
</li>
<li><strong>Start working </strong><strong><br />
</strong></p>
<ol>
<li><strong>Isolate your team</strong>. Everything that is <strong>not</strong> happening within the group and anything <strong>not</strong> related to the project <strong>does not exist</strong></li>
<li><strong>Assign a team leader</strong>. The team leader keeps tabs on all individual time boxes and communicaties and reports to the outside world</li>
<li><strong>Define</strong> who will be Requirement Owners and Code Owners for what parts of the applications</li>
<li><strong>Be in direct contact with each other all the time</strong>. Either by being in the same room or by virtual meeting rooms where audio and video contact is possible all day</li>
<li><strong>Build the requirements</strong> you have chosen</li>
<li><strong>Use short development cycles</strong>. Build what you need to build, test if it breaks the application and check in your code. See also &#8220;Use short check in cycles&#8221;</li>
<li><strong>Respect the contract</strong> you committed to when you took a Time Box: &#8220;finish the requirements listed in the time-box stated&#8221;</li>
</ol>
</li>
<li><strong>Act</strong>
<ol>
<li><strong>Time-boxing is real time:</strong> <strong>Broadcast your status to the team leader</strong>. When you are done with one specific functionality, are to cross the deadline or have problems in any other way, notify the team leader.</li>
<li><strong>Ask for help</strong>. When you have trouble getting a requirement done, notify your team leader. Ask for help.</li>
<li><strong>Solve problems / become part of the solution</strong>. It is sometimes easier to imagine (non existent) problems and imagine (non existent) roadblocks than thinking in terms of solutions. If you tend to think in problems: get over it and start finding solutions.</li>
</ol>
</li>
<li><strong>Test</strong>
<ol>
<li><strong>Testing is an integral part of the development process</strong>. Make sure your parts work according to specifications before you start with the next.</li>
<li><strong>Double check before you check in your code</strong>. Nothing is more annoying for others when their code breaks due to a mistake on your side.</li>
</ol>
</li>
<li><strong>Use Version Control</strong>
<ol>
<li><strong>Don&#8217;t be a stranger.</strong> Update and check in your code more than once a day.</li>
<li><strong>Synchronize your code first</strong>. Before you start working on something, make sure you are up to date with everybody else&#8217;s commits. Nothing is more annoying for you when your work is based on outdated Project Code.</li>
<li><strong>Use short check-in cycles</strong>. Every change and any addition you create should be checked in when you think it is ready</li>
<li><strong>Do not break other peoples code</strong>. See &#8220;Test&#8221;.</li>
</ol>
</li>
<li><strong>Feed results back in the planning</strong>
<ol>
<li><strong>Do not change time estimated</strong>
<ol>
<li><strong>Unless you estimated too low</strong> (over-estimated items function as buffers and are only re-adjusted when they are absurd)</li>
</ol>
</li>
<li><strong>Shift time-boxes</strong> where needed</li>
</ol>
</li>
</ol>
<h2>The Time Box contract</h2>
<p>A time box is based on estimated time and within a system a tool to move quickly, respond faster to changes in planning, reduce independencies by grouping responsibilities and get a better insight on what is needed and what is going on.</p>
<p>Four things can happen in your project:</p>
<ol>
<li><strong>You need less time than estimated</strong>: good going. Take a short time-out or move to the next time box.</li>
<li><strong>You spent the exact hours</strong>: good going. Move to the next Time Box</li>
<li><strong>You need more time than estimated</strong>. No problem. Find out and/or define why. Inform your Team Leader and make a new estimate together.</li>
<li>You needed <strong>more time than estimated</strong>, but <strong>did not notify </strong>your Team Leader yet. Bad, bad, bad! Correct directly by notifying your Team Leader and make a new estimate</li>
</ol>
<p>These are the rules:</p>
<ol>
<li><strong>Work to meet deadlines. </strong>Meeting deadlines is your highest priority as an individual and as a team.</li>
<li>When you <strong>need more time</strong> than estimated, you have two options:
<ol>
<li>Work <strong>overtime</strong></li>
<li>Work with the <strong>Team Leader</strong> to see what the cause and impact is and if the deadline can be rescheduled</li>
</ol>
</li>
<li><strong>See if there are </strong><strong>short cuts</strong> to reach the same goal faster, with the same (or higher) quality. (Work smart, not hard)</li>
<li><strong>Do what is described in your Time Box</strong>, unless it makes no sense. There is a reason for the clustering of functionalities, but people can make mistakes.</li>
<li><strong>Feed back possible misplaced requirements</strong> in your Time Box to the Team Leader and find out where they should be placed.</li>
<li><strong>Communicate what you are doing</strong> and where you think there is room for improvement</li>
<li><strong>Work Smart, not Hard</strong>. Getting from A to B in the shortest amount of time is in most cases done by proper preparation and finding the shortest or most efficient route, not by running faster.</li>
<li><strong>Respect the roles assigned</strong> to yourself and others in your team</li>
<li><strong>Work together</strong>. Time Boxing is team work.</li>
</ol>
<h2>Working days</h2>
<p>Extreem Programming (XP) has a very simple and clear rule about working days: &#8220;keep them family friendly&#8221;. This means 8 hour working days on normal working hours. The reason for this are simple: long working hours are counter-productive on the long run. People get tired, frustrated and lose their sharpness.</p>
<p>It is a wise approach. See &#8220;Keep it real&#8221; in</p>
<h2>Senior and Junior roles within the team</h2>
<p><a href="http://daymoframework.files.wordpress.com/2010/08/picture-299.png"><img class="alignnone size-full wp-image-220" title="Picture 299" src="http://daymoframework.files.wordpress.com/2010/08/picture-299.png?w=594" alt=""   /></a></p>
<p><em>Roles and main communicaton lines</em></p>
<p>If your team becomes bigger than three, you need to start dividing roles. Each of the following roles are given to senior developers.</p>
<ol>
<li><strong>Team Leader or Team Facilitatior</strong>: Takes care of the team as a whole and is the watchdog of progress, requirements, goals and deadlines. The Team Leader makes sure the team can do what is required and finds help where needed. Making sure the team can do what is required includes the reduction of distractions (other projects, questions from other people, meetings). The Team Leader facilitates in decision making processes (do we change specific parts of the code base? Should we refactor now?) and has the last word in this.</li>
<li><strong>Requirement Owners</strong>: Are guarding the correct implementation of specific requirements within the Team. Usually these requirements are clusters of related functionalities.</li>
<li><strong>Code Owners</strong>: Are guarding specific &#8211; often crucial &#8211; parts of the written code.</li>
<li><strong>Architects</strong>: Design the application and (crucial) application parts. Structure the code.</li>
<li><strong>Assistant Programmers</strong>: Assist in coding, doing more basic work.</li>
</ol>
<h2>Dividing the roles</h2>
<p>In general one Senior Developer covers multiple roles. Here is the bottom line:</p>
<ol>
<li>There is only<strong> one Team Leader</strong>.</li>
<li>The <strong>role</strong> of Team Leader <strong>can move</strong> to another person during the project.</li>
<li>A Requirement Owner can <strong>also be</strong> a Code Owner and an Architect.</li>
<li><strong>The team</strong><strong> as a whole</strong> <strong>defines</strong> and <strong>divides</strong> the <strong>roles</strong>, based on best qualifications and mutual consensus.</li>
</ol>
<h2>Direct communication with the Client</h2>
<p><a href="http://daymoframework.files.wordpress.com/2010/08/picture-298.png"><img class="alignnone size-full wp-image-219" title="Picture 298" src="http://daymoframework.files.wordpress.com/2010/08/picture-298.png?w=594" alt=""   /></a></p>
<p>Unlike the classic Waterfall method and very much like RAD and Agile / Scrum, the Project Team has multiple sessions with the Client, where the status is communicated and pre-releases are shared. The main reasons are:</p>
<ol>
<li><strong>Increased commitment of the team to Client and the project</strong>. By knowing that there are real people at the other side of the table, expecting specific results, the stakes are more clear and usually the personal commitment per team member rises.</li>
<li><strong>Reduction of misunderstandings</strong>. As the client is the one who &#8220;owns&#8221; the product as a whole, unclarities and misinterpretations in both requirements, clustering of requirments and prioritizations of requirements are usually reduced.</li>
</ol>
<p>Important in this communication is:</p>
<ol>
<li><strong>Guarding the Scope</strong> of the Development Cycles and Requirement Clusters. Adding new functionalities automatically leads to added time required to finish a Time Box.</li>
<li><strong>Documentation and communication of made decisions</strong>. Each decision made in the communication with the client is a new contract. Documenting these decisions is also the teams protection from arguments later in the project.</li>
</ol>
<p><a href="http://daymoframework.files.wordpress.com/2010/08/picture-2971.png"><img class="alignnone size-full wp-image-218" title="Picture 297" src="http://daymoframework.files.wordpress.com/2010/08/picture-2971.png?w=594" alt=""   /></a></p>
<h2>What happens in every project</h2>
<p>People make mistakes. People get tired. People blame each other for things they might or might not have done. Things will go wrong. Code will break. Some members in the team will lack experience or the experience others assumed this person had.</p>
<h2>When structural negative behavior wrecks the process</h2>
<p>Time Boxing as described here is a democratic process, assuming that all involved are working towards solving the problem, building the requirements and meeting the deadline.</p>
<p>In practice things are not always that simple and personal motivations can interfere. Here are some possible causes that might hamper the process.</p>
<ol>
<li><strong>The bully principle</strong>: In this principle, the &#8220;bully&#8221; is constantly trying to prove that he or she: &#8220;is better than you / better than him&#8221; by &#8220;funny&#8221; remarks and critiques on others and the work of the &#8220;weaker links&#8221;. Bullies are a problem, as they bring down others and slow down the project.</li>
<li><strong>The heavy burden issue</strong>: In this situation, anything that is not available as a Copy &amp; Paste solution is perceived as a heavy burden by the person with this issue.</li>
<li><strong>The wrong person on the wrong job</strong>: In this case, the wrong person is doing the wrong type of tasks. Either due to: lack of experience, lack of motivation or drive, or is simply not fast enough to pull the job off in the given time.</li>
<li><strong>The consequential saboteur</strong>: Due to a lack of drive / motivation / commitment the actions this person performs are sabotaging the project. Some of these actions include:
<ol>
<li>Wasting other peoples time by distracting them from their work.</li>
<li>Wasting your own time by doing other things than what your should be doing.</li>
<li>Using other people in the project to solve your problem where you could have done that yourself.</li>
<li>Repeatedly consciously checking in your code without testing first.</li>
</ol>
</li>
</ol>
<p>In some cases, you need to release a person like this. In some cases you can correct the behavior.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/daymoframework.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/daymoframework.wordpress.com/196/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/daymoframework.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/daymoframework.wordpress.com/196/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/daymoframework.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/daymoframework.wordpress.com/196/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/daymoframework.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/daymoframework.wordpress.com/196/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/daymoframework.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/daymoframework.wordpress.com/196/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/daymoframework.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/daymoframework.wordpress.com/196/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/daymoframework.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/daymoframework.wordpress.com/196/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daymoframework.wordpress.com&amp;blog=13960036&amp;post=196&amp;subd=daymoframework&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://daymoframework.wordpress.com/2010/08/21/a-crash-course-in-time-boxing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cffc2ff7b980a5f5f76c22bddba4f361?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">peter kaptein</media:title>
		</media:content>

		<media:content url="http://daymoframework.files.wordpress.com/2010/08/picture-294.png" medium="image">
			<media:title type="html">Picture 294</media:title>
		</media:content>

		<media:content url="http://daymoframework.files.wordpress.com/2010/08/picture-300.png" medium="image">
			<media:title type="html">Picture 300</media:title>
		</media:content>

		<media:content url="http://daymoframework.files.wordpress.com/2010/08/picture-293.png" medium="image">
			<media:title type="html">Picture 293</media:title>
		</media:content>

		<media:content url="http://daymoframework.files.wordpress.com/2010/08/picture-299.png" medium="image">
			<media:title type="html">Picture 299</media:title>
		</media:content>

		<media:content url="http://daymoframework.files.wordpress.com/2010/08/picture-298.png" medium="image">
			<media:title type="html">Picture 298</media:title>
		</media:content>

		<media:content url="http://daymoframework.files.wordpress.com/2010/08/picture-2971.png" medium="image">
			<media:title type="html">Picture 297</media:title>
		</media:content>
	</item>
		<item>
		<title>Model, View, Controller, Services</title>
		<link>http://daymoframework.wordpress.com/2010/07/01/the-daymo-approach-to-model-view-controller/</link>
		<comments>http://daymoframework.wordpress.com/2010/07/01/the-daymo-approach-to-model-view-controller/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 15:56:58 +0000</pubDate>
		<dc:creator>Peter Kaptein</dc:creator>
				<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Application Model]]></category>
		<category><![CDATA[Model View Controller Services]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[MVCS]]></category>
		<category><![CDATA[MVVC]]></category>
		<category><![CDATA[Separation of Responsibility]]></category>
		<category><![CDATA[View Model]]></category>

		<guid isPermaLink="false">http://daymoframework.wordpress.com/?p=145</guid>
		<description><![CDATA[MVVMCS &#8211; Model, View, View Model, Controller, Services - the outcome of combining the aspects of different models of MVC: MVC, MVVM, MVCS About this article Below you will find an extract of best practices related to MVC in the Daymo approach drawn from different sources, Design Patterns and frameworks. The main goal is to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daymoframework.wordpress.com&amp;blog=13960036&amp;post=145&amp;subd=daymoframework&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://daymoframework.files.wordpress.com/2010/07/picture-214.png"><img title="Picture 214" src="http://daymoframework.files.wordpress.com/2010/07/picture-214.png?w=455&#038;h=471" alt="" width="455" height="471" /></a></p>
<p><em>MVVMCS &#8211; Model, View, View Model, Controller, Services </em>- the outcome of combining the aspects of different models of MVC: MVC, MVVM, MVCS</p>
<h2>About this article</h2>
<p>Below you will find an extract of best practices related to MVC in the Daymo approach drawn from different sources, Design Patterns and frameworks. The main goal is to find and offer you the best and most optimal way of coding both simple and complex projects.</p>
<p>You will find very basic examples and summaries on benefits and possible pitfalls.</p>
<h2>Some basic assumptions on coding</h2>
<p>But before we start, let&#8217;s focus briefly on the basic assumptions we took on Daymo and coding.</p>
<p>We assume that:</p>
<ol>
<li><strong>Every project is different</strong> and comes with different demands on structure and approaches to solve problems</li>
<li><strong>Change is inherent to building an application</strong>. Your code and your application is a growing and changing entity as your project and time progresses.</li>
<li><strong>Restructuring and refactoring will recurringly happen along the way</strong>. At several stages in your development, you will restructure the way your code is organized. Including the places where you execute specific procedures.</li>
</ol>
<p>The following five aspects are therefore key to Daymo:</p>
<ol>
<li><strong>Separation of Responsibilities </strong>- A way to define what belongs where, based on what it does.</li>
<li><strong>Promoting- and Demoting code</strong> &#8211; A way to refactor you code to get clearer project structures.</li>
<li><strong>Model Driven design </strong>- Using the data model to tell your views what to do and how to respond.</li>
<li><strong>Event Driven design</strong> &#8211; Using events to tell &#8220;something&#8221; that &#8220;something&#8221; has happened &#8220;somewhere else&#8221;.</li>
<li><strong>Parameter Driven design</strong> &#8211; Using parameters and Composition instead of creating Custom Classes to distinct and create Objects of the same type with different types of behavior.</li>
</ol>
<p>Apart from that:</p>
<ol>
<li><strong>Use Strong Typing for variables and return types of functions</strong> &#8211; It will help you greatly when building your application and re-factoring and restructuring your code</li>
</ol>
<h2>The core goal of Daymo</h2>
<p>The core goal of all below is to provide you with a structure that will:</p>
<ol>
<li><strong>Simplify</strong> your software design.</li>
<li><strong>Reduce dependencies </strong>in your code and application.</li>
<li><strong>Increase</strong> <strong>the stability</strong> of your application (make it unbreakable).</li>
<li>Make your code <strong>easier to refactor</strong>.</li>
<li><strong>Reduce Boilerplate code</strong> as you will only do what is necessary for the project and also find easier ways to re-use code</li>
<li><strong>Reduction of Classes, Code and Files</strong> as you create objects with specific behaviors via Parameters and Composition (Parameter Driven Design) and can address (self protected) objects directly instead of via layers of mediators and managers.</li>
</ol>
<p>It is understandable that Daymo might approach things different from what you have been using and doing before and also might break some approaches which are considered to be &#8220;best practices&#8221;. Frameworks, for instance, invite you to think, look and work in one specific direction, solving problems in a very specific way to that Framework. So it might also bring you:</p>
<ol>
<li>Stress and frustration from learning a new approach which might be alien to you.</li>
<li>Resistance from doing things you have been tought to be &#8220;wrong&#8221;.</li>
<li>New insights into stuff you took for granted before.</li>
</ol>
<p>.</p>
<h1>MVC, MVVM and MVCS</h1>
<p>There are many different opinions on how MVC should and could be implemented. Each of them add their own value and neither of them is the ultimate solution. To understand the basics of MVC I went back to the <a href="http://st-www.cs.illinois.edu/users/smarch/st-docs/mvc.html">original definition by Steve Burback here</a> and also to <a href="http://ootips.org/mvc-pattern.html">this one </a>quoting an unfindable paper by Dean Helman.</p>
<h2>MVC</h2>
<p><strong>The Model, View, Controller pattern</strong></p>
<p>The MVC pattern is the most common. It stands for &#8220;Model&#8221;, &#8220;View&#8221; and &#8220;Controller&#8221;. Below you will find each more closer defined.</p>
<p>According to the definition of Dean Helman, the MVC pattern originates from this flow:</p>
<blockquote><p>[User] Input &#8211;&gt; Processing &#8211;&gt; Output<br />
Controller &#8211;&gt; Model &#8211;&gt; View</p></blockquote>
<p>As you will read in the quotes and the next chapter, the Model is more than storing and providing data alone. The Model also contains all your application logic, including classes to process data and execute business logic. Quoting quotes from Dean Helmans Objective Toolkit Pro whitepaper:</p>
<blockquote><p>a model encapsulates more than just data and functions that operate on it. A model is meant to serve as a computational approximation or abstraction of some real world process or system. It captures not only the state of a process or system, but how the system works.</p></blockquote>
<h2>MVVM &#8211; adding the &#8220;View Model&#8221;</h2>
<p><strong>The Model, View, <span style="text-decoration:underline;">View Model</span> pattern</strong></p>
<p>When using the MVC pattern, you will find you have two types of &#8220;Models&#8221;:</p>
<ol>
<li>Dealing with View Specific data (the View Model)</li>
<li>Dealing with a lot of processes and things that eventually will produce data to be presented or rendered in your View (The Model)</li>
</ol>
<p>The MVVM pattern makes this Separation of Responsibilities easier. You will see in the &#8220;Combining best practices&#8221; below how we recommend you to apply the MVVM pattern with MVC in flex. <a href="http://blogs.msdn.com/b/johngossman/archive/2005/10/08/478683.aspx">MVVM</a> is credited to John Gossman.</p>
<h2>MVCS &#8211; adding Services</h2>
<p><strong>The Model, View, Controller, <span style="text-decoration:underline;">Services</span> pattern</strong></p>
<p>As an application is also loading and storing data from and to external data sources, the MVC-pattern has been extended with &#8220;Services&#8221;.</p>
<p>Services are called to to specifically that: accepting, loading and storing any type of data from any type of external source. <a href="http://joeberkovitz.com/blog/reviewtube/">MVCS</a> is apparently intorduced to the (Flex) community in 2006 by Joel Berkovitz</p>
<h2>Combining the best practices</h2>
<p><a href="http://daymoframework.files.wordpress.com/2010/07/picture-214.png"><img class="alignnone size-full wp-image-160" title="Picture 214" src="http://daymoframework.files.wordpress.com/2010/07/picture-214.png?w=594" alt=""   /></a></p>
<h2>Huh? 3-Tier!</h2>
<p>Looking at the structure that emerges here, by combining MVC, MVVM and MVCS, you will find many parallels with the <a href="http://en.wikipedia.org/wiki/Multitier_architecture#Three-tier_architecture">3-Tier approach</a> which consists of:</p>
<ol>
<li>The <strong>Presentation</strong> <strong>Layer</strong> / Tier &#8211; Represented here in the <strong>User Interface Domain</strong>.</li>
<li>The <strong>Business</strong> <strong>Layer</strong> / Tier &#8211; Represented here in the <strong>Application Logic Domain</strong>.</li>
<li>The <strong>Data</strong> <strong>Layer</strong> / Tier &#8211; Represented here in the <strong>Services Domain</strong>.</li>
</ol>
<p>(MVC &#8211; according to WikiPedia &#8211; is an older structure than the 3-Tier approach. Where 3-Tier emerged in the 1990&#8242;s, MVC originates from the late 1970&#8242;s.)</p>
<h2>Handling this setup according to Daymo</h2>
<p>With Daymo you make a distinction between User Interface specific and Application Logic specific domains.</p>
<p>The <strong>Application Logic Domain</strong> is Data- and Business Logic Centered and contains all the code required to run the Application. This includes generic View States and Application States but excludes View-specific code.</p>
<p>The <strong>User Interface Domain</strong> is View Centered and contains all the View-specific code. The Views will therefore instantiate the Controllers and the View Model Objects</p>
<p>A <strong>View Object</strong> instantiates the View Model Object and the Controller Object.</p>
<p>A <strong>View Model Object</strong> connects to the Application Model and Application Logic via an Object Request on an Object in the Application Model. This request is a Static Function on the Object itself.</p>
<p><strong>A Controller</strong> observes the View and deals with events happening in the View, to update the View Model Object.</p>
<p><strong>Services</strong> are invoked from the Application Model Domain.</p>
<p>We will go into the different aspects of this setup later in this document.</p>
<p>.</p>
<h1>The Model</h1>
<p>The most common description of the Model and it&#8217;s role is like this (from <a href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller">Wikipedia</a>):</p>
<blockquote><p>The <strong>model</strong> is used to manage information and notify observers when that information changes. The model is the domain-specific representation of the data upon which the application operates. Domain logic adds meaning to raw data (for example, calculating whether today is the user&#8217;s birthday, or the totals, taxes, and shipping charges for shopping cart items). When a model changes its state, it notifies its associated views so they can be refreshed.</p></blockquote>
<p>The problem is: how do you translate this to anything? Based on the description above we deal with data, information management and notifying observers when things changes in the model, but nothing clear about where to put &#8220;the smart stuff&#8221; and how to organize, categorize and name that stuff. Searching further, I came to this definition of the Model on <a href="http://ootips.org/mvc-pattern.html">OOtips</a> (accredited to Dean Helman):</p>
<blockquote><p>[The model is used] to manage information and notify observers when that information changes. [...] It contains only data and functionality that are related by a common purpose [...]. If you need to model two groups of unrelated data and functionality, you create two separate models.</p>
<p>[...] a model encapsulates more than just data and functions that operate on it. A model is meant to serve as a computational approximation or abstraction of some real world process or system. It captures not only the state of a process or system, but how the system works. This makes it very easy to use real-world modeling techniques in defining your models. For example, you could define a model that bridges your computational back-end with your GUI front-end. In this scenario, the model wraps and abstracts the functionality of a computation engine or hardware system and acts as a liaison requesting the real services of the system it models.</p></blockquote>
<p><strong>The Model in brief:</strong></p>
<ul>
<li>Represents a real world process or system</li>
<li>Captures the state of a process or system and how that system works</li>
<li>Manages information</li>
<li>Notifies observers when information changes</li>
<li>Contains data and functionality</li>
<li>The data and functionality are related by a common purpose</li>
<li>You can have multiple models &#8211; unrelated functionality and data are placed in a separate model</li>
</ul>
<p>Now each of these are pointers, giving you an idea where to look for what. The purpose of the next part is to make some practical sens out of this and put it into something you can code. To do that, let&#8217;s state some more definitions first.</p>
<h2>Model Objects</h2>
<p>As the Model is the sum of all parts, we choose to refer to the Model parts in general as Model Objects.</p>
<h2>Separation of responsibilities</h2>
<p>When you look at classes inside the model, the most common are the Value Object, the Object, the Manager and the Handler. Let&#8217;s put them in line.</p>
<ol>
<li><strong>The Value Object (VO)</strong> &#8211; The Value Object is completely stupid. Its only function is to contain data.</li>
<li><strong>The View Model Object (</strong><strong>VMO) </strong>- The View Model Object is directly related to the View.</li>
<li><strong>The Object</strong> &#8211; The Object is your generic all purpose thing and a bit smarter than the VO. It holds data like the Value Object and is able to perform specific simple actions.</li>
<li><strong>The Handler (HND)</strong> &#8211; The Handler is created to perform or &#8220;handle&#8221; specific but simple actions, like loading files, sending data to the server, and parsing data from one format to another.</li>
<li><strong>The Manager (MGR)</strong> &#8211; The Manager is created to deal with the more complex issues. It usually deals with multiple issues from multiple sources, managing them using specific rules.  Managers use and (can) contain the Business Logic and uses the Business Rules of your application.</li>
</ol>
<h2>Promoting and Demoting your code</h2>
<p>Let us assume that in most cases you start with an Object. This Object has some internal logic and performs specific actions. When that internal logic grows, you might want to start separating it into different logic blocks.</p>
<p>Code Promotion and Code Demotion is just another way to say:</p>
<ol>
<li>&#8220;This part of code does more things or smarter things than should happen in this specific Class&#8221;</li>
<li>&#8220;We should extract this specific part / these specific variables and place it in a separate class&#8221;.</li>
</ol>
<h2>- Promoting your code</h2>
<p>A promotion means that the code moves one or more steps up the ladder. So code inside your Object that is more than &#8211; let&#8217;s say &#8211; 10 lines, does smart stuff or handles specific things and shows ambitions to grow even more, will become a Handler or Manager.</p>
<h2>- Demoting your code</h2>
<p>When you are only storing values inside an Object and it turns out to have no intelligence at all, you demote the Object to become a Value Object.</p>
<h2>Handlers</h2>
<p>The <strong>Handler</strong> can be split up into separate parts, doing very specific things. In practice you will find:</p>
<ol>
<li><strong>The Parser</strong> &#8211; Parsing data from one data-format or data-structure to another.</li>
<li><strong>The IOhandler</strong>, which can be split into:
<ol>
<li><strong>The (Data) Loader </strong>- Loading data from a server or device</li>
<li><strong>The (Data) Submitter</strong> &#8211; Sending data to a server or device</li>
</ol>
</li>
<li><strong>The Verifyer</strong> &#8211; Veryfying data and variables based on Rules or Business Rules</li>
<li><strong>The Wrapper or Adapter</strong> &#8211; Adding extra functionalities and handles to an object, to make it complient to your specific needs</li>
<li><strong>The Controller</strong> &#8211; Doing very specific stuff based on user actions and user interactions</li>
<li><strong>The View State Engine</strong> &#8211; Doing very specific stuff with the View, based on internal and external settings and values.</li>
<li><strong>Utilities</strong> &#8211; Doing very generic but time-saving stuff which you can re-use in any project. Like: validating e-mail addresses, cleaning up objects, copying values from one object to another and so on.</li>
</ol>
<h2>Managers</h2>
<p>Managers can be split into different levels of management in your applicaton:</p>
<ol>
<li><strong>Managing Items</strong> &#8211; Dealing with the low level parts in your application, making sure everything is done right.</li>
<li><strong>Managing Views </strong>- Dealing with what is visible and hidden, kept persistent or treated as disposable items (thrown away once used)</li>
<li><strong>Managing Application Parts</strong> &#8211; Dealing with a very specific part of the application, like &#8220;The 2D drawing area&#8221; of an paint-application</li>
<li><strong>Managing the Application</strong> &#8211; Managing the overall flow of interactions</li>
</ol>
<h2>Static functions on Managers</h2>
<p>Managers are there for other parts of the application to be used. To avoid Object Instantiation Dependency, Daymo promotes to use Static Functions on Managers so that you can directly ask a Manager to perform a specific task without having to care where or by whom it is instantiated</p>
<h2>Application Models and View Models</h2>
<p>As stated before, a Model is the sum of all parts. In the case of coding, these parts are Objects. Looking at an application you will find Objects dealing with Application Logic and Objects (in your Model) dealing with Views.</p>
<p>Based on the best practices of MVVM (Model, View, View Model) we recommend to create View Models to deal with the data in your View and communicate to other Objects in whatever Model there is: to store and request data.</p>
<p>Once you start doing that, the Objects in your Model start to form (at least) two camps:</p>
<ol>
<li><strong>View Model Objects</strong> &#8211; Dealing with your View and requesting data from and sending data to other Objects in your Model</li>
<li><strong>Other Objects</strong> &#8211; Dealing with other stuff like: the logic of your application, handling things, managing objects and application parts, etcetera.</li>
</ol>
<p>This is where the Application Model and the View Model concept starts.</p>
<h2>The Application Model</h2>
<p>The Application Model contains all the logic and Objects that run and manage your application. This includes:</p>
<ol>
<li><strong>Managers</strong> &#8211; Doing smart things and executing Business Rules</li>
<li><strong>Handlers</strong> &#8211; Handling specific processes</li>
<li><strong>Generic Objects </strong>- Doing and handling very simple things and storing information about the objects they represent</li>
<li><strong>Value Objects</strong> &#8211; Containing only data</li>
<li><strong>Business Logic</strong> &#8211; Dealing with the more complex decisions related to the application</li>
<li><strong>Business Rules</strong> &#8211; Offering a simple way to find out whether something complies to specific rules</li>
<li><strong>Services</strong> &#8211; Getting data from- and submitting data to- some external source.</li>
<li><strong>Application States </strong>- Telling you what is where and telling your Views to respond</li>
</ol>
<p>This excludes:</p>
<ol>
<li><strong>Controllers</strong></li>
<li><strong>View-specific Models</strong> or <strong>View-specific Value Objects</strong></li>
<li><strong>View-specific View States</strong></li>
</ol>
<h2>The View Model</h2>
<p>The View Model contains all the Classes that deal with and store View-specific data.</p>
<p>This includes:</p>
<ol>
<li><strong>View Managers</strong> &#8211; Managing Views and View states according to business rules</li>
<li><strong>View Handlers</strong> &#8211; Handling specific things for specific views</li>
<li><strong>View Value Objects</strong> &#8211; Containing View specific data</li>
<li><strong>View-specific View States</strong> &#8211; Telling the View what to show and hide</li>
</ol>
<p>This excludes:</p>
<ol>
<li><strong>View Objects</strong> &#8211; Being represented in either State Machines or Controllers</li>
<li><strong>The Controller </strong>- Dealing with user input and user interaction</li>
</ol>
<h2>Object Requests &#8211; Connecting from a View Model to the Application Model</h2>
<p><a href="http://daymoframework.files.wordpress.com/2010/07/picture-210.png"><img class="alignnone size-full wp-image-152" title="Picture 210" src="http://daymoframework.files.wordpress.com/2010/07/picture-210.png?w=594" alt=""   /></a></p>
<p>And more neutral:</p>
<p><a href="http://daymoframework.files.wordpress.com/2010/07/picture-212.png"><img class="alignnone size-full wp-image-157" title="Picture 212" src="http://daymoframework.files.wordpress.com/2010/07/picture-212.png?w=594" alt=""   /></a></p>
<p>There is no strong binding between objects in the Application Model and the View Model. They are two separate worlds without any direct knowledge to each other, except for the knowledge (by the View Model Object) of the existence of specific Classes with specific handles (comparable to an API) in the Application Model.</p>
<p>Basic rules of thumb:</p>
<ol>
<li>The View Model connects to the Application Model via an Object Request.</li>
<li>The Application Model never connects to the View Model.</li>
<li>The Object Request is done via a Static Function in the Object in the Application Model.</li>
</ol>
<p>To connect to any Data Source or Service in the Application Model in most cases a Static Function is used directly on the Class.</p>
<pre><span style="color:#008000;">// We need an instantion of an object in the Application Model</span>
var myInstance:AppModelObject=<span style="color:#0000ff;">AppModelObject</span>.<em><span style="color:#0000ff;">getObject</span></em>();</pre>
<p>getObject can be either a provider of:</p>
<ol>
<li><strong>A Singleton Instance</strong> &#8211; Being the same object anywhere.</li>
<li><strong>A Multiton Instance</strong> &#8211; Being a specific object based on an input variable.</li>
<li><strong>A new Object</strong> &#8211; Created on request.</li>
<li><strong>A Recycled object</strong> &#8211; coming from the recycle bin of that object.</li>
</ol>
<p>We never assume anything about the returned Object from the perspective of the View Model. We fully trust that the provider knows what it is doing when providing either a Singleton, Multiton, new Object or Recycled object.</p>
<p>You might choose to be more specific in calling the Object Provider. The call will then look something like this:</p>
<pre><span style="color:#008000;">// We need an instantion of an object in the Application Model</span>
var myInstance:AppModelObject=<span style="color:#0000ff;">AppModelObject</span>.<span style="color:#ff0000;"><em>getAppModelObject</em></span>();</pre>
<h2>The markup of the Object Provider</h2>
<p>The Object Provider is something you create yourself, in your own Classes. Below you find four examples of an Object Provider.</p>
<p>The principle in Daymo is to cal the Object Provider function call &#8220;getObject&#8221;. <em>getObject</em> is a Static Function and looks like this:</p>
<pre><span style="color:#008000;">// For a singleton</span>
public <span style="color:#0000ff;">static</span> function <span style="color:#0000ff;">getObject</span>(): MyObject
{
   if(_instance==null)
   {
      _instance=new <span style="color:#ff0000;">MyObject</span>();
   }
   return _instance;
}

<span style="color:#008000;">// For a multiton</span>
public <span style="color:#0000ff;">static</span> function <span style="color:#0000ff;">getObject</span>( <span style="color:#0000ff;">objectKey</span>:&lt;some type&gt; ):MyObject
{
    var <span style="color:#ff0000;">myObject</span>:MyObject=_<span style="color:#000000;">myDictionary</span>[<span style="color:#0000ff;">objectKey</span>];
    if(<span style="color:#ff0000;">myObject</span>==null)
    {
       <span style="color:#ff0000;">myObject</span>=new <span style="color:#ff0000;">MyObject</span>();
       _myDictionary[<span style="color:#0000ff;">objectKey</span>]=<span style="color:#ff0000;">myObject</span>;
    }
    return <span style="color:#ff0000;">myObject</span>;
}

<span style="color:#008000;">// For an Object</span>
public <span style="color:#0000ff;">static</span> function <span style="color:#0000ff;">getObject</span>():MyObject
{
    return <span style="color:#0000ff;">new</span> <span style="color:#ff0000;">MyObject</span>();
}

<span style="color:#008000;">// For a Recycled Object</span>
pubic <span style="color:#0000ff;">static</span> function <span style="color:#0000ff;">getObject</span>():MyObject
{
    var <span style="color:#ff0000;">myObject</span>:<span style="color:#ff0000;">MyObject</span>;

    <span style="color:#008000;">// Get from recyclebin</span>
    if(_recycleBin.length&gt;0)
    {
       <span style="color:#ff0000;">myObject</span> = _<span style="color:#0000ff;">recycleBin</span>.<span style="color:#0000ff;">pop</span>();
    }
   <span style="color:#008000;"> // Or create new one</span>
    else
    {
       <span style="color:#ff0000;">myObject</span>=new <span style="color:#ff0000;">MyObject</span>();
    }
}</pre>
<p><strong>Benefits:</strong></p>
<ol>
<li><strong>Direct but Protected Access to onbjects in the Application Model</strong> &#8211; Each Object in the Application Model implementing this approach is directly accessible, in a protected manner, so that you can not break the application by accedentily instantiating an object the wrong way.</li>
<li><strong>Internal Object management</strong> &#8211; The Provider of the Object Instances is also the manager of the rules related to the type of instantiation (singelton, multiton, recycled, new).</li>
<li><strong>Simplified Object management / No Object Management Dependencies</strong> &#8211; There is no need to manage the Object Instantiation on other places in your application (other than in the Object Provider itself).</li>
<li><strong>Agnostic code</strong> &#8211; Your code only needs to know how to get the object. How it is managed is dealt with somewhere else.</li>
</ol>
<p><strong>Critiques:</strong></p>
<ol>
<li><strong>Diverts from Flex Approach</strong> &#8211; This approach to get objects from the Application Model diverts from the Flex Approach and is structurally different from other frameworks.</li>
</ol>
<p>.</p>
<h1>The View</h1>
<p>The View contains all visible elements, like Buttons, Lists and Text fields.</p>
<p>In Daymo the View is stupid. It contains no code, except for the bare basics you need to instantiate the Controller and the View Model Object.</p>
<h2>Building the View</h2>
<p><strong>Phase 1: building what you need</strong> &#8211; In Flex you will normally start building your View code inside the MXML of your View. There is nothing wrong with that. Your code might look like this:</p>
<pre style="padding-left:30px;">&lt;mc:Canvas&gt;
   &lt;mx:formatter id="myFormatter" /&gt;
   &lt;mx:Button click="onClick(event)" label="my Button" formatter="myFormatter"/&gt;
   &lt;mx:DataGrid dataProvider="{myProvider}" filterFunction="{onListItemFilter(data)}"/&gt;
   &lt;script&gt;
   &lt;![CDATA[
        [Bindable]
        var myProvider:ArrayCollection;

        <span style="color:#ff0000;">// This can be moved to a Controller</span>
        private function onClick(event:MouseEvent)
        {
<span style="color:#008000;"> // Do Something</span>
        }

        <span style="color:#ff0000;">// This can be move to a State Machine</span>
        private function setState(state:String)
        {
           <span style="color:#008000;"> // Hide, show or move something in the View</span>
        }

        <span style="color:#ff0000;">// This can be moved to an Handler class</span>
        private function onListItemFilter(object:SomeValueObject):Boolean
        {
<span style="color:#008000;"> // Check if this item complies to conditions // Returns false if not</span>
        }

    ]]&gt;
    &lt;/script&gt;
&lt;/mx:Canvas&gt;</pre>
<p><strong>Phase 2: evaluating your MXML code</strong> &#8211; Basic rule of thumb: When you have more than 30 lines of code and/or your code takes more real estate than your screen provides, it is time to start separating it from the MXML.</p>
<p><strong>Phase 3: Separating Responsibilities</strong> &#8211; When you look at the code in your View it usually either:</p>
<ol>
<li>Does someting with something else, based on events triggered by the User &#8211; This is moved into a <strong>Controller</strong>.</li>
<li>Handles something of something inside your View, like running through data in a list to filter stuff &#8211; This is moved into a <strong>Handler</strong>.</li>
<li>Influences the State of your View (hiding, showing or moving stuff), based on something happening somewhere inside or outside your View &#8211; This is moved into a <strong>State Machine</strong>.</li>
<li>Formats something in your View, like colors of elements and specific notations of (telephone) numbers &#8211; This is moved into a <strong>Formatter</strong>.</li>
</ol>
<p>Each of the Objects from these Classes are instantiated by the View. The reference to the View is Injected when the specific object is Instantiated.</p>
<pre style="padding-left:30px;">&lt;mc:Canvas <span style="color:#0000ff;">creationComplete</span>="init()"&gt;
   &lt;mx:Button label="my Button"/&gt;
   &lt;mx:DataGrid dataProvider="{<span style="color:#0000ff;">viewModel</span>.<span style="color:#0000ff;">myProvider</span>}" /&gt;
   &lt;script&gt;
   &lt;![CDATA[
        var <span style="color:#0000ff;">viewModel</span>:MyViewNameVM;
        var <span style="color:#0000ff;">controller</span>:MyViewNameController;
        var <span style="color:#0000ff;">handler</span>:MyViewNameHandler;
        var <span style="color:#0000ff;">stateMachine</span>:MyVieNameStateMachine;
        var <span style="color:#0000ff;">formatter</span>:SomeSpecificFormatter;

        private function <span style="color:#0000ff;">init</span>()
        {
            <span style="color:#008000;">// viewModel uses the Bindable options of Flex to signal changes</span>
            <span style="color:#0000ff;">viewModel</span> = new <span style="color:#0000ff;">MyViewNameVM</span>( <span style="color:#ff0000;">this</span> );

           <span style="color:#008000;"> // The Controller will internally attach Event // Listeners to buttens and what have you</span>
            <span style="color:#0000ff;">controller</span> = new <span style="color:#0000ff;">MyViewNameController</span>( <span style="color:#ff0000;">this</span> );

            <span style="color:#008000;">// The Handler will deal with filters on lists and other // stuff that needs "handled"</span>
            <span style="color:#0000ff;">handler</span> = new <span style="color:#0000ff;">MyViewNameHandler</span>( <span style="color:#ff0000;">this</span> );

            <span style="color:#008000;">// The state-machine will deals with making items visible and invisible</span>
            <span style="color:#008000;">// Based on specific rules</span>
            <span style="color:#0000ff;">stateMachine</span> = new <span style="color:#0000ff;">MyStateMachine</span>( <span style="color:#ff0000;">this</span> );

            <span style="color:#008000;">// The Formatter attaches formatters to specific objects</span>
            <span style="color:#0000ff;">formatter</span> = new <span style="color:#0000ff;">SomeSpecificFormatter</span>( <span style="color:#ff0000;">this</span> );
        }
    ]]&gt;
    &lt;/script&gt;
&lt;/mx:Canvas&gt;</pre>
<p><strong>Phase 4: generalize your code</strong> &#8211; It might be that for each form you have in your project, the data is collected and sent in exactly the same way. This might lead to a generic function that looks at the display list of your form, picks out all the objects of a specific type and collects and structures the data in such a way that you can send it directly to the Server. The key questions for generalization are:</p>
<ol>
<li><strong>Did I already do something like this somewhere else?</strong> &#8211; If so, you are very likely repeating a pattern that can be generalized.</li>
<li><strong>Can I make this into something that is re-usable?</strong> &#8211; This is the tough one. Very likely: yes.</li>
<li><strong>Is it worth the effort?</strong> &#8211; If your generalized code is only useable on two places in your code and you will never need it again, you might consider leaving things as they are.</li>
</ol>
<h2>Instantiating your View Model Objects, Controllers and Handlers</h2>
<p>As we already gave an example of a cleaned up View, below you will only find the &lt;script&gt; part, as shown above.</p>
<pre>   &lt;script&gt;
   &lt;![CDATA[
        var <span style="color:#0000ff;">viewModel</span>:MyViewNameVM;
        var <span style="color:#0000ff;">controller</span>:MyViewNameController;
        var <span style="color:#0000ff;">handler</span>:MyViewNameHandler;
        var <span style="color:#0000ff;">stateMachine</span>:MyVieNameStateMachine;
        var <span style="color:#0000ff;">formatter</span>:SomeSpecificFormatter;

        <span style="color:#008000;">// Called "oncreationComplete"</span>
        private function init()
        {
            <span style="color:#008000;">// viewModel uses the Bindable options of Flex to signal changes</span>
            <span style="color:#0000ff;">viewModel</span> = new MyViewNameVMO( this );

            <span style="color:#008000;">// The Controller will internally attach Event // Listeners to buttens and what have you</span>
            <span style="color:#0000ff;">controller</span> = new MyViewNameController( this );

            <span style="color:#008000;">// The Handler will deal with filters on lists and other // stuff that needs "handled" </span>
            <span style="color:#0000ff;">handler</span> = new MyViewNameHandler( this );

            <span style="color:#008000;">// The state-machine will dela with making items visible and invisible</span>
            <span style="color:#0000ff;">stateMachine</span> = new MyStateMachine( this );

            <span style="color:#008000;">// The Formatter attaches formatters to specific objects</span>
            <span style="color:#0000ff;">formatter</span> = new SomeSpecificFormatter( this );
        }
    ]]&gt;
    &lt;/script&gt;</pre>
<p>All the View-specific classes share the same name as the View. This makes referring and code-organizing a lot easier as your editor very likely has code-completion and other ways to help you while typing.</p>
<h2>Motivation behind- and benefits of this approach</h2>
<p>Even though Flex allows you to write code in your Views, this is not really recommendable. You are basically doing the same thing people used to do in HTML: mixing presentation stuff with coding stuff. While this is OK for small projects, your integrated code becomes less and less maintainable as your project grows.</p>
<p>The biggest pitfalls you can avoid by externalizing your code are:</p>
<ol>
<li><strong>Code repetition</strong> &#8211; It is easy and also very tempting to make quick builds by Copy &amp; Paste the code you already made throughout your application. However, when you change your approach, this might also lead to</li>
<li><strong>Code clutter</strong> &#8211; As the complexity of your View grows, so does the amount of functions and procedures. By Separation of Responsibilities and externalization you cut your code into clear parts which are stored in a clear place.</li>
</ol>
<p>The main benefits are:</p>
<ol>
<li><strong>Clear separation of responsiblity</strong> &#8211; Your code is broken up into clear modules, each with a clear purpose and function</li>
<li><strong>Easier to refactor</strong> &#8211; As your code is externalized, functionalities in your View can be changed or extended by using and adding other Classes.</li>
<li><strong>More inviting and stimulating to generalize your code</strong> &#8211; When you start externalizing your code, you also (very likely) automatically start to seen new ways to do things smarter and more efficient. For instance: when you do the same thing on multiple places, with only slight changes in the code, it might suddenly become rewarding to generalize those parts, so that one function and one method is doing it all for everyone. This also helps you big time when you need to refactor those specific parts.</li>
</ol>
<p>.</p>
<h1>The Controller</h1>
<p>The controller deals with all events on the view, induced by the user. It retrieves data from the View and passes this to the View Model Object. It can also retrieve data from the View Model Object.</p>
<p>In Daymo, the Controller is separated from the MXML code.</p>
<h2>Registering Events</h2>
<p>Although Flex provides a simple and clean way to attach Events to any object in the View, Events are best attached from the Controller, using ActionScript.</p>
<pre><span style="color:#008000;">// Attaching an Event to an object in the View</span>
myView.myButton.<span style="color:#0000ff;">adEventListener</span>(MouseEvent.MOUSE_UP, onMouseUp)</pre>
<p>This seems retarded at first when you are used to the simple event dispatchers in MXML, but starts making sense when the same pattern is repeated for any button in your View.</p>
<h2>Registering Events with a Handler Object</h2>
<p>When you find that code is repeating, you might want to bundle the repetitive code. For instance: on mouse over the object receives a glow, on mouse-out the glow dissappears.</p>
<pre><span style="color:#008000;">// HANDLER OBJECT <span style="color:#000000;">public class mouseGlowHandler implements IMouseHandler</span> <span style="color:#000000;">{</span> // Function to deal with repetative actions</span>
   public function addObjectMouseHandler( object:UIComponent )
   {
       // Add eventlisteners to the object
       object.addEventListener( MouseEvent.MOUSE_OVER, <span style="color:#ff0000;">onMouseOver</span> )
       object.addEventListener( MouseEvent.MOUSE_OUT, <span style="color:#ff0000;">onMouseOut</span> )
   }<span style="color:#008000;"> </span>

<span style="color:#008000;"> // Handle the events</span>
   private function <span style="color:#ff0000;">onMouseOver</span>( event:MouseEvent )
   {
   <span style="color:#008000;"> // Do something</span>
   }
   private function <span style="color:#ff0000;">onMouseOut</span>( event:MouseEvent )
   {
<span style="color:#008000;"> // Do something else</span>
   }
}</pre>
<p>Applying the Handler Object to the buttons</p>
<pre><span style="color:#008000;">// Instantiate the Handler Object</span>
private var handler:IMouseHandler=new mouseGlowHandler();
<span style="color:#008000;">// Apply to objects</span>
handler.addObjectMouseHandler( this.buttonOne );
handler.addObjectMouseHandler( this.buttonTwo );
handler.addObjectMouseHandler( this.buttonThree );</pre>
<p>.</p>
<h1>The Services</h1>
<p>[Text to be written]</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/daymoframework.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/daymoframework.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/daymoframework.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/daymoframework.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/daymoframework.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/daymoframework.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/daymoframework.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/daymoframework.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/daymoframework.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/daymoframework.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/daymoframework.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/daymoframework.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/daymoframework.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/daymoframework.wordpress.com/145/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daymoframework.wordpress.com&amp;blog=13960036&amp;post=145&amp;subd=daymoframework&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://daymoframework.wordpress.com/2010/07/01/the-daymo-approach-to-model-view-controller/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cffc2ff7b980a5f5f76c22bddba4f361?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">peter kaptein</media:title>
		</media:content>

		<media:content url="http://daymoframework.files.wordpress.com/2010/07/picture-214.png" medium="image">
			<media:title type="html">Picture 214</media:title>
		</media:content>

		<media:content url="http://daymoframework.files.wordpress.com/2010/07/picture-214.png" medium="image">
			<media:title type="html">Picture 214</media:title>
		</media:content>

		<media:content url="http://daymoframework.files.wordpress.com/2010/07/picture-210.png" medium="image">
			<media:title type="html">Picture 210</media:title>
		</media:content>

		<media:content url="http://daymoframework.files.wordpress.com/2010/07/picture-212.png" medium="image">
			<media:title type="html">Picture 212</media:title>
		</media:content>
	</item>
		<item>
		<title>Images and image references in Daymo</title>
		<link>http://daymoframework.wordpress.com/2010/06/14/images-and-image-references-in-daymo/</link>
		<comments>http://daymoframework.wordpress.com/2010/06/14/images-and-image-references-in-daymo/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 11:15:18 +0000</pubDate>
		<dc:creator>Peter Kaptein</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://daymoframework.wordpress.com/?p=141</guid>
		<description><![CDATA[In Flex you can include external assets like images all over your project by using: [Embed(source='mylocationOnDisk/myImage.png')] private var myImageClass:Class; You can then create the image within the same class by using the class myImageClass: var myImage:Bitmap = new myImageClass(); Centralizing the class references The best practice according to Daymo is to centralize the class-references to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daymoframework.wordpress.com&amp;blog=13960036&amp;post=141&amp;subd=daymoframework&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In Flex you can include external assets like images all over your project by using:</p>
<pre>[<span style="color:#ff0000;">Embed</span>(source='mylocationOnDisk/<span style="color:#0000ff;">myImage</span>.png')]
private var <span style="color:#0000ff;">myImageClass</span>:Class;
</pre>
<p>You can then create the image within the same class by using the class myImageClass:</p>
<pre>var <span style="color:#0000ff;">myImage</span>:Bitmap = new <span style="color:#0000ff;">myImageClass</span>();
</pre>
<h2>Centralizing the class references</h2>
<p>The best practice according to Daymo is to centralize the class-references to images and assets.</p>
<pre>package com.myproject.assets.<span style="color:#0000ff;">icons</span>
{
  <span style="color:#008080;">// Class is in same directory as images are</span>
  public class <span style="color:#0000ff;">ButtonIcons</span>
  {
    [<span style="color:#ff0000;">Embed</span>(source='<span style="color:#0000ff;">icon_add.png</span>')]
    [Bindable]
    public static var <span style="color:#0000ff;">icon_add</span>:<span style="color:#ff0000;">Class</span>;

    [<span style="color:#ff0000;">Embed</span>(source='<span style="color:#0000ff;">icon_remove.png</span>')]
    [Bindable]
    public static var <span style="color:#0000ff;">icon_remove</span>:<span style="color:#ff0000;">Class</span>;

  }
}
</pre>
<p>Referencing button icons in your project is then done as follows:</p>
<pre><span style="color:#008080;">// Somewhere in your project:</span>
var <span style="color:#0000ff;">myAddIcon</span>:Bitmap = new ButtonIcons.<span style="color:#0000ff;">icon_add</span>()
</pre>
<h2>Advantages</h2>
<p>The advantages of this approach are as follows:</p>
<ol>
<li>You centralize and abstract your image and asset references</li>
<li>When you change the image (to another file) it will automatically &#8220;change&#8221; all over your project</li>
<li>Changing the folder location of your images and assets (refactoring and restructuring of your project) will not break your project when you correctly change the class-path</li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/daymoframework.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/daymoframework.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/daymoframework.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/daymoframework.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/daymoframework.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/daymoframework.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/daymoframework.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/daymoframework.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/daymoframework.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/daymoframework.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/daymoframework.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/daymoframework.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/daymoframework.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/daymoframework.wordpress.com/141/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daymoframework.wordpress.com&amp;blog=13960036&amp;post=141&amp;subd=daymoframework&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://daymoframework.wordpress.com/2010/06/14/images-and-image-references-in-daymo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cffc2ff7b980a5f5f76c22bddba4f361?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">peter kaptein</media:title>
		</media:content>
	</item>
		<item>
		<title>Blaze DS, Data calls to multiple sources and Blocking and Non-Blocking processes</title>
		<link>http://daymoframework.wordpress.com/2010/06/08/blaze-ds-data-calls-to-multiple-sources-and-blocking-and-non-blocking-processes/</link>
		<comments>http://daymoframework.wordpress.com/2010/06/08/blaze-ds-data-calls-to-multiple-sources-and-blocking-and-non-blocking-processes/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 19:28:26 +0000</pubDate>
		<dc:creator>Peter Kaptein</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://daymoframework.wordpress.com/?p=137</guid>
		<description><![CDATA[By: Peter Kaptein Calling BlazeDS: HTTP, bytecode and less overhead Calling BlazeDS &#8211; as far as I understand now &#8211; happens through a HTTP call from Flex. The main difference between a normal HTTP call (i.e to a Jason or SOAP service) and that of BlazeDS is that all data is sent and received as [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daymoframework.wordpress.com&amp;blog=13960036&amp;post=137&amp;subd=daymoframework&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>By: Peter Kaptein</em></p>
<h2>Calling BlazeDS: HTTP, bytecode and less overhead</h2>
<p>Calling BlazeDS &#8211; as far as I understand now &#8211; happens through a HTTP call from Flex. The main difference between a normal HTTP call (i.e to a Jason or SOAP service) and that of BlazeDS is that all data is sent and received as structured Bytecode representing objects. This reduces a lot of data overhead you do get using XML (in the case of SOAP and Jason).</p>
<h2>Why would we like to handle data from multiple sources?</h2>
<p>In some cases we might want to collect data from several sources via parallel calls and put the results together in one dataset on the server. The reason to do this is:</p>
<ol>
<li>Because the requested data is spread over different data sources on different machines</li>
<li>Because the requested data is from one data source, but better to be split in separate requests</li>
<li>Because some requests can be split over multiple machines on the back end to do the same job faster</li>
</ol>
<h2>Who does what?</h2>
<p>The ideal case is this:</p>
<ol>
<li>The Flex Front end only visualizes the data</li>
<li>The (Java) back end does all the heavy lifting, all the data-processing and all data-merging</li>
</ol>
<h2>Multiple Data Requests: breaking the call into chunks</h2>
<p>When we have multiple data sets from one call, it might be more efficient to process and show them bit by bit, instead of waiting for everything to be done.</p>
<p>For instance: we want to get financial data over 5 different companies. Each company is a separate query with separate execution times, disributed over different processes. For instance:</p>
<ul>
<li>Company 1: 200 milliseconds execution time</li>
<li>Company 2: 10 milliseconds execution time</li>
<li>Company 3: 3.000 milliseconds execution time</li>
</ul>
<p>The response in a normal HTTP call will take as long as the longest call: 3.000 milliseconds. However: we already had data after 10 milliseconds.</p>
<p>Why do we want to break the calls into</p>
<ol>
<li>To present the parts as soon as they are done: increasing the user experience and responsiveness.</li>
</ol>
<h2>Two way Push or HTTP: what is the issue?</h2>
<p>We have no real problem as long as we are talking about 3 to 10 calls.  But when it includes 100 data sets, the game changes. For each separate call we will have to open a separate HTTP request. In most cases the browser Flash / Flex is running in allows us only a limited amount of concurrent calls to go out. Like 3 to 5 &#8211; let&#8217;s call them &#8211; slots. So all the other 95 data calls are waiting until a HTTP-call is finished and a slot becomes available again.</p>
<p>The most ideal situation is to limit the amount of HTTP-calls to the server and do as much as possible over one connection. So when we request multiple data sets we can do that immediately without waiting for slots to become available and at the same time the Server returning us complete data-sets when the process is done on the server.</p>
<p>There are two ways with Flash/Flex where this is simple to establish:</p>
<ol>
<li>Using Sockets &#8211; keeping one persistent connection open to push data from client to server and from server to client</li>
<li>Using Adobes RMTP &#8211; keeping one persistent connction open to .. see Sockets</li>
</ol>
<p>Two way push is a very nice and efficient way of working.</p>
<ol>
<li>You push your request to the server</li>
<li>The server does its work</li>
<li>When done, it pushes the response back</li>
</ol>
<p>With HTTP calls I open a new Socket connection which is closed as soon as the call is replied by the server. It creates more overhead and takes more time.</p>
<h2>Why not use Sockets or RMTP?</h2>
<p>In most companies with firewalls and proxies technologies like Sockets and RMTP are Forbidden. Anything not HTTP is blocked and filtered out as these types of connections can introduce and invite potential harm or run over ports which are blocked.</p>
<h2>BlazeDS: assumptions on Blocking processes and data Push</h2>
<p>In the most ideal case we can send multiple requests to the BlazeDS server via one connection and receive pushes of data back for each of the requests that is finished.</p>
<p>As BlazeDS uses HTTP it does not allow for a straight forward Asynchronous push-scenarios. Each call to the server opens a new socket connection which is closed as soon as the call is replied by the server. This also means that the BlazeDS server and the Java-components are very likely blocking per request: waiting and running a &#8220;while (notDone==true) { // do something }&#8221; until they have all the data.</p>
<p>So, assuming that: multiple calls will open multiple socket connections, each in turn dealt by a thread that is &#8220;blocking&#8221; until that specific call is dealt with.</p>
<h2>BlazeDS: Streaming data &#8211; a Chat example</h2>
<p>In <a href="http://www.adobe.com/devnet/livecycle/articles/blazeds_gettingstarted_03.html">this tutorial</a> on the Adobe Developer Connection, two strategies are followed to create a chat application.</p>
<p>A quote from the site (bold are done by me):</p>
<blockquote><p>A key element of a destination is the channel used to exchange data  between the client and the server. Using BlazeDS, a messaging  destination typically uses either a streaming or a polling channel.</p>
<ul>
<li><strong>Using a streaming channel</strong>, <strong>the server response is left open  until the channel connection is closed, allowing the server to send  incremental chunks of data to the client</strong>. Because HTTP connections are  not duplex, a single streaming Action Message Format (AMF) or HTTP  channel actually requires two browser HTTP connections in order to send  data in both directions. One is needed for the streamed response from  the server to the client that the channel hangs on to. A second  transient connection, drawn from the browser pool, is needed only when  data is sent to the server. This second transient connection is  immediately released back to the browser’s connection pool after the  data is sent.</li>
<li><strong>A polling channel can be configured with a polling  interval, or it can be set up to wait for data at the server-side if  data is not immediately available </strong>(this approach is generally referred  to as long polling). In either case, each poll response completes the  request. Browser HTTP 1.1 connections are persistent by default, so the  browser will likely recycle existing HTTP connections to send subsequent  poll requests, which lowers the overhead for polling.</li>
</ul>
</blockquote>
<h2>Blocking, Non-Blocking and Callbacks</h2>
<p>A blocking process stops an entire process until something is finished.</p>
<p>A non-blocking process delegates the process to another Thread and continues it&#8217;s work, or simply stops until it is called back.</p>
<p>For a non-blocking process to know when a delegated process is done, it receives a Callback: being the Thread telling the object with the non-blocking process &#8211; for instance: &#8220;I am done&#8221;, &#8220;I am stil busy&#8221; or &#8220;I failed&#8221;.</p>
<h2>Blocking and non-blocking scenarios</h2>
<p><a href="http://daymoframework.files.wordpress.com/2010/06/picture-196.png"><img class="alignnone size-full wp-image-138" title="Picture 196" src="http://daymoframework.files.wordpress.com/2010/06/picture-196.png?w=594" alt=""   /></a></p>
<p><strong>Flex</strong> is by default non-blocking in the way it deals with data-calls. Every object loading data releases the main process once fired and fires specific events:</p>
<ul>
<li>When loading (percentage loaded)</li>
<li>When loading is done</li>
<li>When an error occurred somewhere in the process</li>
</ul>
<p>Each of these events can be captured via event listeners.</p>
<p>The HTTP call itself is a &#8220;singular&#8221; process. During the call a HTTP socket connection is opened to the server and once data is returned the socket connection is closed. Normally we do not persist that HTTP connection to push multiple data sets through the same HTTP socket and BlazeDS does not seem to provide a protocol for that.</p>
<p><strong>BlazeDS</strong> (very likely) creates one thread per HTTP-socket: waiting for the response from the Java Bean we called and very likely blocking during that waiting process. The Java-Bean will do the same: waiting until the process is finished when calling a Service.</p>
<p>The <strong>Java Beans</strong> themselves can actually be using any process to get the data. Using event listeners to send their status back to another object (that will execute stuff and send data to other objects) and running in separate Threads they can be either blocking or non-blocking. In the drawing we assume they are blocking while waiting for the data form the Service.</p>
<p>The <strong>Services</strong> called by the beans can also be either blocking or non-blocking. Usually they are non-blocking, releasing themselves via delegates instead of actively looping in a &#8220;while (notDoneYet==true) {  // endless loop until done }&#8221; and blocking all other processes in the mean time.</p>
<p><strong>Asynchronous processes </strong>work with callbacks. The object requesting an action calls out, then continues &#8211; instead of halting while waiting. When the delegate process is done, that process will notify the caller. For instance: the Service telling the Java Bean via a variable: &#8220;I am done&#8221;.</p>
<p><strong>Synchronous processes</strong> stop the execution of the code in an object until something is done. Synchronous processes can freeze an entire application.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/daymoframework.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/daymoframework.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/daymoframework.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/daymoframework.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/daymoframework.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/daymoframework.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/daymoframework.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/daymoframework.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/daymoframework.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/daymoframework.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/daymoframework.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/daymoframework.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/daymoframework.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/daymoframework.wordpress.com/137/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daymoframework.wordpress.com&amp;blog=13960036&amp;post=137&amp;subd=daymoframework&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://daymoframework.wordpress.com/2010/06/08/blaze-ds-data-calls-to-multiple-sources-and-blocking-and-non-blocking-processes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cffc2ff7b980a5f5f76c22bddba4f361?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">peter kaptein</media:title>
		</media:content>

		<media:content url="http://daymoframework.files.wordpress.com/2010/06/picture-196.png" medium="image">
			<media:title type="html">Picture 196</media:title>
		</media:content>
	</item>
		<item>
		<title>Events and Daymo (View) State Machines</title>
		<link>http://daymoframework.wordpress.com/2010/06/05/daymo-events-and-view-state-machines/</link>
		<comments>http://daymoframework.wordpress.com/2010/06/05/daymo-events-and-view-state-machines/#comments</comments>
		<pubDate>Sat, 05 Jun 2010 20:39:15 +0000</pubDate>
		<dc:creator>Peter Kaptein</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://daymoframework.wordpress.com/?p=98</guid>
		<description><![CDATA[Info about the Daymo State Machine and Events.
<img class="alignnone size-full wp-image-105" title="Picture 195" src="http://daymoframework.files.wordpress.com/2010/06/picture-195.png" alt="" width="455" height="263" /><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daymoframework.wordpress.com&amp;blog=13960036&amp;post=98&amp;subd=daymoframework&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>By: Peter Kaptein</em></p>
<p><em>Date: June 5, 2010</em></p>
<h2>So what do State Machines do again?</h2>
<p><a href="http://daymoframework.files.wordpress.com/2010/06/picture-194.png"></a><a href="http://daymoframework.files.wordpress.com/2010/06/picture-1941.png"><img class="alignnone size-full wp-image-101" title="Picture 194" src="http://daymoframework.files.wordpress.com/2010/06/picture-1941.png?w=594" alt=""   /></a></p>
<p>Daymo State Machines changes the state of an object. They are mostly used to set View States:</p>
<ol>
<li><strong>Visibility of objects</strong> &#8211; hide, show, slide out of view, slide into view</li>
<li><strong>Width and size of objects</strong> &#8211; increase, decrease, minimize, maximize</li>
<li><strong>Dependencies</strong> &#8211; &#8220;when the screen is maximized, the button shows a label&#8221;</li>
</ol>
<p>State Machines act on events and values given by the objects they control and received via Static Variables.</p>
<p>The the state of a State Machine is set and change in the following ways:</p>
<ol>
<li>Set or change a Static Variable on the Class Reference of the State Machine</li>
<li>Dispatch an event that will result in a change of state</li>
</ol>
<h2>Basic rules:</h2>
<p><a href="http://daymoframework.files.wordpress.com/2010/06/picture-195.png"><img class="alignnone size-full wp-image-105" title="Picture 195" src="http://daymoframework.files.wordpress.com/2010/06/picture-195.png?w=594" alt=""   /></a></p>
<ol>
<li><em><strong>State Machines set values and call functions on other State Machines</strong></em> &#8211; This is the preferred approach. Expose Static getters, setters and function which deal internally  with the right type</li>
<li><em><strong>State Machines fire events to  State Machines</strong></em> &#8211; Although OK, try to avoid this. The State Machines approach work best when you keep State Machine Events internal. Rather set the values on static getters, setters and functions of other State Machines.</li>
<li><em><strong>State Machines fire events to the outside world</strong></em> &#8211; Although OK, use this only when it is the best option. In principle, State Machines deal with objects directly &#8211; so address the State Machine of an object, instead of</li>
<li><em><strong>Objects set values on State Machines</strong></em> &#8211; Perfectly OK.</li>
</ol>
<h2>State Machines rather keep Events internal</h2>
<p>The best way to use State Machines in Daymo is to treat a State Machine as a closed environment for events. So all events a State Machine could receive, are fired internally.</p>
<p>Here is why:</p>
<ul>
<li>Keeping event dispatching inside a State Machine is <strong>keeping control</strong> over the <strong>reason</strong> a specific event was fired.</li>
<li>Moving event dispatching outside a State Machine is <strong>losing control</strong> over the <strong>reason</strong> a specific event was fired.</li>
</ul>
<p>When the (business) rules change in your application due to Change Requests, you keep control over your event-model. The risk that an Event Dispatcher somewhere in your application is overlooked is reduced.</p>
<p>As soon as your application becomes complex, maintaining your event model can become complex. Especially when States are dependent on other States.</p>
<h2>An example of a &#8220;Global&#8221; State Machine</h2>
<p>In this case the State Machine deals with a View and fires and receives all events internally.</p>
<pre>public class <span style="color:#0000ff;">MyStateMachine</span> {

 public static const <span style="color:#0000ff;">STATE_BUTTON_MINIMIZED</span>:int=75;
 public static const <span style="color:#0000ff;">STATE_BUTTON_MAXIMIZED</span>:int=175;

<span style="color:#008000;"> // Register a internal event dispatcher for this State Machine</span>
 <span style="color:#ff0000;">private static var</span> <span style="color:#0000ff;">dispatcher</span>:<span style="color:#ff0000;">EventDispatcher</span>=new <span style="color:#ff0000;">EventDispatcher</span>()

<span style="color:#008000;"> // Constructor</span>
 public function MyStateMachine(<span style="color:#0000ff;">myViewObject</span>:MyView)
 {
    <span style="color:#008000;">// Code to register myViewObject in this State Machine Instance
    // - We use it to deal with the object specific states</span>

    <span style="color:#008000;">// Init the state machine for myViewObject</span>
    <span style="color:#0000ff;">init</span>();
 }

<span style="color:#008000;"> // Init</span>
 private function <span style="color:#0000ff;">init</span>():void
 {
    <span style="color:#008000;">// Some events for this State Machine</span>
    <span style="color:#0000ff;">dispatcher</span>.addEventListener(SomeEvent.<span style="color:#ff0000;">MINIMIZE</span>,<span style="color:#0000ff;">minimizeHandler</span>);
    <span style="color:#0000ff;">dispatcher</span>.addEventListener(SomeEvent.<span style="color:#ff0000;">MAXIMIZE</span>,<span style="color:#0000ff;">maximizeHandler</span>);
    <span style="color:#0000ff;">dispatcher</span>.addEventListener(SomeEvent.<span style="color:#ff0000;">DEFAULT</span>,<span style="color:#0000ff;">defaultHandler</span>);
 }

<span style="color:#008000;"> // Static Public State setter</span>
 <span style="color:#ff0000;">public static function</span> <span style="color:#0000ff;">setState_Size</span>( <span style="color:#0000ff;">size</span>:int)
 {
    <span style="color:#008000;">// Makes the State Machine globally accessible</span>

    <span style="color:#008000;">// Minimize</span>
    if(<span style="color:#0000ff;">size</span>==<span style="color:#0000ff;">STATE_BUTTON_MINIMIZED</span>)
    {
       <span style="color:#008000;">// Tell all objects with this State Machine to act on "minimize"</span>
       <span style="color:#0000ff;">dispatcher</span>.<span style="color:#0000ff;">dispatchEvent</span>(new <span style="color:#0000ff;">SomeEvent</span>(LeftBarEvent.<span style="color:#ff0000;">MINIMIZE</span>) );
    }
    <span style="color:#008000;">// Do same for default and maximum width</span>
 }

<span style="color:#008000;"> // ==========================================
 // HANDLE VIEW STATES
 // ==========================================</span>
 private function <span style="color:#0000ff;">minimizeHandler</span>(event:ButtonBarEvent):void
 {
<span style="color:#008000;">    // Do something like: Hide labels and minimize widht</span>
    <span style="color:#0000ff;">setObjectWidth</span>(STATE_BUTTON_MINIMIZED,true);
 } 

 private function <span style="color:#0000ff;">maximizeHandler</span>(event:ButtonBarEvent):void
 {
    <span style="color:#008000;">// Do something like: Show labels, maximize widht</span>
 }
 private function <span style="color:#0000ff;">defaultHandler</span>(event:ButtonBarEvent):void
 {
    <span style="color:#008000;">// Do something like: Show labels, set to start-width</span>
 }  

<span style="color:#008000;"> // ==========================================
 // HANDLERS - VIEW STATES
 // ==========================================</span>

<span style="color:#008000;"> // Set button width</span>
 private function <span style="color:#0000ff;">setObjectWidth</span>(width:int,showLabels:Boolean=true)
 {
    <span style="color:#008000;">// Do something to set width of registered view object</span>
 }
}</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/daymoframework.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/daymoframework.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/daymoframework.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/daymoframework.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/daymoframework.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/daymoframework.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/daymoframework.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/daymoframework.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/daymoframework.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/daymoframework.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/daymoframework.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/daymoframework.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/daymoframework.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/daymoframework.wordpress.com/98/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daymoframework.wordpress.com&amp;blog=13960036&amp;post=98&amp;subd=daymoframework&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://daymoframework.wordpress.com/2010/06/05/daymo-events-and-view-state-machines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cffc2ff7b980a5f5f76c22bddba4f361?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">peter kaptein</media:title>
		</media:content>

		<media:content url="http://daymoframework.files.wordpress.com/2010/06/picture-1941.png" medium="image">
			<media:title type="html">Picture 194</media:title>
		</media:content>

		<media:content url="http://daymoframework.files.wordpress.com/2010/06/picture-195.png" medium="image">
			<media:title type="html">Picture 195</media:title>
		</media:content>
	</item>
		<item>
		<title>The Daymo Drag and Drop Handler</title>
		<link>http://daymoframework.wordpress.com/2010/06/05/the-daymo-drag-and-drop-handler/</link>
		<comments>http://daymoframework.wordpress.com/2010/06/05/the-daymo-drag-and-drop-handler/#comments</comments>
		<pubDate>Sat, 05 Jun 2010 15:04:31 +0000</pubDate>
		<dc:creator>Peter Kaptein</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://daymoframework.wordpress.com/?p=74</guid>
		<description><![CDATA[This article explains how to use the Daymo Drag and Drop patterns.
<img class="alignnone size-full wp-image-76" title="Picture 189" src="http://daymoframework.files.wordpress.com/2010/06/picture-1891.png" alt="" width="455" height="332" /><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daymoframework.wordpress.com&amp;blog=13960036&amp;post=74&amp;subd=daymoframework&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>By Peter Kaptein</em></p>
<p><em>June 05, 2010<br />
</em></p>
<p>The Daymo Drag and Drop mechanism envelops the standard Flex Drag &amp; Drop. The goal of the Daymo Drag &amp; Drop Handler is:</p>
<ol>
<li>To simplify implementing and using the drag and drop process throughout your application</li>
<li>To give you direct access to the wanted Target-object clicked by the user</li>
<li>Offer you a clear structure to handle the events dispatched by drag and drop actions</li>
<li>Exposing the &#8220;dragged&#8221; object in a more direct way.</li>
</ol>
<p>The code examples given here are to help you understand the framework. In the &#8220;src.Prototypes&#8221; section of the project folder you will find implementations of these examples.</p>
<h2>Making a distinction between Visual Objects, Data Objects and Handlers</h2>
<p>Using Drag and Drop, Daymo makes a distinction between Visible Objects, Data Objects and Handlers.</p>
<p><strong>Visible Objects</strong> &#8211; Anything you see on the screen, including</p>
<ul>
<li>Buttons</li>
<li>Lists</li>
<li>Treeviews</li>
<li>(Smart) Visual Components you created</li>
</ul>
<p><strong>Data Objects</strong> &#8211; Anything that contains data.</p>
<ul>
<li>Models</li>
<li>Specific data objects you created</li>
</ul>
<p><strong>Handlers</strong> &#8211; The objects that deal with the Drag and Drop events. The handler can be:</p>
<ul>
<li>A (Smart) Visual Component you created</li>
<li>A separate object you created to deal with the events</li>
</ul>
<h2>Drag and Drop in Flex</h2>
<p>Daymo takes a very specific approach to Drag and Drop that is different to Flex.</p>
<p>In Flex you tend to link each object via MXML to their event handlers, like in this code example.</p>
<pre>    &lt;mx:Canvas id="v1"
        width="500" height="500"
        borderStyle="solid"
        backgroundColor="#DDDDDD"
        <span style="color:#0000ff;">dragEnter</span>="<span style="color:#0000ff;">dragEnterHandler</span>(event);"
        <span style="color:#0000ff;">dragDrop</span>="<span style="color:#0000ff;">dragDropHandler</span>(event);"&gt;
    &lt;/mx:Canvas&gt;</pre>
<p>Then you also define the object that can be dragged:</p>
<pre>    &lt;!-- The image is the drag initiator. --&gt;
    &lt;mx:Image id="myimg"
        source="@Embed(source='assets/globe.jpg')"
        <span style="color:#0000ff;">mouseMove</span>="<span style="color:#0000ff;">mouseMoveHandler</span>(event);"/&gt;</pre>
<p>The code to deal with dragging and dropping &#8211; in most cases &#8211; is then embedded in the MXML of the View.</p>
<pre><span style="color:#008000;">// Do something when dragobject is moved</span>
private function <span style="color:#0000ff;">mouseMoveHandler</span>(event:MouseEvent):void
{
    var dragInitiator:Image=Image(event.currentTarget);
    var ds:<span style="color:#0000ff;">DragSource</span> = new <span style="color:#0000ff;">DragSource</span>();
    ds.<span style="color:#0000ff;">addData</span>(dragInitiator, "img");
        DragManager.<span style="color:#0000ff;">doDrag</span>(dragInitiator, ds, event);
}

<span style="color:#008000;">// Do something when drag enters</span>
private function <span style="color:#0000ff;">dragEnterHandler</span>(event:DragEvent):void {
    if (event.dragSource.hasFormat("img"))
    {
        DragManager.acceptDragDrop(Canvas(event.currentTarget));
    }
}

<span style="color:#008000;">// Do something with the drop</span>
private function <span style="color:#0000ff;">dragDropHandler</span>(event:DragEvent):void {
    <span style="color:#008000;">// Set image on new dropped location</span>
}</pre>
<p>There are two disadvantages in this approach:</p>
<ol>
<li>You create &#8220;smart&#8221; code inside your View. Which makes the view very use case specific</li>
<li>Your code to handle drag and drop is fragmented through your project file.</li>
</ol>
<p>This seems not to be a big case when you start the project, but the more changes come, the more it will work against you.</p>
<p>So let&#8217;s compare:</p>
<p>To propagate a value from &#8220;Dragger&#8221; to &#8220;Drophandler&#8221; we do this:</p>
<pre>
<pre>    var <span style="color:#0000ff;">ds</span>:<span style="color:#ff0000;">DragSource</span> = new <span style="color:#ff0000;">DragSource</span>();
    <span style="color:#0000ff;">ds</span>.<span style="color:#0000ff;">addData</span>(<span style="color:#ff0000;">myImage</span>, "img");
    <span style="color:#008000;">// Start drag and propagate variable   </span>
    DragManager.doDrag<span style="color:#808080;">(dragInitiator,</span> <span style="color:#0000ff;">ds</span><span style="color:#808080;">, event)</span>;</pre>
</pre>
<p>That equals this:</p>
<pre>   DragDropHandler.<span style="color:#0000ff;">dataObject</span>=<span style="color:#ff0000;">myImage</span>; <span style="color:#008000;">// Of type Image</span></pre>
<p>When we receive a drop in Flex, this is the standard approach:</p>
<pre><span style="color:#008000;">// Do something when drag enters</span>
private function dragEnterHandler(event:DragEvent):void {
    if (event.<span style="color:#ff0000;">dragSource</span>.<span style="color:#0000ff;">hasFormat</span>("img"))
    {
        <span style="color:#008000;">// Do something</span>
    }
}</pre>
<p>Which equals this in Daymo:</p>
<pre>private function dragEventHandler(event:DragEvent):void {
    <span style="color:#008000;">// Only do things if object is of type Image</span>
    if(DragDropHandler.<span style="color:#0000ff;">dataObject</span> is <span style="color:#ff0000;">Image</span>)
    {
       <span style="color:#008000;">// Do something</span>
    }
}</pre>
<p>You will find more examples and comparisons between Flex and Daymo drag and drop further in this document. The Flex examples hopefully help you to see how Daymo allows you to make shortcuts on your code.</p>
<h2>Keeping the Visual Objects Stupid</h2>
<p>What we will do in Daymo is to keep the MXML-based Visual Objects as stupid as possible. All code that deals with the &#8220;smart&#8221; work will be externalized in DragHandlers and DropHandlers.</p>
<p>We also avoid using the DragSource. And this is why: Daymo promotes the use of Code Reduction and the use of Object Reflection when you do drag and drop. As you can only drag one object at a time in the base Flex Drag &amp; Drop scheme we might as well use a Static Variable.</p>
<h2>Making your own Smart Visual Components</h2>
<p>When you make your own Visual Components, you can merge the View Object and the Drag and Drop Handlers and make the Component Smart. One example where you might do that is draggable items in a Tree View.</p>
<h2>The Daymo Drag &amp; Drop principle</h2>
<p><a href="http://daymoframework.files.wordpress.com/2010/06/picture-1891.png"><img class="alignnone size-full wp-image-76" title="Picture 189" src="http://daymoframework.files.wordpress.com/2010/06/picture-1891.png?w=594" alt=""   /></a></p>
<p>When dragging starts you place an object in the static variable <strong><em>dataObject</em></strong> in the Daymo DragDropHandler. This creates a reference.</p>
<p>When the object is dropped on a drop-enabled object, you retrieve that object from the Daymo DragDropHandler.</p>
<h2>Initializing objects for drag and drop in Flex</h2>
<p>In the View we have a button called &#8220;dragObject&#8221;. We also have an object that operates as the drag handler: &#8220;dragHandler&#8221;. As we can define the drag- and drop handler separately, the drag and drop objects can be regular objects.</p>
<p>We have shown the full code at the beginning of the article, so let&#8217;s cut only the main items out.</p>
<p>Setting the dragEnter and dragDrop handlers:</p>
<pre>    &lt;mx:Canvas id="v1"
        <span style="color:#008000;">&lt;!-- IN DAYMO THIS IS DONE VIA <span style="color:#0000ff;">acceptDrop</span>--&gt;</span>
        dragEnter="<span style="color:#0000ff;">dragEnterHandler</span>(event);"
        dragDrop="<span style="color:#0000ff;">dragDropHandler</span>(event);"&gt;
    &lt;/mx:Canvas&gt;</pre>
<p>Defining the object that can be dragged:</p>
<pre>    <span style="color:#008000;">&lt;!-- The image is the drag initiator. --&gt;</span>
    &lt;mx:Image id="myimg"
        source="@Embed(source='assets/globe.jpg')"
        <span style="color:#008000;">&lt;!-- IN DAYMO THIS IS ADDED BY <span style="color:#0000ff;">setDraggable</span>--&gt;</span>
        mouseDown="<span style="color:#0000ff;">mouseClickHandler</span>(event);"
        mouseUp="<span style="color:#0000ff;">mouseReleaseHandler</span>(event);" /&gt;</pre>
<p>The code below to deal with dragging and dropping &#8211; in most cases &#8211; is then  embedded in the MXML of the View. In Daymo, all this work below is done in the Daymo DragDropManager, to save you the work of boilerplate coding.</p>
<pre><span style="color:#008000;">// FLEX MXML CODE </span>
private function <span style="color:#0000ff;">mouseClickHandler</span>(event:MouseEvent):void
{
    var <span style="color:#0000ff;">dragObject</span>:* =event.<span style="color:#0000ff;">currentTarget</span> ;

    <span style="color:#008000;">// Make sure we are going to drag this</span>
    <span style="color:#0000ff;">dragObject</span>.addEventListener(MouseEvent.MOUSE_MOVE,<span style="color:#0000ff;">mouseMoveHandler</span>) ;
}
<span style="color:#008000;">// Release drag listener</span>
private function <span style="color:#0000ff;">mouseReleaseHandler</span>(event:MouseEvent): void
{
    var <span style="color:#0000ff;">dragObject</span>:* = event.<span style="color:#0000ff;">currentTarget</span>
    <span style="color:#0000ff;">dragObject</span>.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
}
<span style="color:#008000;">// Do something when dragobject is clicked and moved</span>
private function <span style="color:#0000ff;">mouseMoveHandler</span>(event:MouseEvent):void
{
    <span style="color:#008000;">// Register drag start</span><span style="color:#008000;"> on DragManager</span>
    <span style="color:#008000;">// Start dargging</span>
}</pre>
<p>The dragHandler and dropHandler Objects are explained later in this document: how you create them, how you link them and what you within them.</p>
<h2>Initializing objects for drag and drop in Daymo</h2>
<p>In Daymo you make objects draggable and accepting drops via tow lines of code:</p>
<pre><span style="color:#008000;">// Set object to be draggable</span>
DragDropManager.<span style="color:#0000ff;">setDraggable</span>(<span style="color:#0000ff;">dragObject</span>, <span style="color:#ff0000;">dragHandler</span> ,true);

<span style="color:#008000;">// Set object to be droppable</span>
DragDropManager.<span style="color:#0000ff;">acceptDrop</span>(<span style="color:#0000ff;">dropObject</span>, <span style="color:#ff0000;">dropHandler</span> ,true);</pre>
<p>The dragHandler and dropHandler objects are explained later in this  document: how you create them, how you link them and what you within  them.</p>
<h2>Handling specific Drag and Drop events in Flex</h2>
<p>To give you an idea how you would most likely do this in the MXML code of your view:</p>
<pre><span style="color:#008000;">// Do something when dragobject is clicked and moved</span>
<span style="color:#008000;">// (IN DAYMO THIS IS DONE IN THE</span><span style="color:#008000;"> <span style="color:#0000ff;">dragHandler</span> OBJECT</span><span style="color:#008000;">)</span>
private function <span style="color:#0000ff;">mouseMoveHandler</span>(event:MouseEvent):void
{
    <span style="color:#008000;">// Do drag and drop custom magic</span>
}

<span style="color:#008000;">// Do something when drag enters</span>
<span style="color:#008000;">// (IN DAYMO THIS IS HANDLED IN THE <span style="color:#0000ff;">dropHandler</span> OBJECT</span><span style="color:#008000;">)</span>
private function <span style="color:#0000ff;">dragEnterHandler</span>(event:DragEvent):void {
    if (event.dragSource.hasFormat("img"))
    {
        DragManager.<span style="color:#0000ff;">acceptDragDrop</span>(Canvas(event.currentTarget));
    }
}

<span style="color:#008000;">// Do something with the drop
// (IN DAYMO THIS IS HANDLED IN THE <span style="color:#0000ff;">dropHandler</span> OBJECT)</span>
private function <span style="color:#0000ff;">dragDropHandler</span>(event:DragEvent):void {
    // Set image on new dropped location
}</pre>
<p>Remember that all event listeners to fire those blocks of code in Daymo are automatically created by the DragDropManager.</p>
<h2>Creating a Drag handler object</h2>
<p>The Drag Handler always implements <strong>IDraggable</strong>. The Drag Object always implements an interface (named IDragObjectInterface in this example). We will explain in the next part why we do that for the draggable object.</p>
<p>Via DragDropHandler.setDraggable we have attached eventlisteners to the Drag Handler, firing the following functions (included in IDraggable):</p>
<ol>
<li><strong>onStartDragClick</strong> &#8211; called when the user clicks on the draggable object</li>
<li><strong>onDragRelease</strong> &#8211; called when the user releases the object</li>
<li><strong>dragStartHandler</strong> &#8211; called when dragging starts</li>
<li><strong>dragCompleteHandler</strong> &#8211; called when dragging with the Flex DragManager is finished</li>
<li><strong>onRemovedFromStage</strong> &#8211; called when the dragObject is removed from stage</li>
</ol>
<pre>public class <span style="color:#0000ff;">DragHandler</span> implements <span style="color:#ff0000;">IDraggable</span> {

<span style="color:#008000;"> // Is linked to an event by- and called from- the DragDropManager</span>
 public function <span style="color:#0000ff;">onStartDragClick</span>(event : MouseEvent) : void
 {
   <span style="color:#008000;"> // Find out who we are dragging exactly</span>
    var obj:* =DragDropManager.<span style="color:#0000ff;">resolveTarget</span>(
         event.target, <span style="color:#ff0000;">IDragObjectInterface</span>
    ) ;

    trace("dragging :"+obj.name);

<span style="color:#008000;">    // Create a DradDrop Object</span>
    var <span style="color:#0000ff;">dragDropObject</span>:DragDropObject =new DragDropObject();

    <span style="color:#008000;">// Set the "name" variable</span>
    dragDropObject.name=obj.name;

 <span style="color:#008000;">   // Give Daymo DragDrop manager the data-object to be read by the drop-area</span>
    DragDropManager.<span style="color:#0000ff;">dataObject</span>=<span style="color:#0000ff;">dragDropObject</span>;
 }

 <span style="color:#008000;">// Eventlistener set via DragDropManager</span>
 public function <span style="color:#0000ff;">onDragRelease</span>(event : MouseEvent) : void {
     <span style="color:#008000;">// Do something here when the user releases the mouse button</span>
 }

 <span style="color:#008000;">// Not used here - extra functions you can use for more control
</span> public function <span style="color:#0000ff;">dragStartHandler</span>(event : DragEvent) : void {
     <span style="color:#008000;">// Do something when dragging starts</span>
 }
 public function <span style="color:#0000ff;">dragCompleteHandler</span>(event : DragEvent) : void {
     <span style="color:#008000;">// Do something when dragging is complete</span>
 }
 public function <span style="color:#0000ff;">onRemovedFromStage</span>(event : Event) : void {
 <span style="color:#008000;">    // We want to remove event listeners too</span>
 }</pre>
<h2>Creating a DropHandler object</h2>
<p>The DropHandler deals with alle the events fired when an object is dropped on a dropEnabled object.</p>
<p>The DropHandler has four autmated callbacks you can use:</p>
<ol>
<li><strong>dragStartHandler</strong> &#8211; when the user starts dragging</li>
<li><strong>dragStopHandler</strong> &#8211; when the user drops the object</li>
<li><strong>dragEnterHandler</strong> &#8211; when the dragged object hits the droppable object</li>
<li><strong>dragDropHandler</strong> &#8211; when the dragged object is dropped on the droppable object</li>
</ol>
<p><em><strong>Code example of a DropHandler class:</strong></em></p>
<pre>public class <span style="color:#0000ff;">DropHandler</span> implements <span style="color:#ff0000;">IDroppable</span> {

  public function DropHandler()
  {
 <span style="color:#008000;">    // We can register eventlisteners here to filter
     // specific drag actions to be ignored</span>
  }

  <span style="color:#008000;">// Deal with drag-object entering drop object</span>
<span style="color:#008000;">  // Called via the event listener set in the DragDropManager
  // when added via <span style="color:#0000ff;">DragDropManager.acceptDrop</span></span>

  public function <span style="color:#0000ff;">dragEnterHandler</span>(event : DragEvent) : void
  {
    var <span style="color:#0000ff;">dataObject</span>:DragDropObject =DragDropManager.<span style="color:#0000ff;">dataObject</span>;

    <span style="color:#008000;">// Get the drop target component from the event object.</span>
    var <span style="color:#0000ff;">dropTarget</span>:* = event.currentTarget;

    <span style="color:#008000;">// Show icon on drag object</span>
    <span style="color:#008000;">// Using the Flex dragmanager</span>
    DragManager.<span style="color:#0000ff;">showFeedback</span>(DragManager.COPY);
    DragManager.<span style="color:#0000ff;">acceptDragDrop</span>(<span style="color:#0000ff;">dropTarget</span>);    

 }

  <span style="color:#008000;">// Deal with object drop</span>
  public function <span style="color:#0000ff;">dragDropHandler</span>(event : DragEvent) : void {

 <span style="color:#008000;">   // We can check if the dropped object is of specific type</span>
    if(DragDropManager.<span style="color:#0000ff;">dataObject</span> is <span style="color:#ff0000;">DragDropObject</span>)
    {
        var <span style="color:#0000ff;">dataObject</span>:DragDropObject =DragDropManager.<span style="color:#0000ff;">dataObject</span>;

        <span style="color:#008000;">// Trace the value</span>
        trace("Dropped : "+<span style="color:#0000ff;">dataObject</span>.name);
    }
  }

  <span style="color:#008000;">// Explained later</span>
  public function <span style="color:#0000ff;">dragStartHandler</span>(e:DragDropEvent): void
  {
  }

  public function <span style="color:#0000ff;">dragStopHandler</span>(e:DragDropEvent):void
  {
  }
}</pre>
<h2>Interfacing the DragObject</h2>
<p>Remember this part in the DropHandler code above?</p>
<pre>
<pre>    <span style="color:#008000;">// Find out who we are dragging</span>
    var obj:* =DragDropManager.<span style="color:#0000ff;">resolveTarget</span>(
         event.target, <span style="color:#ff0000;">IDragObjectInterface</span>
    ) ;</pre>
</pre>
<p>When you start dragging an object, your &#8220;click&#8221; has been registered on <em>something</em>. This &#8220;<em>something</em>&#8221; is very likely a child-object of your DragObject. What we want to do is resolve the DragObject itself. And that is what we do here.</p>
<p>So let&#8217;s define the DragObject.</p>
<pre>Public class <span style="color:#0000ff;">DragObject</span> implements <span style="color:#ff0000;">IDragObjectInterface</span>
{
   <span style="color:#008000;">// Constructor</span>
   Public function DragObject()
   {

   }
   <span style="color:#008000;">// Do something here with code</span>
}</pre>
<p>The &#8220;implements an Interface&#8221; is crucial here.</p>
<p>Lets show you why via two images.</p>
<p><em><strong>The setup:</strong></em></p>
<p><a href="http://daymoframework.files.wordpress.com/2010/06/picture-190.png"><img class="alignnone size-medium wp-image-77" title="Picture 190" src="http://daymoframework.files.wordpress.com/2010/06/picture-190.png?w=300&#038;h=170" alt="" width="300" height="170" /></a></p>
<p>The user clicks on some child object in MyDragObject.</p>
<p>Using ResolveTarget with <em>event.target</em> and an Interface (or Class) as the input variable, this is what happens behind the screens:</p>
<p><em><strong>Finding the Interface (or Class):</strong></em></p>
<p><a href="http://daymoframework.files.wordpress.com/2010/06/picture-191.png"><img class="alignnone size-full wp-image-78" title="Picture 191" src="http://daymoframework.files.wordpress.com/2010/06/picture-191.png?w=594" alt=""   /></a></p>
<p>There is no limit to the levels of nesting. DragDropManager.resolveTarget keeps iterating up until it either reaches the root level or an object of &#8220;Interface A&#8221;.</p>
<p>So when we look at this code in the DragHandler:</p>
<pre>public class <span style="color:#0000ff;">DragHandler</span> implements <span style="color:#ff0000;">IDraggable</span> {

 public function <span style="color:#0000ff;">onStartDragClick</span>(event : MouseEvent) : void
 {
    <span style="color:#008000;">// Find out who we are dragging
</span>    var <span style="color:#0000ff;">dragObj</span>:<span style="color:#ff0000;">IDragObjectInterface</span> =
         DragDropManager.<span style="color:#0000ff;">resolveTarget</span>(
             event.<span style="color:#0000ff;">target</span>, <span style="color:#ff0000;">IDragObjectInterface</span>
         ) ;

    trace("dragging :"+<span style="color:#0000ff;">dragObj</span>.name);
    <span style="color:#008000;">// Removed code</span>
 }
}</pre>
<p>we know exactly what object or value (null when not found) we can expect from resolveTarget.</p>
<h2>Defining which drag-objects you support</h2>
<p>The easiest way to define which drag objects you support is by checking if the object put into DragDropManager.dataObject:</p>
<ol>
<li> Is of a specific class.</li>
<li>Contains a specific value</li>
</ol>
<pre><span style="color:#008000;">// Example of checking what is in the
// DragDropManager.dataObject</span>
if(DragDropManager.<span style="color:#0000ff;">dataObject</span> is <span style="color:#ff0000;">MyClass</span>)
{
   <span style="color:#008000;">// Do something</span>
}

<span style="color:#008000;">// Alternative: checking content of dataObject</span>
var <span style="color:#0000ff;">myObject</span>:<span style="color:#000000;">MyObject</span>=MyObject(DragDropManager.<span style="color:#0000ff;">dataObject</span>);
if(<span style="color:#0000ff;">myObject</span>.name=="<span style="color:#ff0000;">Peter</span>")
{
   <span style="color:#008000;">// Do something</span>
}</pre>
<h2>Manipulating the drop-Objects</h2>
<p>When you start and stop dragging, the DragDropManager notifies each DropHandler via an event.</p>
<p>The functions called are:</p>
<ol>
<li><strong>dragStartHandler</strong> &#8211; called when a drag object is picked up</li>
<li><strong>dragStopHandler</strong> &#8211; called when a drag object is dropped</li>
</ol>
<p>You can use the dragStartHandler and dragStopHandler to:</p>
<ol>
<li>Grey out or hide all droppable objects which should not accept that specific drag object</li>
<li>Show all hidden or greyed out objects when the drag object is dropped.</li>
</ol>
<p>In this example we will hide our drop-object when the data-object is not of type DragDropObject</p>
<pre><span style="color:#008000;">// DROPHANDLER

// Is set by the code that created the drop object
// and the DropHandler</span>
var <span style="color:#ff0000;">dropObject</span>:myDropObject;

public function <span style="color:#0000ff;">dragStartHandler</span>(e:DragDropEvent)
{
   if(DragDropManager.<span style="color:#0000ff;">dataObject</span> is <span style="color:#ff0000;">DragDropObject</span>)
   {
      <span style="color:#008000;">// Do nothing</span>
   }
   else
   {
      <span style="color:#008000;">// Hide our droppable object</span>
      <span style="color:#0000ff;">dropObject</span>.visible=false;
   }
}
public function <span style="color:#0000ff;">dragStopHandler</span>(e:DragDropEvent)
{
   <span style="color:#008000;">// Show our droppable object</span>
   <span style="color:#0000ff;">dropObject</span>.visible=true;
}</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/daymoframework.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/daymoframework.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/daymoframework.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/daymoframework.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/daymoframework.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/daymoframework.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/daymoframework.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/daymoframework.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/daymoframework.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/daymoframework.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/daymoframework.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/daymoframework.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/daymoframework.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/daymoframework.wordpress.com/74/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daymoframework.wordpress.com&amp;blog=13960036&amp;post=74&amp;subd=daymoframework&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://daymoframework.wordpress.com/2010/06/05/the-daymo-drag-and-drop-handler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cffc2ff7b980a5f5f76c22bddba4f361?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">peter kaptein</media:title>
		</media:content>

		<media:content url="http://daymoframework.files.wordpress.com/2010/06/picture-1891.png" medium="image">
			<media:title type="html">Picture 189</media:title>
		</media:content>

		<media:content url="http://daymoframework.files.wordpress.com/2010/06/picture-190.png?w=300" medium="image">
			<media:title type="html">Picture 190</media:title>
		</media:content>

		<media:content url="http://daymoframework.files.wordpress.com/2010/06/picture-191.png" medium="image">
			<media:title type="html">Picture 191</media:title>
		</media:content>
	</item>
		<item>
		<title>Why I created Daymo</title>
		<link>http://daymoframework.wordpress.com/2010/05/31/hello-world/</link>
		<comments>http://daymoframework.wordpress.com/2010/05/31/hello-world/#comments</comments>
		<pubDate>Mon, 31 May 2010 19:54:10 +0000</pubDate>
		<dc:creator>Peter Kaptein</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://daymoframework.wordpress.com/?p=1</guid>
		<description><![CDATA[To do Inversion of Control, you do not need Swiz or Robotlegs. In most cases, you have very likely already been doing it in AS3 without knowing it - for instance - by using object references you "inject" into another object using code, by building singletons to share data over your project, by doing some Kung Fu with Static  functions and doing some Black Scroll Ninja Style Event Dispatching to tell other objects something has happened.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daymoframework.wordpress.com&amp;blog=13960036&amp;post=1&amp;subd=daymoframework&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>Author: Peter Kaptein</em></p>
<p>I like the coding principles and design patterns Swiz (and Robotlegs) uses. I do not like the way Swiz adds another layer of complexity and non-tracable abstraction on top of Flex, without explaining in a clear and simple way what is going on or giving you proper instructions on how to use it.</p>
<p>Another reason not to like Swiz is that object references &#8211; used for instance in autowiring &#8211; are String based instead of being real references. Which can become a real pain when you refactor your project.</p>
<h2>Why I created Daymo</h2>
<p>To do Inversion of Control, you do not need Swiz or Robotlegs. In most cases, you have very likely already been doing it in AS3 without knowing it &#8211; for instance &#8211; by using object references you &#8220;inject&#8221; into another object using code, by building singletons to share data over your project, by doing some Kung Fu with Static  functions and doing some Black Scroll Ninja Style Event Dispatching to tell other objects something has happened.</p>
<p>Based on those  I created Daymo.</p>
<ol>
<li><strong>It is 100% ActionScript</strong> &#8211; which means that (via the editor):
<ol>
<li><strong>Object Dependencies</strong> in binding patterns can easily be tracked (which is not the case with Swiz and Robotlegs as object references are passed as String values)</li>
<li><strong>Broken dependencies </strong>- due to i.e. refactoring &#8211; can easily be found</li>
</ol>
</li>
<li>It <strong>shows</strong> you what <em>you</em> are <strong>doing</strong> and offers clear backgrounds on what <em>Daymo</em> is doing.</li>
<li>It <strong>helps</strong> you <strong>binding</strong> Objects and Object variables with a few simple lines of code</li>
<li>It <strong>offers</strong> you an <strong>array of nifty tips and tricks</strong> to:
<ol>
<li><strong>Reduce code</strong> on all kind of issues</li>
<li><strong>Simplify</strong> <strong>coding</strong> of complex Interaction Structures<strong></strong></li>
<li><strong>Refactor</strong> and <strong>restructure</strong> your project <strong>without breaking</strong> it that much (it will always break a bit)</li>
</ol>
</li>
</ol>
<h2>Will following the Next New Black help you?</h2>
<p>I have done a lot of projects in the past 10 years, including cleaning up the mess of others. I also built several Frameworks to auto-generate code form databases and generate Flash-sites from XHTML definitions.</p>
<p>Looking at the Design Patterns available, I have seen ways to do it and ways to completely fuck it up. (My own work included.)</p>
<p>With Daymo I have tried to pin this down by also offering a clear structure and a set of rules and tools on:</p>
<ol>
<li><strong>Where to put what</strong> (organization of code and Separation of Responsibilities)</li>
<li>How objects <strong>communicate</strong> (read about Global Events, Drag and Drop and the article about &#8220;Daymo State Machines and Events&#8221;)</li>
<li>How you can <strong>extend functionalities</strong> of an <strong>object</strong> and do that in a flexible way (read i.e. about State Machines and about Autowiring in the &#8220;About&#8221; page)</li>
</ol>
<p>The main approach I use is that any code and any application is like an organization of people: with responsibilities, working together in departments or multidisciplinary teams trying to get the work done.</p>
<p>The main rules I use and used are: keep it clear and simple,  get it right when it feels wrong, dig deeper if things seem unclear, cut the overhead where possible, use whatever methods that get you there faster with better results and you will already get very far.</p>
<p>Sometimes this comes with a price. Autowiring for instance opens a totally new way to distribute variables and objects through your project, reduces your coding dramatically when you bind objects, but also takes way more CPU cycles to execute. In other words: when you use it EVERYWHERE (especially binding MVC structures for list items) it will kill your application.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/daymoframework.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/daymoframework.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/daymoframework.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/daymoframework.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/daymoframework.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/daymoframework.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/daymoframework.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/daymoframework.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/daymoframework.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/daymoframework.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/daymoframework.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/daymoframework.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/daymoframework.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/daymoframework.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daymoframework.wordpress.com&amp;blog=13960036&amp;post=1&amp;subd=daymoframework&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://daymoframework.wordpress.com/2010/05/31/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cffc2ff7b980a5f5f76c22bddba4f361?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">peter kaptein</media:title>
		</media:content>
	</item>
	</channel>
</rss>
