<?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/"
	>

<channel>
	<title>Mendix &#124; Next-generation Business Applications Made Easy &#187; mdd</title>
	<atom:link href="http://www.mendix.com/tag/mdd/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mendix.com</link>
	<description></description>
	<lastBuildDate>Fri, 03 Feb 2012 18:26:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Interview Mendix CEO in Business Process Magazine</title>
		<link>http://www.mendix.com/blog/interview-mendix-ceo-in-business-process-magazine/</link>
		<comments>http://www.mendix.com/blog/interview-mendix-ceo-in-business-process-magazine/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 14:25:06 +0000</pubDate>
		<dc:creator>Derek Roos</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[mdd]]></category>
		<category><![CDATA[Modelling]]></category>

		<guid isPermaLink="false">https://www.mendix.com/?p=444</guid>
		<description><![CDATA[online]]></description>
			<content:encoded><![CDATA[<p><span lang="EN-US">This month’s edition of Business Process Magazine published an extensive interview with Mendix Mendix CEO Derek Roos. In the article Roos gives insight in Mendix’ vision on model-driven application development and process-centric business automation. He also sheds light on Mendix strategy and product roadmap.</span></p>
<div class="wp-caption alignnone" style="width: 160px"><a href="https://www.mendix.com/wordpress/wp-content/uploads/2009/06/Artikel_Derek_BPM.pdf"><img class=" " title="BPM cover" src="http://farm4.static.flickr.com/3448/4072306370_df33d00fd7_m.jpg" alt="*Please note article is in Dutch only" width="150" height="150" /></a><p class="wp-caption-text">*Please note article is in Dutch only</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.mendix.com/blog/interview-mendix-ceo-in-business-process-magazine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mendix Campus program at TU Twente great success. And the winner is…</title>
		<link>http://www.mendix.com/blog/mendix-campus-program-at-tu-twente-great-success-and-the-winner-is%e2%80%a6/</link>
		<comments>http://www.mendix.com/blog/mendix-campus-program-at-tu-twente-great-success-and-the-winner-is%e2%80%a6/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 14:25:47 +0000</pubDate>
		<dc:creator>Derek Roos</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[agile development]]></category>
		<category><![CDATA[mdd]]></category>
		<category><![CDATA[Mendix On Campus]]></category>
		<category><![CDATA[University of twente]]></category>

		<guid isPermaLink="false">https://www.mendix.com/?p=447</guid>
		<description><![CDATA[Rotterdam, The Netherlands]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">Over the last few weeks, a class of bachelor students from Technical University Twente completed the course “Business Information Systems” for which they had to work in 5 small, agile teams to build a working business application using Mendix.  Each team could pick from a list of real-life cases and model a fullfledged application “from scratch” in only a few weeks. After completion the teacher graded all projects and awarded the best application with an A (or in Dutch equivalent: 10 out of 10)!</p>
<p style="text-align: left;"><strong>And the winning team is: </strong></p>
<p style="text-align: left;">… Dennis Pallet and Allard Brand with their Mendix implementation of the “University Enrollment Case”.</p>
<p>Congratulations guys!! Well done! Below is an summary of the jury report:</p>
<p style="text-align: left;"><em>The University enrollment case is the most complete project for several reasons. First of all, the project was correctly modeled; the project contains several validations, delete behaviour was set and they clearly used the Mendix Modeling conventions. The group was able to make use of webservices to streamline the enrollment process. Further, by calling a Java action, they made it possible to generate passwords given that it requires anonymous access. This realistic approach is supported by both admin interfaces and student interfaces. The group also worked out the idea of sending a welcome email to University’s new applicants. Most important, this University enrollment case reduces lots of manual work, processes are more efficient and the simple sign-up process is user friendly.</em></p>
<p style="text-align: left;"><em></p>
<div class="wp-caption alignnone" style="width: 250px"><em><a href="http://www.flickr.com/photos/mendix/"><img title="Mendix On Campus" src="http://farm3.static.flickr.com/2753/4071554669_d9611e239e_m.jpg" alt="Proud-looking Dennis Pallet and Allard Brand" width="240" height="180" /></a></em><p class="wp-caption-text">Proud-looking Dennis Pallet and Allard Brand</p></div>
<p>
</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mendix.com/blog/mendix-campus-program-at-tu-twente-great-success-and-the-winner-is%e2%80%a6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mendix Campus program at TU Twente great success. And the winner is…</title>
		<link>http://www.mendix.com/blog/mendix-campus-program-at-tu-twente-great-success-and-the-winner-is%e2%80%a6/</link>
		<comments>http://www.mendix.com/blog/mendix-campus-program-at-tu-twente-great-success-and-the-winner-is%e2%80%a6/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 14:25:47 +0000</pubDate>
		<dc:creator>Derek Roos</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[agile development]]></category>
		<category><![CDATA[mdd]]></category>
		<category><![CDATA[Mendix On Campus]]></category>
		<category><![CDATA[University of twente]]></category>

		<guid isPermaLink="false">https://www.mendix.com/?p=447</guid>
		<description><![CDATA[Rotterdam, The Netherlands]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">Over the last few weeks, a class of bachelor students from Technical University Twente completed the course “Business Information Systems” for which they had to work in 5 small, agile teams to build a working business application using Mendix.  Each team could pick from a list of real-life cases and model a fullfledged application “from scratch” in only a few weeks. After completion the teacher graded all projects and awarded the best application with an A (or in Dutch equivalent: 10 out of 10)!</p>
<p style="text-align: left;"><strong>And the winning team is: </strong></p>
<p style="text-align: left;">… Dennis Pallet and Allard Brand with their Mendix implementation of the “University Enrollment Case”.</p>
<p>Congratulations guys!! Well done! Below is an summary of the jury report:</p>
<p style="text-align: left;"><em>The University enrollment case is the most complete project for several reasons. First of all, the project was correctly modeled; the project contains several validations, delete behaviour was set and they clearly used the Mendix Modeling conventions. The group was able to make use of webservices to streamline the enrollment process. Further, by calling a Java action, they made it possible to generate passwords given that it requires anonymous access. This realistic approach is supported by both admin interfaces and student interfaces. The group also worked out the idea of sending a welcome email to University’s new applicants. Most important, this University enrollment case reduces lots of manual work, processes are more efficient and the simple sign-up process is user friendly.</em></p>
<p style="text-align: left;"><em></p>
<div class="wp-caption alignnone" style="width: 250px"><em><a href="http://www.flickr.com/photos/mendix/"><img title="Mendix On Campus" src="http://farm3.static.flickr.com/2753/4071554669_d9611e239e_m.jpg" alt="Proud-looking Dennis Pallet and Allard Brand" width="240" height="180" /></a></em><p class="wp-caption-text">Proud-looking Dennis Pallet and Allard Brand</p></div>
<p>
</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mendix.com/blog/mendix-campus-program-at-tu-twente-great-success-and-the-winner-is%e2%80%a6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TechCrunch about Mendix</title>
		<link>http://www.mendix.com/blog/techcrunch-about-mendix/</link>
		<comments>http://www.mendix.com/blog/techcrunch-about-mendix/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 14:27:56 +0000</pubDate>
		<dc:creator>Derek Roos</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Agile software development]]></category>
		<category><![CDATA[mdd]]></category>
		<category><![CDATA[Portals]]></category>
		<category><![CDATA[Techcrunch]]></category>

		<guid isPermaLink="false">https://www.mendix.com/?p=451</guid>
		<description><![CDATA[Rotterdam, The Netherlands]]></description>
			<content:encoded><![CDATA[<div>
<p>Leading techblog covers Mendix.</p>
<p>Check out the article <a href="http://www.techcrunchit.com/2009/04/08/mendix-helps-enterprises-streamline-application-deployment/">here</a>.</p>
<p><a href="http://www.techcrunchit.com/2009/04/08/mendix-helps-enterprises-streamline-application-deployment/"><br />
 </a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.mendix.com/blog/techcrunch-about-mendix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mendix listed as a Cool Vendor in Gartner report</title>
		<link>http://www.mendix.com/blog/mendix-gartner-cool-vendor/</link>
		<comments>http://www.mendix.com/blog/mendix-gartner-cool-vendor/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 16:14:52 +0000</pubDate>
		<dc:creator>Derek Roos</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[cool vendor]]></category>
		<category><![CDATA[dsl]]></category>
		<category><![CDATA[Gartner]]></category>
		<category><![CDATA[mdd]]></category>
		<category><![CDATA[recognition]]></category>

		<guid isPermaLink="false">https://www.mendix.com/?p=595</guid>
		<description><![CDATA[<div>
<p>We are proud! Mendix has just been listed “Cool Vendor” by industry research firm Gartner in the category “Cool Vendors in Application Development, New Tools, 2009″ published on March 30th. We see this as Gartner´s recognition of our vision, innovations and success as a team!</p>
<p>Gartner defines a “Cool Vendor” as a company that offers technologies or solutions that are:</p>
<ol>
<li><strong>Innovative</strong>: enable users to do things they couldn’t do before;</li>
<li><strong>Impactful</strong>: have, or will have, business impact (not just technology for the sake of technology);</li>
<li><strong>Intriguing</strong>: have caught Gartner’s interest or curiosity within approximately the past six months.</li>
</ol>
</div>
<div>
<p>The report notes that, “As development projects and processes deal with complex business problems and large quantities of information, the translation of the business need into a tangible design addresses a major source of project failure and are at the root of many development project horror stories.”</p>
<p>According to Gartner, “Development managers and business analysts should develop new methods for successfully deploying applications built with newer, more-complex tools and processes”.</p>
<p>In the report, Gartner selected vendors that have “cool” approaches to application development, and, specifically, the management, specification and quality delivery of complex development projects.</p>
<p>Note: We</p></div><p>&#8230;</p>]]></description>
			<content:encoded><![CDATA[<div>
<p>We are proud! Mendix has just been listed “Cool Vendor” by industry research firm Gartner in the category “Cool Vendors in Application Development, New Tools, 2009″ published on March 30th. We see this as Gartner´s recognition of our vision, innovations and success as a team!</p>
<p>Gartner defines a “Cool Vendor” as a company that offers technologies or solutions that are:</p>
<ol>
<li><strong>Innovative</strong>: enable users to do things they couldn’t do before;</li>
<li><strong>Impactful</strong>: have, or will have, business impact (not just technology for the sake of technology);</li>
<li><strong>Intriguing</strong>: have caught Gartner’s interest or curiosity within approximately the past six months.</li>
</ol>
</div>
<div>
<p>The report notes that, “As development projects and processes deal with complex business problems and large quantities of information, the translation of the business need into a tangible design addresses a major source of project failure and are at the root of many development project horror stories.”</p>
<p>According to Gartner, “Development managers and business analysts should develop new methods for successfully deploying applications built with newer, more-complex tools and processes”.</p>
<p>In the report, Gartner selected vendors that have “cool” approaches to application development, and, specifically, the management, specification and quality delivery of complex development projects.</p>
<p>Note: We can’t publish the entire report here, but go the <a href="http://www.gartner.com/">Gartner</a> website to find it (search for ‘mendix’). Analysis was done by research director David Norton.</p>
<p><strong><span style="font-size: small;">Disclaimer about Gartner&#8217;s Cool Vendor Selection Process</span></strong></p>
<p><span style="font-size: small;"><strong> </strong>Gartner&#8217;s listing does not constitute an exhaustive list of vendors in any given technology area, but rather is designed to highlight interesting, new and innovative vendors, products and services. Gartner disclaims all warranties, expressed or implied, with respect to this research, including any warranties of merchantability or fitness of a particular purpose. Gartner defines a cool vendor as a company that offers technologies or solutions that are: Innovative, enable users to do things they couldn&#8217;t do before; Impactful, have, or will have, business impact (not just technology for the sake of technology); Intriguing, have caught Gartner&#8217;s interest or curiosity in approximately the past six months.</span></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.mendix.com/blog/mendix-gartner-cool-vendor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mendix &amp; Centric @ J-Fall 2008</title>
		<link>http://www.mendix.com/blog/mendix-centric-j-fall-2008/</link>
		<comments>http://www.mendix.com/blog/mendix-centric-j-fall-2008/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 15:25:54 +0000</pubDate>
		<dc:creator>Derek Roos</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[mdd]]></category>

		<guid isPermaLink="false">https://www.mendix.com/?p=950</guid>
		<description><![CDATA[<div>
<p>On J-Fall 2008 Mendix and Centric teamed by jointly exhibiting at another successful Java conference organized by the NLJUG. J-Fall proved a great event to get in touch with the Java community and to demonstrate the Mendix platform in front of a live audience.</p>
<p>See you again at J-Spring 2009!</p>
<div id="attachment_128" style="width: 310px;"><a href="http://blog.mendix.com/wp-content/uploads/2008/12/j-fall-121108-15.jpg"><img title="j-fall-121108-15" src="http://blog.mendix.com/wp-content/uploads/2008/12/j-fall-121108-15-300x225.jpg" alt="The Mendix &#38; Centric booth" width="300" height="225" /></a></p>
<p>The Mendix &#38; Centric booth</p>
</div>
<div id="attachment_129" style="width: 235px;"><a href="http://blog.mendix.com/wp-content/uploads/2008/12/j-fall-121108-3.jpg"><img title="j-fall-121108-3" src="http://blog.mendix.com/wp-content/uploads/2008/12/j-fall-121108-3-225x300.jpg" alt="Johan den Haan explains" width="225" height="300" /></a></p>
<p>Johan den Haan explains</p>
</div>
</div>
]]></description>
			<content:encoded><![CDATA[<div>
<p>On J-Fall 2008 Mendix and Centric teamed by jointly exhibiting at another successful Java conference organized by the NLJUG. J-Fall proved a great event to get in touch with the Java community and to demonstrate the Mendix platform in front of a live audience.</p>
<p>See you again at J-Spring 2009!</p>
<div id="attachment_128" style="width: 310px;"><a href="http://blog.mendix.com/wp-content/uploads/2008/12/j-fall-121108-15.jpg"><img title="j-fall-121108-15" src="http://blog.mendix.com/wp-content/uploads/2008/12/j-fall-121108-15-300x225.jpg" alt="The Mendix &amp; Centric booth" width="300" height="225" /></a></p>
<p>The Mendix &amp; Centric booth</p>
</div>
<div id="attachment_129" style="width: 235px;"><a href="http://blog.mendix.com/wp-content/uploads/2008/12/j-fall-121108-3.jpg"><img title="j-fall-121108-3" src="http://blog.mendix.com/wp-content/uploads/2008/12/j-fall-121108-3-225x300.jpg" alt="Johan den Haan explains" width="225" height="300" /></a></p>
<p>Johan den Haan explains</p>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.mendix.com/blog/mendix-centric-j-fall-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ajax security perception</title>
		<link>http://www.mendix.com/blog/ajax-security-perception/</link>
		<comments>http://www.mendix.com/blog/ajax-security-perception/#comments</comments>
		<pubDate>Fri, 19 Jan 2007 15:55:45 +0000</pubDate>
		<dc:creator>Derek Roos</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[mdd]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">https://www.mendix.com/?p=993</guid>
		<description><![CDATA[<div>
<p>It seems like a month doesn’t go by without a new whitepaper detailing interesting new ways to maliciously apply JavaScript comes out. And this is fine. The problem I have is not with the papers themselves (I enjoy reading them &#8211; a lot of novel code appears there) but rather, how the media picks them up. Sure, ‘AJAX is insecure’ makes for clickable headlines, but it’s bad reporting.</p>
<p>When a security issue is reported the first thing that is relevant is discovering whether this is an implementation bug or an architectural flaw. Implementation bugs are fairly trivial to fix (but might have a lot of short-term impact). Architectural flaws are big time trouble.</p>
<p>Ajax security issues tend to fall into neither category. In fact, they usually are not even Ajax security issues. At all.</p>
<p>These issues generally focus on the interesting things you can accomplish as an attacker once you have already breached security by performing a form on how of malicious code injection.</p>
<p>There is nothing inherently insecure about Ajax applications. Their security (or insecurity) depends entirely on how the service provider manages the content delivered to the client.</p>
<p>So the Ajax security alerts don’t really tell us</p></div><p>&#8230;</p>]]></description>
			<content:encoded><![CDATA[<div>
<p>It seems like a month doesn’t go by without a new whitepaper detailing interesting new ways to maliciously apply JavaScript comes out. And this is fine. The problem I have is not with the papers themselves (I enjoy reading them &#8211; a lot of novel code appears there) but rather, how the media picks them up. Sure, ‘AJAX is insecure’ makes for clickable headlines, but it’s bad reporting.</p>
<p>When a security issue is reported the first thing that is relevant is discovering whether this is an implementation bug or an architectural flaw. Implementation bugs are fairly trivial to fix (but might have a lot of short-term impact). Architectural flaws are big time trouble.</p>
<p>Ajax security issues tend to fall into neither category. In fact, they usually are not even Ajax security issues. At all.</p>
<p>These issues generally focus on the interesting things you can accomplish as an attacker once you have already breached security by performing a form on how of malicious code injection.</p>
<p>There is nothing inherently insecure about Ajax applications. Their security (or insecurity) depends entirely on how the service provider manages the content delivered to the client.</p>
<p>So the Ajax security alerts don’t really tell us anything about Ajax security in itself. It is by now a well-established maxim in the security community that once an attacker manages to execute arbitrary code on your computer &#8211; it’s not your computer anymore. Why would anyone assume the rules have changed because the web jumped up a number in the media?</p>
<p>As an attacker, if you manage to inject your code into a page you can pretty much go hog-wild with the user session. But this is nothing new. For Ajax security the surface area available for attacks is fairly limited. Once you circumvent that the sky’s the limit, of course. There are any number of ways in which it is possible to get around the single domain policy found in all modern browsers. Some of these have even become a de-facto standard for Ajax developers and have lead to comments stating that such policies are pointless (I respectfully disagree here, but more on that later).</p>
<p>The content provider has a trusted role. A function of that role is to sanitize the content. LISP programmers and security programmers have been comfortable with the idea that code equals data and vice versa for a long time. This is for others a rather novel concept, but it’s high time everybody else caught up.</p>
<p>And shifting blame on end-users (a popular activity in the IT world) is simply not acceptable. As developers we have to shield end-users from technological complexity. This includes security. When people use our applications they implicitly trust us. As technology developers we have to honour that trust.</p>
<p>It makes for some interesting food for thought.</p>
<p>The bottom line is that security is hard and we can’t expect end-users to ever comprehend the complexities involved. So dumping security resonsibility on end-users is fairly stupid.</p>
<p>It’s up to us to write decent systems.</p>
</div>
<div>
<p>You can follow any responses to this entry through the <a href="http://blog.mendix.com/?feed=rss2&amp;p=8">RSS 2.0</a> feed.  													You can <a href="http://blog.mendix.com/?p=8#respond">leave a response</a>, or <a rel="trackback" href="http://blog.mendix.com/wp-trackback.php?p=8">trackback</a> from your own site.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.mendix.com/blog/ajax-security-perception/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fun with JavaScript Functions</title>
		<link>http://www.mendix.com/blog/fun-with-javascript-functions/</link>
		<comments>http://www.mendix.com/blog/fun-with-javascript-functions/#comments</comments>
		<pubDate>Wed, 10 Jan 2007 15:56:42 +0000</pubDate>
		<dc:creator>Michiel Kalkman</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[mdd]]></category>

		<guid isPermaLink="false">https://www.mendix.com/?p=995</guid>
		<description><![CDATA[<div>
<p>Let’s take a shot at controlling the order of execution of synchronous and asynchronous functions in JavaScript.</p>
<p>If you want to play along instead of just reading passively, fire up a <a href="http://www.squarefree.com/shell/shell.html">JavaScript Shell</a> and copy/paste all code directly into it.</p>
<p>We’ll start off with everyone’s favorite annoyance. Popup alerts.</p>
<p><code> </code></p>
<pre>var sayA = function() {
  alert("a");
}
var sayB = function() {
   alert("b");
}
</pre>
<p><br class="spacer_" /></p>
<p>So, let’s say we want to run those in order. First <code>sayA</code>, then <code>sayB</code> and then <code>sayA</code> again.</p>
<p><br class="spacer_" /></p>
<pre>var funcArray = [sayA, sayB, sayA];
for (var i=0;i&#60;funcArray.length;i++) {
  funcArray[i]();
}
</pre>
<p>Nice and cuddly. But that is, of course, no fun at all. Time to start making this a little more interesting.</p>
<p>Let’s pretend we want to grab a random number from an asynchronous request.</p>
<p><code> </code></p>
<pre>var asyncGetNumber = function(request) {
  window.setTimeout(
    function() { request.handler(Math.floor(Math.random()*16)); }
    , 500);
}
</pre>
<p><br class="spacer_" /></p>
<p>And let’s have a say function that alerts the returned value..</p>
<p><code> </code></p>
<pre>sayRandom = function() {
  var request = {
     handler: function(n) {
       alert(n);
     }
  };
  asyncGetNumber(request);
}
</pre>
<p><br class="spacer_" /></p>
<p>And before we start repeating ourselves, let’s have a function that runs functions for us.</p>
<p><code> </code></p></div><p>&#8230;</p>]]></description>
			<content:encoded><![CDATA[<div>
<p>Let’s take a shot at controlling the order of execution of synchronous and asynchronous functions in JavaScript.</p>
<p>If you want to play along instead of just reading passively, fire up a <a href="http://www.squarefree.com/shell/shell.html">JavaScript Shell</a> and copy/paste all code directly into it.</p>
<p>We’ll start off with everyone’s favorite annoyance. Popup alerts.</p>
<p><code> </code></p>
<pre>var sayA = function() {
  alert("a");
}
var sayB = function() {
   alert("b");
}
</pre>
<p><br class="spacer_" /></p>
<p>So, let’s say we want to run those in order. First <code>sayA</code>, then <code>sayB</code> and then <code>sayA</code> again.</p>
<p><br class="spacer_" /></p>
<pre>var funcArray = [sayA, sayB, sayA];
for (var i=0;i&lt;funcArray.length;i++) {
  funcArray[i]();
}
</pre>
<p>Nice and cuddly. But that is, of course, no fun at all. Time to start making this a little more interesting.</p>
<p>Let’s pretend we want to grab a random number from an asynchronous request.</p>
<p><code> </code></p>
<pre>var asyncGetNumber = function(request) {
  window.setTimeout(
    function() { request.handler(Math.floor(Math.random()*16)); }
    , 500);
}
</pre>
<p><br class="spacer_" /></p>
<p>And let’s have a say function that alerts the returned value..</p>
<p><code> </code></p>
<pre>sayRandom = function() {
  var request = {
     handler: function(n) {
       alert(n);
     }
  };
  asyncGetNumber(request);
}
</pre>
<p><br class="spacer_" /></p>
<p>And before we start repeating ourselves, let’s have a function that runs functions for us.</p>
<p><code> </code></p>
<pre>var sequence = function(funcArray) {
  for (var i=0;i&lt;funcArray.length;i++) {
    funcArray[i]();
  }
}
</pre>
<p>Now, let’s rock!</p>
<p><code> </code></p>
<pre>sequence([sayRandom,sayA,sayB]);
</pre>
<p>Oops. Notice what happened? Our alerts in order were “a”, “b” and here in my case “5″. Not the order we wanted.</p>
<p>As the handler function in <code>asyncGetNumber</code> falls outside of the execution sequence, we can’t control the execution order. Time to change that. Enter <em>action sequences(tm)</em> (get yours free with an extra large order of fries).</p>
<p>Now we’re going to use a few features of JavaScript that are generally speaking less well understood than, say, <code>alert</code>.</p>
<p>We’re going to create and pass around functions on the fly. First we re-write <code>sayA</code>, <code>sayB</code> and <code>sayRandom</code> to accept a <em>handler</em> parameter. This is basically a function that it’ll call when it’s done doing whatever it does. (How’s that for non-specific?)</p>
<p>For <code>sayA</code> and <code>sayB</code> this is pretty trivial.</p>
<p><code> </code></p>
<pre>var sayA = function(handler) {
  alert("a");
  handler &amp;&amp; handler();
};
 var sayB = function(handler) {
    alert("b");
   handler &amp;&amp; handler();
};
</pre>
<p>Not very spectacular, right? Don’t worry &#8211; we’re not there yet.</p>
<p>A detail to note is the use of,<br />
 <code> </code></p>
<pre>   handler &amp;&amp; handler();
</pre>
<p>The <code>&amp;&amp;</code> works as a guard operator, giving these functions the new <em>handler</em> functionality if a parameter is passed (by executing it), but otherwise operating exactly as they did before.</p>
<p><code> </code></p>
<pre>sayRandom = function(handler) {
  var request = {
     handler: function(n) {
       alert(n);
       handler &amp;&amp; handler();
    }
  };
  asyncGetNumber(request);
}
</pre>
<p><br class="spacer_" /></p>
<p>The handler parameter is available in the local scope, which includes the scope of the function found at the handler key of the request object. So when request.handler is executed, the handler parameter passed to <code>sayRandom</code> is available to it.And now we re-write <code>sequence</code> as follows,</p>
<p><code> </code></p>
<pre>var sequence = function(funcArray) {
    // runFunctions is a function that takes the first element of the funcArray
    // and executes it with *itself* as the parameter
    var runFunctions = function() {
      // If there is anything left in the Array
      if (funcArray.length != 0) {
       // Take it out and assign it to a local variable
       var latestFunction = funcArray.shift();
       // Execute it and call with ourself
      latestFunction(runFunctions);
    }
  }
   // Now run it.
  runFunctions();
};
sequence([sayRandom,sayA,sayB]);
</pre>
<p>Voila. Sequenced actions.<br />
 It still looks a little crufty, though.<br />
 Let’s clean that up a little. For this we’ll use two aspects of functions in JavaScript. The first being that we can anonymously define and evaluate a function on the fly. The second being that a function in JavaScript can refer to itself, using the local variable <code>arguments.callee</code>.</p>
<p>We’ll use these to create a new local scope that can be referred to with <code>arguments.callee</code>, but which has access to the <code>funcArray</code> parameter passed to sequence.</p>
<p>A direct evaluation looks like this,</p>
<p><code> </code></p>
<pre>(function(){
  alert("How you doin'?");
})();
</pre>
<p>And combining this with <code>arguments.callee</code> allows you to quickly and efficiently shoot yourself in the foot by blowing up your stack ..</p>
<p><code> </code></p>
<pre>(function(){ arguments.callee(); })(); // Keep calling ourselves
</pre>
<p>Now, applying this to a re-write of <code>sequence</code>..</p>
<p><code> </code></p>
<pre>var sequence = function(funcArray) {
   (function() {
     (funcArray.length != 0) &amp;&amp;
       funcArray.shift()(arguments.callee);
  })();
};
</pre>
<p>Much more elegant. Now, let’s use that to get 10 random numbers.</p>
<p><code> </code></p>
<pre>var actions = [];
for (var i=0; i&lt;10; i++) {
  actions.push(sayRandom);
}
sequence(actions);
</pre>
<p>10 random numbers in 5 seconds, if you click really fast.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.mendix.com/blog/fun-with-javascript-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

