<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-5211228043243414701</atom:id><lastBuildDate>Sun, 29 Jan 2012 12:49:44 +0000</lastBuildDate><category>Personal</category><category>AOP</category><category>Web dev</category><category>J2ME</category><category>Visual Studio</category><category>GWT</category><category>Microsoft</category><category>MVC</category><category>Antipatterns</category><category>HowTo</category><category>.Net</category><category>Apple</category><category>Exploring JavaScript</category><category>C++</category><category>Software Design</category><category>Projects</category><category>Mac</category><category>iOS</category><category>Spring</category><category>Clean Code</category><category>Windows OS</category><category>Android</category><category>Unit Testing</category><category>Design Patterns</category><category>jQuery</category><category>Smelly Code</category><category>refactoring</category><category>jFace</category><category>interesting apps</category><category>Software testing</category><category>martial arts</category><category>Software Architecture</category><category>Java</category><category>OSX</category><category>Best Practices</category><category>Google</category><category>Blogging</category><category>C#</category><category>VBA</category><category>RCP</category><category>iPhone</category><category>WCF</category><category>Linux</category><category>mobile dev</category><category>Eclipse</category><category>functional programming</category><category>lessions learned</category><category>annotated</category><category>webclips</category><category>Agile Development</category><category>JavaScript</category><category>Tech vids</category><category>ASP.net</category><category>Entity Framework</category><category>Silverlight</category><title>Juri's TechBlog</title><description>Software Architectures, Web Technologies, Computer Science, Best Practices...</description><link>http://blog.js-development.com/</link><managingEditor>noreply@blogger.com (Juri Strumpflohner)</managingEditor><generator>Blogger</generator><openSearch:totalResults>393</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/juristrumpflohner" /><feedburner:info uri="juristrumpflohner" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5211228043243414701.post-5059761824188875200</guid><pubDate>Mon, 23 Jan 2012 07:50:00 +0000</pubDate><atom:updated>2012-01-23T08:50:36.557+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Eclipse</category><title>Eclipse: Importing existing project: "Invalid project description"</title><description>&lt;div class="intro"&gt;
Monday morning, 07:30 AM. Me, starting the computer after the weekend, executing a &lt;code&gt;git pull&lt;/code&gt; from &lt;a href="http://blog.js-development.com/2010/11/juri-goes-git-first-steps.html" target="_blank"&gt;my repository&lt;/a&gt;&amp;nbsp;to fetch the latest src. Then I opened my freshly installed Eclipse JavaScript version followed by a nice "Import existing project" (I pushed the project on my Mac previously) on the just fetched git repository. Fail.&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;/div&gt;
&lt;blockquote&gt;
Invalid project description
&lt;/blockquote&gt;
Damn. My first thought was a potential incompatibility, given that the project was created on my Mac previously, and I just tried to import it on Win7.&lt;br /&gt;
So if you should encounter a similar problem try the following. Assume you pulled the repository into &lt;code&gt;C:\gitrepo\mygit&lt;/code&gt;. Then&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;create another directory, for instance &lt;code&gt;C:\eclipsewrkspc\mygit&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;start Eclipse to use that directory as its workspace.&lt;/li&gt;
&lt;li&gt;use the "Import existing project" functionality and point to the git directory&lt;/li&gt;
&lt;li&gt;Uncheck the "copy into workspace" flag.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
That approach should work, at least it did for me.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5211228043243414701-5059761824188875200?l=blog.js-development.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/zCk3F51N6NpbGXhJM8-L7N8-Vcs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/zCk3F51N6NpbGXhJM8-L7N8-Vcs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/zCk3F51N6NpbGXhJM8-L7N8-Vcs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/zCk3F51N6NpbGXhJM8-L7N8-Vcs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/juristrumpflohner/~4/aZ93CLXaUlQ" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/juristrumpflohner/~3/aZ93CLXaUlQ/eclipse-importing-existing-project.html</link><author>noreply@blogger.com (Juri Strumpflohner)</author><thr:total>0</thr:total><feedburner:origLink>http://blog.js-development.com/2012/01/eclipse-importing-existing-project.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5211228043243414701.post-4599136043687677664</guid><pubDate>Tue, 17 Jan 2012 07:53:00 +0000</pubDate><atom:updated>2012-01-17T08:53:28.009+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C#</category><category domain="http://www.blogger.com/atom/ns#">.Net</category><title>Don't Fall into the IEnumerable&lt;T&gt; Trap</title><description>&lt;div class="intro"&gt;
Recently I upgraded some code of our company-internal class library and observed a plausible but still tricky problem. See yourself.
&lt;/div&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;img border="0" height="192" src="http://images.all-free-download.com/images/graphiclarge/question_smiley_clip_art_25272.jpg" width="200" /&gt;&lt;/div&gt;
In a class deep inside the class library ( ;)) there was a method which looked similar to the following:&lt;br /&gt;
&lt;pre class="brush:csharp"&gt;public IEnumerable&amp;lt;SomeObject&amp;gt; GetAllValidations()
{
   foreach...
       yield return new ValidationObject(...);
}
&lt;/pre&gt;
Then, inside another method in some other class there was the following code:
&lt;br /&gt;
&lt;pre class="brush:csharp;highlight:[5,18, 24]"&gt;public void HandleValidationErrors(IEnumerable&amp;lt;ValidationObject&amp;gt; validationObjects)
{
    IDictionary&amp;lt;ValidationObject, IList&amp;lt;ValidationErrors&amp;gt;&amp;gt; cache = new Dictionary&amp;lt;ValidationObject, IList&amp;lt;ValidationErrors&amp;gt;&amp;gt;();

    foreach(var validationObj in validationObjects)
    {
        cache.Add(validationObj, validationObj.ValidationErrors.ToList&lt;validationerror&gt;());
    }

    ActivateValidatorsAccordingToValidationErrors(validationObjects, cache);

    //snip snip: If cache not empty, some validation objects haven't been treated/found
}


public void ActivateValidatorsAccordingToValidationErrors(IEnumerable&amp;lt;ValidationObject&amp;gt; validationObjects, IDictionary&amp;lt;ValidationObject, IList&amp;lt;ValidationErrors&amp;gt;&amp;gt; cache)
{
    foreach(var valObj in validationObjects)
    {
        var validator = GetValidatorByValidationObj(valObj);
        if(validator != null)
        {
            //activate validator
            //remove ValidationObj from cache
        }
    }
}
&lt;/validationerror&gt;&lt;/pre&gt;
Now guess what, &lt;strong&gt;line 24&lt;/strong&gt; gave me an exception when I wanted to access the dictionary with the validationObj as key, telling me that the key was not present. I debugged the code and the obj was present!? My first thought: did someone override the &lt;code&gt;Equals()&lt;/code&gt;??...but that wasn't the case.&lt;br /&gt;
&lt;br /&gt;
Then I immediately saw the problem when looking at the method signature. Did you get it? &lt;code&gt;IEnumerable&amp;lt;T&amp;gt;&lt;/code&gt;. Did you hear about the &lt;strong&gt;"lazy-evaluation"&lt;/strong&gt; of IEnumerables? I did, fortunately. The problem here was that when the code entered the &lt;code&gt;HandleValidationErrors(...)&lt;/code&gt; method, passing in the IEnumerable, that latter has not been evaluated so far. And then I had the situation of a &lt;b&gt;possible multiple enumeration &lt;/b&gt;(&lt;a href="http://confluence.jetbrains.net/display/ReSharper/Possible+multiple+enumeration+of+IEnumerable" target="_blank"&gt;Resharper tells you that&lt;/a&gt;, so don't ignore it!). So what does that mean? When the &lt;code&gt;IEnumerable&lt;/code&gt; was accessed 1st in &lt;strong&gt;line 5&lt;/strong&gt;, the method &lt;code&gt;GetAllValidations()&lt;/code&gt; was called, actually executing the enumeration with &lt;strong&gt;new&lt;/strong&gt; instances of type ValidationObject. So far so good. Then when the loop in &lt;strong&gt;line 18&lt;/strong&gt; was executed, &lt;strong&gt;the same happened&lt;/strong&gt;, returning another, &lt;strong&gt;new&lt;/strong&gt; instance of a ValidationObject, basically another &lt;code&gt;IEnumerable&amp;lt;ValidationObject&amp;gt;&lt;/code&gt; than I previously added to the &lt;code&gt;cache&lt;/code&gt; variable. And here we are, now the exception when accessing the dictionary is quite obvious, isn't it?&lt;br /&gt;
&lt;br /&gt;
Obviously this was a silly mistake and fixing it was quite easy by inserting somewhere (I did it in the first possible place to keep other devs from falling in this trap as well ;)) a line like
&lt;br /&gt;
&lt;pre class="brush:csharp"&gt;var theList = theValidationObjectEnumeration.ToList&amp;lt;ValidationObject&amp;gt;()&lt;/pre&gt;
which "materializes" the list and prevents the multiple enumeration problem.&lt;br /&gt;
&lt;br /&gt;
I'm writing this post because such bugs can become quite nasty to find, especially if you don't know the fact about lazy-loading of &lt;code&gt;IEnumerable&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;and if the method returning the IEnumerable was written by some other dev. So watch out!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5211228043243414701-4599136043687677664?l=blog.js-development.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/PMNMa_jGXqkYYgpWd89zKMQck-Q/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/PMNMa_jGXqkYYgpWd89zKMQck-Q/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/PMNMa_jGXqkYYgpWd89zKMQck-Q/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/PMNMa_jGXqkYYgpWd89zKMQck-Q/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/juristrumpflohner/~4/EtUAYIUX5bA" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/juristrumpflohner/~3/EtUAYIUX5bA/dont-fall-into-ienumerable-trap.html</link><author>noreply@blogger.com (Juri Strumpflohner)</author><thr:total>0</thr:total><feedburner:origLink>http://blog.js-development.com/2012/01/dont-fall-into-ienumerable-trap.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5211228043243414701.post-2980543515843968420</guid><pubDate>Sun, 15 Jan 2012 12:25:00 +0000</pubDate><atom:updated>2012-01-15T13:25:53.014+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Linux</category><title>Help, Ubuntu 11.10 won't boot!!</title><description>&lt;div class="intro"&gt;
Today I tried to start the new Ubuntu 11.10 from the live CD on the old desktop computer of my girlfriend. Her computer is quite slow and the old WinXP installation broken. So why not take the occasion and try Ubuntu :).&lt;/div&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;img border="0" src="http://2.bp.blogspot.com/-ikVmfDdZb8Q/TxG_LOxTCEI/AAAAAAAAC8Q/gqvmp-sJfn8/s1600/ubuntu-11.10-oneiric-ocelot.png" /&gt;&lt;/div&gt;
I was impressed by the new Unity interface presented in the online &lt;a href="http://www.ubuntu.com/tour/" target="_blank"&gt;live Ubuntu tour&lt;/a&gt;. Much cleaner, more modern UI, actually there are many similarities to OSX. Anyway, I created an install CD and booted the computer from that. On the boot option I chose to first just run Ubuntu from the live CD. Everything seemed fine, but then, &lt;b&gt;black screen&lt;/b&gt;.&lt;br /&gt;
As usual when you use a Linux system, ask Google. And look there, a &lt;a href="http://ubuntuforums.org/showthread.php?t=1613132" target="_blank"&gt;nice forum entry&lt;/a&gt; with some helpful instructions (thx to the community).&lt;br /&gt;
&lt;br /&gt;
Basically the problem was to change the kernel boot options from &lt;code&gt;quiet splash&lt;/code&gt; to &lt;code&gt;quiet splash nomodeset&lt;/code&gt;. What is this "nomodeset"?
&lt;br /&gt;
&lt;blockquote&gt;
nomodeset&lt;br /&gt;
The newest kernels have moved the video mode setting into the kernel. So all the programming of the hardware specific clock rates and registers on the video card happen in the kernel rather than in the X driver when the X server starts.. This makes it possible to have high resolution nice looking splash (boot) screens and flicker free transitions from boot splash to login screen. Unfortunately, on some cards this doesnt work properly and you end up with a black screen. Adding the nomodeset parameter instructs the kernel to not load video drivers and use BIOS modes instead until X is loaded.
&lt;/blockquote&gt;
So in order to be able to install Ubuntu I booted the system from the live CD. At startup make sure you press the &lt;b&gt;down-key multiple times&lt;/b&gt; to enter the classic live CD menu with the options for either "just run" the system, install it or perform some memory and disk checks. At the same time, when &lt;b&gt;pressing F6&lt;/b&gt;, there is the possibility to check the "nomodeset" boot option. Then try to run the system, it should work.&lt;br /&gt;
&lt;br /&gt;
Then after having installed Ubuntu you have to do a restart. Again, press the &lt;b&gt;down-key or End&lt;/b&gt; key to enter the startup options. Select the desired one (not recovery) and press "e" to edit the boot option as follows:
&lt;br /&gt;
&lt;pre class="brush:bash"&gt;linux /boot/vmlinuz-....generic root=UUID=... ro quite splash nomodeset
&lt;/pre&gt;
Then press F10 and the system should boot.
&lt;br /&gt;
&lt;br /&gt;
So once you've booted the installed version you need to permanently configure the boot mode. The best way is to open a terminal window and type&lt;br /&gt;
sudo gedit /etc/default/grub&lt;br /&gt;
and edit the GRUB_CMDLINE_LINUX_DEFAULT as follows:
&lt;br /&gt;
&lt;pre class="brush:bash"&gt;GRUB_DEFAULT=0
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomodeset"
&lt;/pre&gt;
Save the file and execute a &lt;code&gt;sudo upgrade-grub&lt;/code&gt;. Then your computer should boot normally next time.

Here's a link I found quite useful of some hints to perform after installing Ubuntu:
&lt;a href="http://www.techdrivein.com/2011/10/15-things-i-did-after-installing-new.html" rel="nofollow"&gt;http://www.techdrivein.com/2011/10/15-things-i-did-after-installing-new.html&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5211228043243414701-2980543515843968420?l=blog.js-development.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Z5FDP7xrI4nqO3VNWqrGK8bO0PY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Z5FDP7xrI4nqO3VNWqrGK8bO0PY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Z5FDP7xrI4nqO3VNWqrGK8bO0PY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Z5FDP7xrI4nqO3VNWqrGK8bO0PY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/juristrumpflohner/~4/80D-dIRFGJ0" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/juristrumpflohner/~3/80D-dIRFGJ0/help-ubuntu-1110-wont-boot.html</link><author>noreply@blogger.com (Juri Strumpflohner)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-ikVmfDdZb8Q/TxG_LOxTCEI/AAAAAAAAC8Q/gqvmp-sJfn8/s72-c/ubuntu-11.10-oneiric-ocelot.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://blog.js-development.com/2012/01/help-ubuntu-1110-wont-boot.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5211228043243414701.post-3726901119619920712</guid><pubDate>Wed, 04 Jan 2012 23:35:00 +0000</pubDate><atom:updated>2012-01-05T00:35:18.163+01:00</atom:updated><title>2011 Retrospective and a New Look</title><description>&lt;p class="intro"&gt;
I know it's a bit late for a 2011 year recap, but I didn't manage to write one earlier. Actually, I just noted that I didn't publish one last year at all. Anyway, here just a couple of lines to 2011, the new look of this blog and maybe some outlook to 2012?&lt;/p&gt;
&lt;a name='more'&gt;&lt;/a&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;img border="0" height="361" width="500" src="http://www.happynewyear2012.net/images/pictures/happy-new-year-2012-picture-05.gif" /&gt;&lt;/div&gt;
&lt;h3&gt;Year 2011 - A Retrospective&lt;/h3&gt;
2011 was a very successful and interesting year. In March I finally concluded my &lt;a href="http://blog.js-development.com/2011/03/concluding-another-chapter.html" target="_blank"&gt;university studies&lt;/a&gt;. It was an interesting, but at the same time very effortful period. After that I returned to work full-time with lots of interesting new challenges to face. Unfortunately my blog didn't (yet) reflect that much about these changes.&lt;br /&gt;
Beside computer science related topics I managed to enter the Italian National team of &lt;a href="http://www.yoseikan.it/" rel="nofollow" target="_blank"&gt;Yoseikan Budo&lt;/a&gt; (&lt;a href="http://www.yoseikan-nals.it/" target="_blank"&gt;my club&lt;/a&gt;) and successfully concluded the exams for the 2. Dan Yoseikan Budo.&lt;br /&gt;
And last but not least, with the start of 2012 I moved in together with my girlfriend in our first common flat.&lt;br /&gt;

&lt;h3&gt;A Facelift to this Blog&lt;/h3&gt;
Yep, once again I decided to give this blog a small facelift. The major changes consist in making the entry page more attractive, while the detail post pages remained mostly the same. The entry page now consists in small snippets of the 6 most recent posts with each posts having a small initial intro part describing its content.&lt;br /&gt;
Basically, the main objective was to just visualize only the most common and most important information while still giving the blog an attractive "face". Now, obviously I'm not a designer, I'm a software dev. But still I like to play around with CSS as IMHO the design of a web page/application is a major important part. Making such changes to my blog is always again a good learning lesson. But I'm open for suggestions and improvements.&lt;br /&gt;
&lt;u&gt;Note&lt;/u&gt; that there are still some fine-tuning improvements coming over the following weeks as I didn't yet manage to include them right now.&lt;br /&gt;

&lt;h3&gt;
And for 2012?&lt;/h3&gt;
More blogging, more about .Net, more Android development, and finally more about web development especially about JavaScript. Let's see whether I manage it :). And obviously I'm looking forward for a &lt;a href="http://www.google.com/search?sourceid=chrome&amp;amp;ie=UTF-8&amp;amp;q=23.12.2012" target="_blank"&gt;year recap 2012&lt;/a&gt; ;).&lt;br /&gt;
So I wish you all a good start in 2012 and much success.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5211228043243414701-3726901119619920712?l=blog.js-development.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/uCmTbVF3FgSXBiN2y2M5fut3BY0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/uCmTbVF3FgSXBiN2y2M5fut3BY0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/uCmTbVF3FgSXBiN2y2M5fut3BY0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/uCmTbVF3FgSXBiN2y2M5fut3BY0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/juristrumpflohner/~4/oXlK7CRaRg0" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/juristrumpflohner/~3/oXlK7CRaRg0/2011-retrospective-and-new-look.html</link><author>noreply@blogger.com (Juri Strumpflohner)</author><thr:total>0</thr:total><feedburner:origLink>http://blog.js-development.com/2012/01/2011-retrospective-and-new-look.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5211228043243414701.post-2718946823677824371</guid><pubDate>Mon, 12 Dec 2011 13:39:00 +0000</pubDate><atom:updated>2011-12-12T14:39:00.501+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Unit Testing</category><category domain="http://www.blogger.com/atom/ns#">Best Practices</category><category domain="http://www.blogger.com/atom/ns#">C#</category><category domain="http://www.blogger.com/atom/ns#">Software testing</category><category domain="http://www.blogger.com/atom/ns#">.Net</category><title>Writing IoC Supported Integration Tests using AutoFac</title><description>Using a dependency injection framework can &lt;a href="http://blog.js-development.com/2010/12/smelly-code-direct-object-instantiation.html" target="_blank"&gt;greatly facilitate&lt;/a&gt; your &lt;a href="http://blog.js-development.com/2010/03/tackle-software-dependencies-with-ioc.html" target="_blank"&gt;code's testability&lt;/a&gt;&amp;nbsp;in that you don't have any "glue" code for managing a classes' dependency that needs to be mocked (if even possible) when writing unit tests. But what about when writing &lt;b&gt;integration tests&lt;/b&gt;? In such case you'd probably want to use your IoC container's configuration for resolving types in order to also verify the proper &lt;i&gt;integration &lt;/i&gt;of your components, frankly your dependency injection configuration, right?&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://code.google.com/p/autofac/logo?cct=1304973969" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://code.google.com/p/autofac/logo?cct=1304973969" /&gt;&lt;/a&gt;&lt;/div&gt;
With AutoFac it is actually quite simple. What your integration test needs to do is to himself create the &lt;code&gt;ContainerBuilder()&lt;/code&gt; and accordingly register the dependencies. What you should do is the following. Assume you have a Visual Studio project that encapsulates your business logic called "BusinessLogic". Then the best strategy is to &lt;b&gt;create a so-called Autofac module per project &lt;/b&gt;(and hence dll) to configure the dependencies within that specific project. This is done by extending the abstract class &lt;code&gt;Autofac.Module&lt;/code&gt; like&lt;br /&gt;
&lt;pre class="brush:csharp"&gt;public class BusinessLogicModule : Module
{
    protected override void Load(ContainerBuilder builder)
    {
        //register other modules/dependencies here
    }
}
&lt;/pre&gt;
&lt;br /&gt;
When you now want to write a test for the BusinessLogic project, you might create a &lt;code&gt;BusinessLogic.IntegrationTests&lt;/code&gt; project, adding the project under test as a reference.&lt;br /&gt;
A possible approach to this could be the following: create ageneric class for instantiating the Autofac IoC container with the BusinessLogicModule created before. Let's call this class&amp;nbsp;&lt;b&gt;"IoCSupportedTest"&lt;/b&gt;:&lt;br /&gt;
&lt;pre class="brush:csharp"&gt;using Autofac;
using Autofac.Core;

namespace BusinessLogic.IntegrationTest.Utils
{
    public class IoCSupportedTest&amp;lt;TModule&amp;gt; where TModule : IModule, new()
    {
        private IContainer container;

        public IoCSupportedTest()
        {
            var builder = new ContainerBuilder();

            builder.RegisterModule(new TModule());

            container = builder.Build();
        }

        protected TEntity Resolve&amp;lt;TEntity&amp;gt;()
        {
            return container.Resolve&amp;lt;TEntity&amp;gt;();
        }

        protected void ShutdownIoC()
        {
            container.Dispose();
        }
    }
}&lt;/pre&gt;
A specific test case might then look as follows:&lt;br /&gt;
&lt;pre class="brush:csharp"&gt;[TestClass]
public class UserRepositoryTest : IoCSupportedTest&amp;lt;BusinessLogicModule&amp;gt;
{
    private IUserRepository userRepo;

    [TestInitialize]
    public void Setup()
    {
        this.userRepo = Resolve&amp;lt;IUserRepository&amp;gt;();
    }

    [TestCleanup]
    public void TearDown()
    {
        userRepo = null;
        ShutdownIoC();
    }

    //the tests
}&lt;/pre&gt;
&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5211228043243414701-2718946823677824371?l=blog.js-development.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/HTyqYQQZg3krXAinWnN0FPpKLfE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/HTyqYQQZg3krXAinWnN0FPpKLfE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/HTyqYQQZg3krXAinWnN0FPpKLfE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/HTyqYQQZg3krXAinWnN0FPpKLfE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/juristrumpflohner/~4/02Ae2u8y4HI" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/juristrumpflohner/~3/02Ae2u8y4HI/writing-ioc-supported-integration-tests.html</link><author>noreply@blogger.com (Juri Strumpflohner)</author><thr:total>0</thr:total><feedburner:origLink>http://blog.js-development.com/2011/12/writing-ioc-supported-integration-tests.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5211228043243414701.post-2074750179714657507</guid><pubDate>Wed, 07 Dec 2011 10:15:00 +0000</pubDate><atom:updated>2011-12-07T11:15:36.647+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">JavaScript</category><category domain="http://www.blogger.com/atom/ns#">Exploring JavaScript</category><title>Exploring JavaScript: Scope Pollution when instantiating JavaScript Objects</title><description>John Resig has written a very interesting article (I'm not able to find just now) on how the current scope might get polluted if you're accidentally invoking a function intended as an object constructor function without using the "new" keyword in front. Here's a simple example that illustrates the issue.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;Basically consider you have the following, extremely simple code:&lt;br /&gt;
&lt;pre class="brush:javascript"&gt;var Person = function(first, second){
   this.name = first + " " + second;
};

//using it somewhere
var name = "Juri";
var aPerson = new Person("Peter", "Oberhofer"); //invoking the constructor function

document.write(name);
&lt;/pre&gt;
Now as expected you'd assume "Juri" to be printed as you don't do anything else than printing the current variable &lt;code&gt;name&lt;/code&gt;.&lt;br /&gt;
&lt;br /&gt;
Now what happens if you forget to use the "new" keyword like
&lt;br /&gt;
&lt;pre class="brush:javascript"&gt;var name="Juri";
var aPerson = Person("Peter", "Oberhofer"); //attention, no "new" keyword

document.write(name);
&lt;/pre&gt;
What would be the result? Can you guess it? It would be: &lt;code&gt;Peter Oberhofer&lt;/code&gt;. Strange, right? The problem is that given the fact you didn't specify the "new" keyword the function &lt;code&gt;Person&lt;/code&gt; &lt;b&gt;wrote on the global namespace&lt;/b&gt; when executing &lt;code&gt;this.name = ...&lt;/code&gt;. The declaration of &lt;code&gt;var name = "Juri"&lt;/code&gt;&amp;nbsp;is in this case on the global namespace as well, hence without specifying the &lt;code&gt;new&lt;/code&gt; keyword you overwrite the previous declaration, resulting in &lt;code&gt;Peter Oberhofer&lt;/code&gt;&amp;nbsp;to be printed out.&lt;br /&gt;
&lt;br /&gt;
You can check out a live sample here: &lt;a href="http://jsbin.com/ozawep/4/edit#javascript,live"&gt;http://jsbin.com/ozawep/4/edit#javascript,live&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5211228043243414701-2074750179714657507?l=blog.js-development.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/BnuSTa4FJPaMtWP4qXDj4reRh7I/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/BnuSTa4FJPaMtWP4qXDj4reRh7I/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/BnuSTa4FJPaMtWP4qXDj4reRh7I/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/BnuSTa4FJPaMtWP4qXDj4reRh7I/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/juristrumpflohner/~4/0SeJ7OMCOiw" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/juristrumpflohner/~3/0SeJ7OMCOiw/exploring-javascript-scope-pollution.html</link><author>noreply@blogger.com (Juri Strumpflohner)</author><thr:total>0</thr:total><feedburner:origLink>http://blog.js-development.com/2011/12/exploring-javascript-scope-pollution.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5211228043243414701.post-5383002569905960369</guid><pubDate>Tue, 06 Dec 2011 21:45:00 +0000</pubDate><atom:updated>2011-12-06T22:45:40.066+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Personal</category><title>Saying Goodbye to University</title><description>&lt;div&gt;
After my thesis presentation in &lt;a href="http://blog.js-development.com/2011/03/concluding-another-chapter.html" target="_blank"&gt;march this year,&lt;/a&gt; my university career now ended officially with the degree ceremony last saturday. I remember when I first inscribed myself about 5 years ago, at the &lt;a href="http://www.unibz.it/en/inf/welcome/default.html" target="_blank"&gt;Free University of Bolzano at the faculty of computer science&lt;/a&gt;. The faculty (same as the university itself) is quite young. It actually celebrated its 10 year birthday a couple of days ago. And this was reflected also on the number of students, 5 years ago, when I first entered the Analysis class with about 70 people in total. Nothing compared to the really big universities. And after the 1st semester the number even diminished until, about a year later, we were a small, constant group of about 20 to 30 people in total.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
Three years later I successfully concluded the Bachelor in Applied Computer Science and decided to start working. I was interested in applying the learned stuff and collect some experiences. But still, there was always the desire to continue and so, after working full-time for a year I was given the opportunity by my employer to switch to part time and to inscribe in the Master of Computer Science..always at the &lt;a href="http://www.unibz.it/" target="_blank"&gt;FUB&lt;/a&gt;. It was though, really tough. When you sit at the university for studying in the morning and then in the afternoon you go at work, doing your job there, then, in the evening, you need to catch up with what your study mates did while you were at work. Thats challenging and most importantly, you need to be well organized. Nevertheless, I never neglected my girlfriend or my hobbies and thats a major important thing. This is what keeps your head above water ;).&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;img border="0" height="400" src="http://3.bp.blogspot.com/-w_me-obEjW4/Tt6JfD-ZmKI/AAAAAAAAC7Y/ku-9yYJih-s/s400/P1070142.JPG" style="margin-left: auto; margin-right: auto;" width="300" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;I did it!!&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
Now, about 3 years later I'm here, just concluded my MSc studies getting 110/110 points (which I'd never been imagined) and having a good work place offering some interesting challenges.&lt;br /&gt;
Looking back, I would always again inscribe me at the Free University of Bolzano if I'd have to. A lot of people are somehow often looking at the university in a&amp;nbsp;devaluating&amp;nbsp;manner, mainly given its low number of students compared to other, more established universities. But that's not a disadvantage, differently, its an advantage in my eyes as you have direct contact to the professors which gives you the unique possibility to dive into interesting discussions. And the number of students is growing from year to year.&amp;nbsp;Another major important fact is the internationality of the university in terms of its language model. Although being in a region where there are nearly just italian and german native speakers, the official teaching language of the computer science faculty is English. Even if this might sound pretty irrelevant, it is definitely not. English is &lt;b&gt;the&lt;/b&gt;&amp;nbsp;computer science language and it is so extremely useful in your professional career as I just experienced recently when we had a phone conference with a guy in America, reviewing parts of our code base.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5211228043243414701-5383002569905960369?l=blog.js-development.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/m597pu4GDYjC2Rg5450EJTf2FiA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/m597pu4GDYjC2Rg5450EJTf2FiA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/m597pu4GDYjC2Rg5450EJTf2FiA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/m597pu4GDYjC2Rg5450EJTf2FiA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/juristrumpflohner/~4/ms8v4IkhEJg" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/juristrumpflohner/~3/ms8v4IkhEJg/saying-goodbye-to-university.html</link><author>noreply@blogger.com (Juri Strumpflohner)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-w_me-obEjW4/Tt6JfD-ZmKI/AAAAAAAAC7Y/ku-9yYJih-s/s72-c/P1070142.JPG" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://blog.js-development.com/2011/12/saying-goodbye-to-university.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5211228043243414701.post-3986316218010391680</guid><pubDate>Mon, 21 Nov 2011 13:03:00 +0000</pubDate><atom:updated>2012-01-05T00:36:50.189+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">JavaScript</category><category domain="http://www.blogger.com/atom/ns#">MVC</category><category domain="http://www.blogger.com/atom/ns#">Web dev</category><category domain="http://www.blogger.com/atom/ns#">Software Architecture</category><title>Large-scale JavaScript Application Architecture</title><description>JavaScript programming has evolved a lot over the past years and has somehow revolutionized the way you develop on the web. While many initially just used it as a scripting language to quickly hack in some dynamic behavior into traditional websites, it starts now to be used much more like a fully capable programming language (mainly also due to many emerging JavaScript libraries and more capable browsers).&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
Despite this, the key to successful JavaScript development - as I've already &lt;a href="http://blog.js-development.com/2011/10/what-model-view-controller-in.html"&gt;written in a prior post&lt;/a&gt; and which you might have been able to read between the lines of some other ones - is &lt;b&gt;structure&lt;/b&gt;. Without structure you're lost.., your code gets messy, a maintenance nightmare, uncontrollable, rigid ... scripting code basically. You might not take care about all this in small projects, but it becomes crucial as your project grows and gets rather big.&lt;br /&gt;
Take a look at the following presentation by &lt;a href="http://addyosmani.com/blog/" target="window"&gt;Addy Osmani&lt;/a&gt; about &lt;i&gt;Large-scale JavaScript Application Architecture&lt;/i&gt; which in my opinion nicely presents the major important points.&lt;br /&gt;
&lt;br /&gt;
&lt;script src="http://speakerdeck.com/embed/4ec3f44095903900510005cf.js"&gt;
&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5211228043243414701-3986316218010391680?l=blog.js-development.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/-KJ6Pm1O9wf7-N9UlxySEkNN81s/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-KJ6Pm1O9wf7-N9UlxySEkNN81s/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/-KJ6Pm1O9wf7-N9UlxySEkNN81s/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-KJ6Pm1O9wf7-N9UlxySEkNN81s/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/juristrumpflohner/~4/ipI_KVf7J2s" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/juristrumpflohner/~3/ipI_KVf7J2s/large-scale-javascript-application.html</link><author>noreply@blogger.com (Juri Strumpflohner)</author><thr:total>0</thr:total><feedburner:origLink>http://blog.js-development.com/2011/11/large-scale-javascript-application.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5211228043243414701.post-2812062567388139517</guid><pubDate>Fri, 18 Nov 2011 11:16:00 +0000</pubDate><atom:updated>2011-11-18T14:54:20.385+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C#</category><category domain="http://www.blogger.com/atom/ns#">Software Design</category><title>Some Usability Thoughts for the Weekend...</title><description>A couple of days ago I got the order to write a very simple program that would take a bunch of XML input files with the task to elaborate them in terms of grouping them according to some identifier and then to output the result (grouped per directory) in a more user friendly and readable way. While the prog is stupidly simple there are still some potential pitfall one might not realize immediately.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The objective was to give the tool to one of our customers in order to facilitate their work, hence:&amp;nbsp;&lt;b&gt;pay attention to usability factors&lt;/b&gt;.&lt;br /&gt;
I started with a simple GUI:&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-UVpFTtFtcwc/TsY_ppK3DqI/AAAAAAAAC6k/C8WWMOXItwg/s1600/avcpGui.png" imageanchor="1" rel="zoombox" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="150" src="http://2.bp.blogspot.com/-UVpFTtFtcwc/TsY_ppK3DqI/AAAAAAAAC6k/C8WWMOXItwg/s400/avcpGui.png" width="400" /&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;div&gt;
So far, nothing special. There is a source folder textbox and a destination folder. They're self-explanatory I guess. What the program should do (for comfortability reasons) is to &lt;b&gt;create the destination folder&lt;/b&gt; if it doesn't exist and if it exists already, &lt;b&gt;delete all its content&lt;/b&gt;, as it might originate from a previous elaboration.&lt;br /&gt;
&lt;br /&gt;
A naive approach would be to do&lt;br /&gt;
&lt;pre class="brush:c#"&gt;if(!Directory.Exists(destinationDir))
{
   Directory.CreateDirectory(destinationDir);
}
else
{
   //delete all files and directories in destinationDir
}
&lt;/pre&gt;
But attention! What might a "dummy" user do what an "expert" user might not? Probably enter something like this:&lt;br /&gt;
&lt;i&gt;Source: C:\sourceFileDirectory&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;Destination:&amp;nbsp;C:\sourceFileDirectory&lt;/i&gt;&lt;br /&gt;
&lt;b&gt;Bad:&lt;/b&gt; You delete all of the source files.&lt;br /&gt;
&lt;br /&gt;
Or even worse:&lt;br /&gt;
&lt;i&gt;Source: C:\sourceFileDirectory&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;Destination:&amp;nbsp;C:\&lt;/i&gt;&lt;br /&gt;
&lt;b&gt;Bad:&lt;/b&gt;&amp;nbsp;You wipe his C drive :D.&lt;br /&gt;
&lt;br /&gt;
These are exactly the problems that are often overlooked (as they might seem obvious) and which then cause&amp;nbsp;enormous&amp;nbsp;damage.&amp;nbsp;Therefore a possible solution might be..&lt;br /&gt;
&lt;pre class="brush:c#"&gt;if(!Directory.Exists(destinationDir))
{
   Directory.CreateDirectory(destinationDir);
}
else
{
   //create an output directory inside the specified 
   destinationDir = Path.Combine(destinationDir, "Out");

   if(!Directory.Exists(destinationDir))
   {
      //create it
   }
   else
   {
      //Ask the user about wiping the content of the output directory
      //Do it if confirmed
   }
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-UPzkbtJyeyw/TsZEkSsCsBI/AAAAAAAAC6s/wikSP-jhl3s/s1600/avcpConfirmation.png" imageanchor="1" rel="zoombox" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="207" src="http://4.bp.blogspot.com/-UPzkbtJyeyw/TsZEkSsCsBI/AAAAAAAAC6s/wikSP-jhl3s/s400/avcpConfirmation.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
Have a nice weekend :).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5211228043243414701-2812062567388139517?l=blog.js-development.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/-y46Nlng9jUVed8SaNxjAtyBUi8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-y46Nlng9jUVed8SaNxjAtyBUi8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/-y46Nlng9jUVed8SaNxjAtyBUi8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-y46Nlng9jUVed8SaNxjAtyBUi8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/juristrumpflohner/~4/rlpVlZTU1ys" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/juristrumpflohner/~3/rlpVlZTU1ys/some-usability-thoughts-for-weekend.html</link><author>noreply@blogger.com (Juri Strumpflohner)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-UVpFTtFtcwc/TsY_ppK3DqI/AAAAAAAAC6k/C8WWMOXItwg/s72-c/avcpGui.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://blog.js-development.com/2011/11/some-usability-thoughts-for-weekend.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5211228043243414701.post-4358391560692573192</guid><pubDate>Fri, 18 Nov 2011 07:32:00 +0000</pubDate><atom:updated>2011-11-18T08:32:17.676+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Unit Testing</category><category domain="http://www.blogger.com/atom/ns#">C#</category><category domain="http://www.blogger.com/atom/ns#">refactoring</category><category domain="http://www.blogger.com/atom/ns#">.Net</category><title>Use The "var" Keyword to Have More Maintainable Tests!?</title><description>I have to admit that initially when the "var" keyword has been introduced in C# I was quite precautious in using it. It does reduce code readability, I thought. In the end I'd say it's pretty much a matter of style and preferences, but not only, it even might help you in avoiding to break your code when you make changes, thus leading to a more maintainable code base.&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
I recently had the following scenario in a lot of tests where I verified the correct validation of my entities&lt;br /&gt;
&lt;pre class="brush:c#"&gt;public void TestSomething()
{
   //Arrange
   ...

   //Act
   IList&amp;lt;ValidationError&amp;gt; result = validationProvider.Validate(entity);

   //Assert
   Assert.AreEqual(3, result.Count(), "There should be 3 validation errors");
}&lt;/pre&gt;
However, with the new changes to our architecture I'm currently working on, I try to adapt the validation to the one proposed by ASP.net MVC and Entity Framework, still allowing to write validation rules in the same way we were accustomed so far. This led to a couple of &lt;b&gt;breaking changes&lt;/b&gt; however, as I took the opportunity to make some improvements. As a result the return type of the validation adapter wasn't an &lt;code&gt;IList&lt;/code&gt; any more, but instead &lt;code&gt;IEnumerable&amp;lt;ValidationResult&amp;gt;&lt;/code&gt;. Note the generic type of the list changed as well. As a consequence the tests didn't compile any more and I had to manually fix them all (although it was just a matter of search&amp;amp;replace ;)).&lt;br /&gt;
&lt;br /&gt;
Instead, if I had written those tests by not explicitly defining the collection type but rather to just declare them using the var keyword, my tests would have continued to work without any problems.&lt;br /&gt;
&lt;pre class="brush:c#"&gt;public void TestSomething()
{
   //Arrange
   ...

   //Act
   var result = validationProvider.Validate(entity);
   ...
}&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5211228043243414701-4358391560692573192?l=blog.js-development.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/WvHyBhb3DO9hj7hvwGl4JLjpmQE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/WvHyBhb3DO9hj7hvwGl4JLjpmQE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/WvHyBhb3DO9hj7hvwGl4JLjpmQE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/WvHyBhb3DO9hj7hvwGl4JLjpmQE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/juristrumpflohner/~4/2Q8_2yde7s0" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/juristrumpflohner/~3/2Q8_2yde7s0/use-var-keyword-to-have-more.html</link><author>noreply@blogger.com (Juri Strumpflohner)</author><thr:total>0</thr:total><feedburner:origLink>http://blog.js-development.com/2011/11/use-var-keyword-to-have-more.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5211228043243414701.post-4046647863225479445</guid><pubDate>Tue, 15 Nov 2011 11:15:00 +0000</pubDate><atom:updated>2011-11-16T08:16:51.307+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ASP.net</category><category domain="http://www.blogger.com/atom/ns#">Web dev</category><category domain="http://www.blogger.com/atom/ns#">.Net</category><title>AutoFac: ASP.net WebForms UserControl Dependencies Only Available At Page_Load Event</title><description>I'm currently adapting the architecture of one of our old but core projects, still written in ASP.net WebForms and with our custom ORM mapper. Since we're currently starting to release a new version of the project, we decided took the opportunity to also exchange our custom ORM mapper with Entity Framework and at the same time I introduced &lt;a href="http://code.google.com/p/autofac/"&gt;&lt;b&gt;AutoFac&lt;/b&gt;&lt;/a&gt; for providing dependency injection. It turned out however, that with the default ASP.net WebForms integration, dependencies of a Page's child control (i.e. a UserControl) are only available in the Page_Load event of the UserControl rather than already in its OnInit.&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
The official AutoFac page has a nice article describing the integration into ASP.net Webforms: &lt;a href="http://code.google.com/p/autofac/wiki/AspNetIntegration"&gt;*click*&lt;/a&gt;. That worked out just fine with one exception. Normally our ASP.net pages contain very little logic. They're just aggregating a series of UserControls. As such I noticed that the dependencies inside those child UserControls are only available starting from the UserControl's Page_Load event whereas it would often be handy to have them in the &lt;code&gt;OnInit&lt;/code&gt; event already.&lt;br /&gt;
&lt;pre class="brush:c#"&gt;public class MyUserControl : UserControl
{
    public IServiceClass ServiceClass { get; set; }

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        //ServiceClass.DoSomething(); //&amp;lt;&amp;lt; would not work as ServiceClass is at this point
    }

    protected void Page_Load(object sender, EventArgs e)
    {
       ServiceClass.DoSomething(); //works just fine
    }
}
&lt;/pre&gt;
Note, the dependencies are autowired here over the public properties.&lt;br /&gt;
To avoid this, I used a BaseClass DependencyResolvingUserControl&lt;br /&gt;
&lt;pre class="brush:c#"&gt;public class DependencyResolvingUserControl : UserControl
{
    protected override void OnInit(EventArgs e)
    {
        var cpa = (IContainerProviderAccessor)HttpContext.Current.ApplicationInstance;
        var cp = cpa.ContainerProvider;
        cp.RequestLifetime.InjectProperties(this);

        base.OnInit(e);
    }
}
&lt;/pre&gt;
And the according custom UserControl does now inherit from it
&lt;br /&gt;
&lt;pre class="brush:c#; highlight:[1]"&gt;public class MyUserControl : DependencyResolvingUserControl
{
    public IServiceClass ServiceClass { get; set; }

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        ServiceClass.DoSomething(); //works
    }

    protected void Page_Load(object sender, EventArgs e)
    {
       ServiceClass.DoSomething(); //works as well
    }
}&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5211228043243414701-4046647863225479445?l=blog.js-development.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/_qtug-36cGVMxgul9w64HnV6Qd0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/_qtug-36cGVMxgul9w64HnV6Qd0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/_qtug-36cGVMxgul9w64HnV6Qd0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/_qtug-36cGVMxgul9w64HnV6Qd0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/juristrumpflohner/~4/7R-85-GQIWs" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/juristrumpflohner/~3/7R-85-GQIWs/autofac-aspnet-webforms-usercontrol.html</link><author>noreply@blogger.com (Juri Strumpflohner)</author><thr:total>0</thr:total><feedburner:origLink>http://blog.js-development.com/2011/11/autofac-aspnet-webforms-usercontrol.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5211228043243414701.post-2784557021929219004</guid><pubDate>Fri, 04 Nov 2011 07:22:00 +0000</pubDate><atom:updated>2011-11-07T21:42:47.496+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">JavaScript</category><category domain="http://www.blogger.com/atom/ns#">Web dev</category><category domain="http://www.blogger.com/atom/ns#">jQuery</category><title>jQuery Validation: Add a Required Field Marker</title><description>When you use jQuery for validating input fields you might want to automatically (based on the validators) decorate your according field labels or input fields with appropriate markers that indicate required fields. This is common practice in web UIs and quite handy and intuitive for the user. Obviously you'd like this to happen on an automated basis rather than manually adding those markers which is more error prone. Using jQuery this is quite simple actually.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;The idea is to do this process of adding markers after the validation has been hooked on your form.&amp;nbsp;&lt;span style="background-color: transparent;"&gt;There are basically two possibilities:&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: transparent;"&gt;(a) if you added your jQuery validators by directly annotating your input fields, then you might use a jQuery selector to find all those fields and append the marker appropriately (assume all your required fields have a class "required"):&lt;/span&gt;
&lt;br /&gt;
&lt;pre class="brush:javascript"&gt;$(".required").append("(*)");
&lt;/pre&gt;
Alternatively, if (b) you have your jQuery validators as a set of rules, in the form
&lt;br /&gt;
&lt;pre class="brush:javascript"&gt;{
    rules: {
        firstname: {
            required: true,
            rangelength: [2,5]
        },
        ...
    }
    ...
}
&lt;/pre&gt;
..then you can iterate over those rules and process them directly:
&lt;br /&gt;
&lt;pre class="brush:javascript"&gt;for(var propName in validationRules.rules){
  if(validationRules.rules[propName].required !== undefined){
    $("(*)").insertAfter($("*[name=" + propName + "]", $("form")));
  }
}
&lt;/pre&gt;
Here's a live demo: &lt;a href="http://jsbin.com/ojuwuy/2/edit#javascript,live"&gt;http://jsbin.com/ojuwuy/2/edit#javascript,live&lt;/a&gt;. Easy, huh?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5211228043243414701-2784557021929219004?l=blog.js-development.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/6yeMrnWUVd42iIsTKePb-C27hpo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/6yeMrnWUVd42iIsTKePb-C27hpo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/6yeMrnWUVd42iIsTKePb-C27hpo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/6yeMrnWUVd42iIsTKePb-C27hpo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/juristrumpflohner/~4/CdFdSotCia4" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/juristrumpflohner/~3/CdFdSotCia4/jquery-validation-add-required-field.html</link><author>noreply@blogger.com (Juri Strumpflohner)</author><thr:total>0</thr:total><feedburner:origLink>http://blog.js-development.com/2011/11/jquery-validation-add-required-field.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5211228043243414701.post-8570922135989719741</guid><pubDate>Thu, 03 Nov 2011 13:38:00 +0000</pubDate><atom:updated>2011-11-07T21:42:28.383+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">JavaScript</category><category domain="http://www.blogger.com/atom/ns#">lessions learned</category><category domain="http://www.blogger.com/atom/ns#">ASP.net</category><category domain="http://www.blogger.com/atom/ns#">Web dev</category><title>Don't Underestimate the Trouble Caused by URLs in Emails</title><description>At a first glance, the title might seem strange, but wait. The company I'm working at creates e-government solutions, so the target audience are the citizens, from the young, very computer-literate ones to the more elderly (and often, but not always) less computer-literate ones :). Recently we created an ID-Management system for providing a single-signon system for all of our services.&amp;nbsp;&lt;span style="background-color: transparent;"&gt;That specific ID-Man system does send emails to the citizen on an automated basis, i.e. when resetting the password and those emails contain links which point back to our ID-Man web application. I'd never have thought how much trouble those URLs might cause us.&lt;/span&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;img border="0" height="221" src="http://one4theotherthumb.com/images/stories/argh.gif" width="320" /&gt;&lt;/div&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span style="background-color: transparent;"&gt;The point is that the links have the following form:&lt;/span&gt;
&lt;br /&gt;
&lt;pre class="code"&gt;http://ouridmanserver.it/changepwd.aspx?lang=de&amp;amp;p=JURKDKHS988123&lt;/pre&gt;
The token is unique and identifies a user's previous request to change his password. Now, initially we sent those emails as plain text mails. This turned out to create several problems in having our URL broken on several lines as there is a limit at 70 or 80 chars (don't remember exactly). As a consequence, the (less computer-literate guys) weren't able to handle the link properly as their email client did not account for the line break and so our server received just a part of the link and was unable to process the request.&lt;br /&gt;
&lt;br /&gt;
Seeing those problems pop up quite often, we decided to go for the quickest possible solution and turned our plain text mails in to HTML mails, in this way properly encoding those URLs within the email body. This did actually eliminate the issue of potentially having broken links.&lt;br /&gt;
Then, a couple of days ago I had an error log in my inbox from a user with the following URL:&lt;br /&gt;
&lt;pre class="code"&gt;http://ouridmanserver.it/changepwd.aspx?lang=de?p=JURKDKHS988123&lt;/pre&gt;
You see the issue?? The query string is not correct as there is a "?" instead of a "&amp;amp;" between the parameters. I immediately thought of a bug in our system but that wasn't the case. I had two different cases that turned out to have exactly the same issue. Both of them were using the same webmail client from the same provider. Ergo: &lt;b&gt;Email clients are crappy&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
To definitely solve that problem I decided to convert that URL like&lt;br /&gt;
&lt;pre class="code"&gt;http://ouridmanserver.it/p/de/JURKDKHS988123&lt;/pre&gt;
That reduced the size of the url and removed any special characters like "?" and "&amp;amp;". And that seems to have solved all those weird url issues (at least so far).&lt;br /&gt;
&lt;br /&gt;
If I find some time I quickly outline how I achieved such routing in an ASP.net 3.5 webapp without actually touching the existing ASPX logic (as backwards compatibility is a must in this scenario).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5211228043243414701-8570922135989719741?l=blog.js-development.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/soAGu_nJgTrUj1cd9KSX3c6t3m4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/soAGu_nJgTrUj1cd9KSX3c6t3m4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/soAGu_nJgTrUj1cd9KSX3c6t3m4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/soAGu_nJgTrUj1cd9KSX3c6t3m4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/juristrumpflohner/~4/JaajX8c2HNc" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/juristrumpflohner/~3/JaajX8c2HNc/dont-underestimate-trouble-caused-by.html</link><author>noreply@blogger.com (Juri Strumpflohner)</author><thr:total>0</thr:total><feedburner:origLink>http://blog.js-development.com/2011/11/dont-underestimate-trouble-caused-by.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5211228043243414701.post-3318320601118733813</guid><pubDate>Thu, 27 Oct 2011 09:16:00 +0000</pubDate><atom:updated>2011-11-07T21:42:47.500+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">JavaScript</category><category domain="http://www.blogger.com/atom/ns#">Exploring JavaScript</category><category domain="http://www.blogger.com/atom/ns#">Web dev</category><title>Exploring JavaScript: Iterating Over a Collection of Items</title><description>If I manage to do it, I'd like to write a series of introductory posts about programming in JavaScript as when listening to the latest hypes it is going to play a major role in programming the web but even desktop or mobile apps (see Microsoft's latest moves regarding Silverlight, HTML5 and their new Win8 OS). Google has always been an early promoter of heavy, rich-client JavaScript applications and as a recent example I'd also like to mention &lt;a href="http://trello.com/"&gt;Trello&lt;/a&gt;, a quite new app from Fog Creek,&amp;nbsp;which I started to use for organizing my work/projects and which is a JavaScript app that will blow you away ;).&lt;br /&gt;
&lt;br /&gt;
So here the first post in the series "exploring JavaScript" (I'll also tag them as such so you can easily keep track). Please do not pay attention at the order of how posts arrive related to the concepts in JavaScript. So I might write now about iterating over collections and at a later point about potential problems in using variable declarations, scoping or data types :). I'll write them as I encounter those problems.&lt;br /&gt;
&lt;br /&gt;
So this post outlines some possibilities of iterating over collections of items.&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;b style="background-color: transparent;"&gt;&lt;span style="font-size: large;"&gt;Using the standard for-loop&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
Similarly as in other language, there is the normal for-loop.&lt;br /&gt;
&lt;div style="text-align: right;"&gt;
&lt;i&gt;&lt;span style="font-size: x-small;"&gt;&lt;a href="http://jsbin.com/ifuyon/2/edit"&gt;Live Code&lt;/a&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;pre class="brush:javascript"&gt;var list = ["entry1", "entry2", "entry3"];
for(var i=0; i&amp;lt;list.length; i++){
    $("#out").append($("&amp;lt;div&amp;gt;" + i + " - " + list[i] + "&amp;lt;/div&amp;gt;"));    
}&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style="font-size: large;"&gt;Using the "foreach"&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
Note, the foreach loop iterates over the properties of a given object which might be slightly different than in other programming languages such as C# or Java.&lt;br /&gt;
&lt;div style="text-align: right;"&gt;
&lt;i&gt;&lt;span style="font-size: x-small;"&gt;&lt;a href="http://jsbin.com/imujob/2/edit"&gt;Live Code&lt;/a&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;pre class="brush:javascript"&gt;var list = ["entry1", "entry2", "entry3"];
for(var entry in list){
    $("#out").append($("&amp;lt;div&amp;gt;" + entry + " - " + list[entry] + "&amp;lt;/div&amp;gt;"));    
}&lt;/pre&gt;
The usage of the &lt;b&gt;for-in&lt;/b&gt; loop for arrays is highly discouraged, however. See this Stackoverflow post:&lt;br /&gt;
&lt;a href="http://stackoverflow.com/questions/500504/javascript-for-in-with-arrays"&gt;http://stackoverflow.com/questions/500504/javascript-for-in-with-arrays&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style="font-size: large;"&gt;Using jQuery.each(...)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
Beside the normal JavaScript build-in functions, one can also use the &lt;a href="http://api.jquery.com/jQuery.each/"&gt;jQuery.each&lt;/a&gt;&amp;nbsp;which does not only allow to iterate over a collection of DOM elements captured by the specified selector, but also through JavaScript collections.&lt;br /&gt;
&lt;div style="text-align: right;"&gt;
&lt;i&gt;&lt;span style="font-size: x-small;"&gt;&lt;a href="http://jsbin.com/ezewij/2/edit"&gt;Live Code&lt;/a&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;pre class="brush:javascript"&gt;var list = ["entry1", "entry2", "entry3"];
$.each(list, function(index, value){
    $("#out").append($("&amp;lt;div&amp;gt;" + index + " - " + value + "&amp;lt;/div&amp;gt;"));
});&lt;/pre&gt;
...or alternatively like...&lt;br /&gt;
&lt;div style="text-align: right;"&gt;
&lt;i&gt;&lt;span style="font-size: x-small;"&gt;&lt;a href="http://jsbin.com/ihinop/2/edit"&gt;Live Code&lt;/a&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;pre class="brush:javascript"&gt;var list = ["entry1", "entry2", "entry3"];
$(list).each(function(index, value){
    $("#out").append($("&amp;lt;div&amp;gt;" + index + " - " + value + "&amp;lt;/div&amp;gt;"));
});&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5211228043243414701-3318320601118733813?l=blog.js-development.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/aYslhKGkGUbuE-qLyQ35E3ysISA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/aYslhKGkGUbuE-qLyQ35E3ysISA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/aYslhKGkGUbuE-qLyQ35E3ysISA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/aYslhKGkGUbuE-qLyQ35E3ysISA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/juristrumpflohner/~4/lyPwOBbVeII" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/juristrumpflohner/~3/lyPwOBbVeII/exploring-javascript-iterating-over.html</link><author>noreply@blogger.com (Juri Strumpflohner)</author><thr:total>0</thr:total><feedburner:origLink>http://blog.js-development.com/2011/10/exploring-javascript-iterating-over.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5211228043243414701.post-5097551736916044512</guid><pubDate>Wed, 26 Oct 2011 06:02:00 +0000</pubDate><atom:updated>2011-11-07T21:42:28.350+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">JavaScript</category><category domain="http://www.blogger.com/atom/ns#">Blogging</category><title>My Tumblr Stream: A Developer's Work Log</title><description>You may have noted the diminishing frequency of posts being published on my blog here. Well, sadly I'm currently quite busy at work as well as privately. I'm currently relocating (out of my parent's home :)) as now also my girlfriend finally graduated about a week ago in MSc in Global Management and Markets - Major in Entrepreneurship (with 110/110 - congrats btw :)). And then there is &lt;a href="http://www.yoseikan-nals.it/"&gt;Yoseikan&lt;/a&gt;, where I have to prepare myself for the upcoming fighting season.&lt;br /&gt;
&lt;span style="background-color: transparent;"&gt;Anyway, don't worry, t&lt;/span&gt;&lt;span style="background-color: transparent;"&gt;here is a huge amount of posts in the draft state, waiting to be published. The point is that on this blog here I'd like to publish more elaborated, well thought articles that cover some interesting topic. This implies that does posts usually take a bit longer to write down (-&amp;gt; hence the long draft list).&lt;/span&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;img border="0" height="30" src="http://3.bp.blogspot.com/-f9F2f6eO11I/TqcrDY0ZfzI/AAAAAAAAC6Q/PZpKUTMatEo/s320/socialnets.png" width="320" /&gt;&lt;/div&gt;
&lt;span style="background-color: transparent;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;span style="background-color: transparent;"&gt;Often however, I find interesting stuff that's worth sharing which might be short comments, videos or even just links to nice blog articles I encounter while working/browsing the web. &lt;/span&gt;&lt;a href="http://twitter.com/juristr" style="background-color: transparent;"&gt;Twitter&lt;/a&gt;&lt;span style="background-color: transparent;"&gt; is an option but its char limit is not always suitable. As a result I started to experiment with a &lt;/span&gt;&lt;b style="background-color: transparent;"&gt;parallel Tumblr blog&lt;/b&gt;&lt;span style="background-color: transparent;"&gt; to this one here. Tumblr's philosophy exactly matches this need for sharing short posts, links or videos.&lt;/span&gt;&lt;br /&gt;
&lt;blockquote class="tr_bq"&gt;
Tumblr lets you effortlessly share anything. Post text, photos, quotes, links, music, and videos, from your browser, phone, desktop, email, or wherever you happen to be. You can customize everything, from colors, to your theme's HTML. And we're here to help!&lt;/blockquote&gt;
Let's see whether Tumblr works for me. So, you can follow me on&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;This blog&lt;/b&gt; here ;)&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&lt;a href="http://twitter.com/juristr"&gt;Twitter&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;You will get my personal status updates, links, Tumblr posts as well as Blog posts published here.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://developerlog.tumblr.com/"&gt;&lt;b&gt;Tumblr&lt;/b&gt;&lt;/a&gt;&lt;br /&gt;This is the new blog where I'd like to share more quick and concise infos like links, videos, short comments, code pieces etc.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.facebook.com/pages/Juri-Strumpflohners-TechBlog/157432560964701"&gt;&lt;b&gt;Facebook: Juri Strumpflohner's TechBlog Fanpage&lt;/b&gt;&lt;/a&gt;&lt;br /&gt;Similar as Twitter, an aggregation of my blog posts as well as those from Tumblr. This is just for convenience if you'd like to have them nicely integrated into your daily Facebook news stream. (Just click "Like" on the Facebook box in the sidebar of this blog).&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Google+ Public Stream&lt;/b&gt;&lt;br /&gt;Well, yes. You might search and follow me there as well but sincerely I don't use it that much as other networks, yet.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
Enjoy.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5211228043243414701-5097551736916044512?l=blog.js-development.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/EhyCpp1yELtg15wSi1JdLxM2ONY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/EhyCpp1yELtg15wSi1JdLxM2ONY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/EhyCpp1yELtg15wSi1JdLxM2ONY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/EhyCpp1yELtg15wSi1JdLxM2ONY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/juristrumpflohner/~4/XZbPYmSXn50" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/juristrumpflohner/~3/XZbPYmSXn50/my-tumblr-stream-developers-work-log.html</link><author>noreply@blogger.com (Juri Strumpflohner)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-f9F2f6eO11I/TqcrDY0ZfzI/AAAAAAAAC6Q/PZpKUTMatEo/s72-c/socialnets.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://blog.js-development.com/2011/10/my-tumblr-stream-developers-work-log.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5211228043243414701.post-6096038101962930425</guid><pubDate>Mon, 10 Oct 2011 13:32:00 +0000</pubDate><atom:updated>2011-11-07T21:42:47.524+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">JavaScript</category><category domain="http://www.blogger.com/atom/ns#">MVC</category><category domain="http://www.blogger.com/atom/ns#">Design Patterns</category><category domain="http://www.blogger.com/atom/ns#">Web dev</category><title>What? Model-View-Controller in JavaScript?</title><description>At work I'm currently working on a new web architecture composed of a rich client written in JavaScript and an ASP.net MVC server-side backend exposing a REST-like JSON api. An important part of that work is to also train developers on that, quite new way of programming web-apps.
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://advertisements.2291090.n4.nabble.com/file/n3524722/QUESTION.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="200" src="http://advertisements.2291090.n4.nabble.com/file/n3524722/QUESTION.jpg" width="171" /&gt;&lt;/a&gt;&lt;/div&gt;
And actually, devs are quite surprised when I mention the term MVC and JavaScript in one sentence?
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;blockquote&gt;
"Ok...I understand the MVC concept now and the benefits are clear..but JavaScript?"&lt;/blockquote&gt;
I fully understand their doubts or astonishment. That's the problem with JavaScript and web developers. For many years (and even now) JavaScript has been purely used as a scripting language, for quickly hacking in some dynamic behavior in your web application that was mainly rendered by some "fat" (IIS ASP.net / Apache JBoss) server. How did that look like??&lt;br /&gt;
&lt;pre class="brush:javascript"&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;script type="text/javascript"&amp;gt;
function performAction(){
   var dropdown = document.getElementById("myDropdown");
   if(dropdown.selectedIndex == .....)
       document.getElementById("theDiv").style.display = "none";
   ...
}
&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
   ...
   &amp;lt;input type="button" value="doAction" onClick="performAction()"/&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/pre&gt;
Something like this, right? I'm speaking out of experience. That's JavaScript used as a "scripting language", fully procedural, hooked in globally on the window object far away from any best practice or object oriented approach (nor to speak about testability).&lt;br /&gt;
&lt;br /&gt;
Enough, let's talk about MVC.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: large;"&gt;&lt;b&gt;The "messy", structureless codebase&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre class="brush:javascript highlight:[5]"&gt;function showOutput(){
  var name = "Juri";
  var age = 26;
  
  var output = "Hi, my name is &lt;i&gt;" + name + "&lt;/i&gt; and I'm &lt;i&gt;" + age + "&lt;/i&gt; years old.";
  $(".output").html(output);
}
&lt;/pre&gt;
and the according HTML page
&lt;br /&gt;
&lt;div style="text-align: right;"&gt;
&lt;span style="font-size: x-small;"&gt;&lt;a href="http://jsbin.com/oyazib/3/edit"&gt;http://jsbin.com/oyazib/3/edit&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class="brush:html highlight:[12]"&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;meta charset=utf-8 /&amp;gt;
&amp;lt;title&amp;gt;JS Bin&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
  &amp;lt;div id="view"&amp;gt;
    &amp;lt;strong&amp;gt;Output:&amp;lt;/strong&amp;gt;
    &amp;lt;div class="output"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;input id="btnClickMe" type="button" value="Click me" onClick="showOutput()"/&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/pre&gt;
I guess this is what might seem most familiar to you. The "onClick" event is directly registered on the button (line 12) which invokes a global function "showOutput" which in turn processes the embedded output and sets it to a given div element.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style="font-size: large;"&gt;Converting the example to be more MVC-like&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Step 1: Remove the event registering code from the HTML code.&lt;/b&gt;&lt;/u&gt;
&lt;br /&gt;
In a first step we remove the event registering code from the above example s.t. the code looks as follows:&lt;br /&gt;
&lt;pre class="brush:javascript highlight:[10]"&gt;function showOutput(){
  var name = "Juri";
  var age = 26;
  
  var output = "Hi, my name is &lt;i&gt;" + name + "&lt;/i&gt; and I'm &lt;i&gt;" + age + "&lt;/i&gt; years old.";
  $(".output").html(output);
}

$(document).ready(function(){
  $("#btnClickMe").click(showOutput);
});&lt;/pre&gt;
and the HTML code doesn't have any knowledge about the JavaScript behind, now.
&lt;br /&gt;
&lt;div style="text-align: right;"&gt;
&lt;span style="font-size: x-small;"&gt;&lt;a href="http://jsbin.com/oyazib/4/edit"&gt;http://jsbin.com/oyazib/4/edit&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class="brush:html"&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;meta charset=utf-8 /&amp;gt;
&amp;lt;title&amp;gt;JS Bin&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
  &amp;lt;div id="view"&amp;gt;
    &amp;lt;strong&amp;gt;Output:&amp;lt;/strong&amp;gt;
    &amp;lt;div class="output"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;input id="btnClickMe" type="button" value="Click me"/&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/pre&gt;
&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Step 2: Extracting the model&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
So far the "model" wasn't really visible but rather represented by the two variables "name" and "age". Let's create a simple JavaScript object that encapsulates this data:
&lt;br /&gt;
&lt;div style="text-align: right;"&gt;
&lt;span style="font-size: x-small;"&gt;&lt;a href="http://jsbin.com/oyazib/5/edit"&gt;http://jsbin.com/oyazib/5/edit&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class="brush:javascript"&gt;var Person = function(firstname, age){
  this.firstname = firstname;
  this.age = age;
};

function showOutput(){
  var aPerson = new Person("Juri", 26);  
  
  var output = "Hi, my name is &lt;i&gt;" + aPerson.firstname + "&lt;/i&gt; and I'm &lt;i&gt;" + aPerson.age + "&lt;/i&gt; years old.";
  $(".output").html(output);
}

$(document).ready(function(){
  $("#btnClickMe").click(showOutput);
});&lt;/pre&gt;
The HTML code remains unchanged.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Step 3: Moving the presentation logic where it belongs to&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
The major thing that still disturbs in the above code is the presentation logic that is encoded in line 9. This is pure presentation logic. To solve this problem we use a templating engine. For simplicity reasons I've chosen &lt;a href="http://api.jquery.com/jquery.tmpl/"&gt;jQuery tmpl&lt;/a&gt;&amp;nbsp;but there are numerous others like &lt;a href="http://aefxx.com/jquery-plugins/jqote2/"&gt;jQote&lt;/a&gt; and &lt;a href="http://embeddedjs.com/"&gt;EJS templates&lt;/a&gt;.&lt;br /&gt;
First, the view:
&lt;br /&gt;
&lt;pre class="brush:html"&gt;&amp;lt;script type="text/x-jquery-tmpl" id="personView"&amp;gt;
  Hi, my name is &amp;lt;i&amp;gt;${firstname}&amp;lt;/i&amp;gt; and I'm &amp;lt;i&amp;gt;${age}&amp;lt;/i&amp;gt; old.
&amp;lt;/script&amp;gt;&lt;/pre&gt;
The strange &lt;code&gt;${...}&lt;/code&gt; are the jQuery tmpl placeholders. The according JavaScript code now looks as follows:
&lt;br /&gt;
&lt;div style="text-align: right;"&gt;
&lt;span style="font-size: x-small;"&gt;&lt;a href="http://jsbin.com/oyazib/7/edit"&gt;http://jsbin.com/oyazib/7/edit&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class="brush:javascript highlight:[9,10]"&gt;var Person = function(firstname, age){
  this.firstname = firstname;
  this.age = age;
};

function showOutput(){
  var aPerson = new Person("Juri", 26);  
  
  var output = $("#personView").tmpl(aPerson);
  $(".output").html(output);
}

$(document).ready(function(){
  $("#btnClickMe").click(showOutput);
});&lt;/pre&gt;
Note the highlighted lines 9 and 10. There is no view-related code any more, but rather we invoke jQuery tmpl with the given view and pass in the data. The HTML code remains unchanged, except the jQuery tmpl view which is added at the end of the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; section.
Now that we have the model and the view extracted, where's the controller??&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Step 4: The controller, refining the big picture&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
The controller is nothing else but the glue that keeps together the model and the view. It knows from where to the fetch the model and which view to use. In fact, it is already present in the JavaScript code that has been shown so far. Have a look at the big picture:&lt;br /&gt;
&lt;b&gt;The Model:&lt;/b&gt;
&lt;br /&gt;
&lt;pre class="brush:javascript"&gt;var Person = function(firstname, age){
  this.firstname = firstname;
  this.age = age;
};&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;The View:&lt;/b&gt;
&lt;br /&gt;
&lt;pre class="brush:html"&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="http://ajax.aspnetcdn.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;meta charset=utf-8 /&amp;gt;
&amp;lt;title&amp;gt;JS Bin&amp;lt;/title&amp;gt;

&amp;lt;script type="text/x-jquery-tmpl" id="personView"&amp;gt;
  Hi, my name is &amp;lt;i&amp;gt;${firstname}&amp;lt;/i&amp;gt; and I'm &amp;lt;i&amp;gt;${age}&amp;lt;/i&amp;gt; old.
&amp;lt;/script&amp;gt;
  
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
  &amp;lt;div id="view"&amp;gt;
    &amp;lt;strong&amp;gt;Output:&amp;lt;/strong&amp;gt;
    &amp;lt;div class="output"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;input id="btnClickMe" type="button" value="Click me"/&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;The Controller:&lt;/b&gt;
&lt;br /&gt;
&lt;pre class="brush:javascript"&gt;$(document).ready(function(){
  $("#btnClickMe").click(function(){
    var aPerson = new Person("Juri", 26);  
  
    var output = $("#personView").tmpl(aPerson);
    $(".output").html(output); 
  });
});&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style="font-size: large;"&gt;Conclusion&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
The example mentioned in this post is very basic and simple but still, I think it perfectly reflects what the MVC pattern is about and how a possible implementation in JavaScript could look like.&lt;br /&gt;
Obviously this is a simple example with the purpose of understanding the concepts. In a real-world application you would probably rely on the numerous JavaScript MVC frameworks that are available.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: large;"&gt;&lt;b&gt;Now for the advanced among you&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
For the more JavaScript-literate guys among you, I'd even go a step further and make the MVC model more clear by extracting the controller's logic into a reusable jQuery plugin.
&lt;br /&gt;
The controller is now encapsulated into a jQuery plugin which takes a view and a model to handle.
&lt;br /&gt;
&lt;pre class="brush:javascript"&gt;//Controller
(function($){
  
  $.fn.personcontroller = function(model){ 

    //register events
    $("input[type=button]", this).click(function(){ 
      var output = $("#personView").tmpl(model);
      $(".output").html(output); 
    });
    
  };
  
})(jQuery);
&lt;/pre&gt;
Finally, there is the application entry code which hooks up the controller:
&lt;br /&gt;
&lt;pre class="brush:javascript"&gt;//Main of the "application"
$(document).ready(function(){
  var aPerson = new Person("Juri", 26);
  $("#view").personcontroller(aPerson);
});&lt;/pre&gt;
I guess now the separation is perfectly visible. The controller registers itself on a view where it hooks on the click event and visualizes the model that has been passed.&lt;br /&gt;
&lt;br /&gt;
The live code can be found here:&amp;nbsp;&lt;a href="http://jsbin.com/oyazib/11/edit"&gt;http://jsbin.com/oyazib/latest/edit&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5211228043243414701-6096038101962930425?l=blog.js-development.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/But5qgrDkbY8Qm8t2txvjjggIM8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/But5qgrDkbY8Qm8t2txvjjggIM8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/But5qgrDkbY8Qm8t2txvjjggIM8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/But5qgrDkbY8Qm8t2txvjjggIM8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/juristrumpflohner/~4/l4a45hd6rDE" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/juristrumpflohner/~3/l4a45hd6rDE/what-model-view-controller-in.html</link><author>noreply@blogger.com (Juri Strumpflohner)</author><thr:total>0</thr:total><feedburner:origLink>http://blog.js-development.com/2011/10/what-model-view-controller-in.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5211228043243414701.post-7691135121255080309</guid><pubDate>Sat, 08 Oct 2011 19:16:00 +0000</pubDate><atom:updated>2011-11-07T21:42:47.536+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">JavaScript</category><category domain="http://www.blogger.com/atom/ns#">Tech vids</category><category domain="http://www.blogger.com/atom/ns#">Web dev</category><title>TechVid: Become a Javascript Console Power-User</title><description>A nice 7 minute video showing some Chrome, Opera and Firefox power user commands for the JavaScript console.&lt;br /&gt;
&lt;br /&gt;
&lt;iframe allowfullscreen="" frameborder="0" height="315" src="http://www.youtube.com/embed/4mf_yNLlgic" width="420"&gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5211228043243414701-7691135121255080309?l=blog.js-development.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/xIaNo68K29Zad3KCQMzs1faEI74/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/xIaNo68K29Zad3KCQMzs1faEI74/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/xIaNo68K29Zad3KCQMzs1faEI74/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/xIaNo68K29Zad3KCQMzs1faEI74/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/juristrumpflohner/~4/zdeFHs8Kpnk" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/juristrumpflohner/~3/zdeFHs8Kpnk/techvid-become-javascript-console-power.html</link><author>noreply@blogger.com (Juri Strumpflohner)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://img.youtube.com/vi/4mf_yNLlgic/default.jpg" height="72" width="72" /><thr:total>1</thr:total><feedburner:origLink>http://blog.js-development.com/2011/10/techvid-become-javascript-console-power.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5211228043243414701.post-4550022738634342167</guid><pubDate>Mon, 03 Oct 2011 19:49:00 +0000</pubDate><atom:updated>2011-11-07T21:42:47.513+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">JavaScript</category><category domain="http://www.blogger.com/atom/ns#">C#</category><category domain="http://www.blogger.com/atom/ns#">Web dev</category><title>The Similarity of C# and JavaScript Syntax</title><description>I'm currently diving deeply into creating rich JavaScript web applications. You cannot deny that they are now the must have for modern-looking web (2.0) apps. They are &lt;a href="https://read.amazon.com/"&gt;rich, user-friendly&lt;/a&gt; and provide a &lt;a href="http://trello.com/"&gt;desktop-like experience&lt;/a&gt; within the browser..without the need to install heavy applications or &lt;a href="http://www.silverlight.net/"&gt;runtimes&lt;/a&gt;. While initially building such apps was a pure pain, emerging JavaScript frameworks and libraries make it really fun and easy. So webdevs out there...if you want to keep up, go and get in touch with JavaScript. &lt;b&gt;It is&lt;/b&gt; the language of programming the web :).&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;Just when coding some JavaScript I noted that the syntax between C# and JavaScript is actually quite similar. Take these examples:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: large;"&gt;Variables&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;C#&lt;/b&gt;
&lt;br /&gt;
&lt;pre class="brush:c#"&gt;var x = "some string";&lt;/pre&gt;
&lt;b&gt;JavaScript&lt;/b&gt;&lt;br /&gt;
&lt;pre class="brush:javascript"&gt;var x = "some string";&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: large;"&gt;Anonymous Object initialization&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;C#&lt;/b&gt;
&lt;br /&gt;
&lt;pre class="brush:c#"&gt;var x = new {
   Name = "Juri",
   Surname = "Strumpflohner"
};&lt;/pre&gt;
&lt;b&gt;JavaScript&lt;/b&gt;
&lt;br /&gt;
&lt;pre class="brush:javascript"&gt;var x = {
   name: "Juri",
   surname: "Strumpflohner"
};&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: large;"&gt;Delegates/Callbacks&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;C#&lt;/b&gt;
&lt;br /&gt;
&lt;pre class="brush:c#"&gt;var result = SomeFunction(
   () =&amp;gt; {
      //A delegate method performing some work
   }
);&lt;/pre&gt;
&lt;b&gt;JavaScript&lt;/b&gt;
&lt;br /&gt;
&lt;pre class="brush:javascript"&gt;var result = someFunction(function (){
   //callback / delegate
});&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5211228043243414701-4550022738634342167?l=blog.js-development.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/aM3SRMI9TTu-MQeESIIaMW36ulk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/aM3SRMI9TTu-MQeESIIaMW36ulk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/aM3SRMI9TTu-MQeESIIaMW36ulk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/aM3SRMI9TTu-MQeESIIaMW36ulk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/juristrumpflohner/~4/A4xn0LVW0Do" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/juristrumpflohner/~3/A4xn0LVW0Do/similarity-of-c-and-javascript-syntax.html</link><author>noreply@blogger.com (Juri Strumpflohner)</author><thr:total>0</thr:total><feedburner:origLink>http://blog.js-development.com/2011/10/similarity-of-c-and-javascript-syntax.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5211228043243414701.post-1878076328413858955</guid><pubDate>Mon, 26 Sep 2011 18:50:00 +0000</pubDate><atom:updated>2011-11-07T21:42:47.476+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">JavaScript</category><category domain="http://www.blogger.com/atom/ns#">Unit Testing</category><category domain="http://www.blogger.com/atom/ns#">Exploring JavaScript</category><category domain="http://www.blogger.com/atom/ns#">Software testing</category><category domain="http://www.blogger.com/atom/ns#">jQuery</category><title>Testing JavaScript: Mocking jQuery Ajax Calls</title><description>When "seriously" developing JavaScript applications we obviously need to write tests. Being a fully dynamic language (similar as Ruby), tests are more necessary than ever since there is no compiler that checks for you all the silly mistakes before you run your code the first time. What also remains important is the distinction between integration tests and unit tests.&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
So mocking comes to play immediately as I wouldn't want to establish any contact to the server from within my unit tests. Consider the following jQuery call:&lt;br /&gt;
&lt;pre class="brush:javascript"&gt;function fetchPerson(id){
   $.ajax({
      type: "GET",
      url: "/person/" + id,
      success: function(data){
         ...
      }
      ...
   });
}
&lt;/pre&gt;
To steer the "data" that is returned by such ajax call (without actually performing it), you can just override jQuery's &lt;code&gt;ajax&lt;/code&gt; method.&lt;br /&gt;
&lt;pre class="brush:javascript"&gt;(function($){

   $.ajax = function(params){
      if(params.url === "/person/1"){
         params.success({ ... }); //return the data you need
      }
   });

})(jQuery);
&lt;/pre&gt;
This is the power a dynamic languages gives you and may be very helpful not only while testing but also during development. Consider when you don't yet have the server-side implemented and ready to feed data to your JavaScript rich client? You can program your whole application using jQuery as you'd do and then include an additional file that overrides the jQuery ajax method returning the fake data you'd expect from the server-api. Once the server-side is ready you just remove the JavaScript include containing the jQuery override and you'd start communicate with the real server, without touching any application-code.&lt;br /&gt;
&lt;br /&gt;
Actually it somehow feels a bit like AOP, where you define an aspect telling it to crosscut all ajax calls and replace it with the defined behavior.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5211228043243414701-1878076328413858955?l=blog.js-development.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/cs6A3Y-kk-YKddUINjHfjZURnG0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/cs6A3Y-kk-YKddUINjHfjZURnG0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/cs6A3Y-kk-YKddUINjHfjZURnG0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/cs6A3Y-kk-YKddUINjHfjZURnG0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/juristrumpflohner/~4/dUP4egYAMXs" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/juristrumpflohner/~3/dUP4egYAMXs/testing-javascript-mocking-jquery-ajax.html</link><author>noreply@blogger.com (Juri Strumpflohner)</author><thr:total>0</thr:total><feedburner:origLink>http://blog.js-development.com/2011/09/testing-javascript-mocking-jquery-ajax.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5211228043243414701.post-4308125703297976863</guid><pubDate>Thu, 01 Sep 2011 12:37:00 +0000</pubDate><atom:updated>2011-11-07T21:42:47.506+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">JavaScript</category><category domain="http://www.blogger.com/atom/ns#">Exploring JavaScript</category><category domain="http://www.blogger.com/atom/ns#">Web dev</category><title>JavaScript Scoping by Example</title><description>Understanding the scoping rules of JavaScript is one of the fundamental things to learn when getting started with the language. I just found &lt;a href="http://twitter.com/#!/codylindley/status/108152873438814208"&gt;this link&lt;/a&gt; posted by &lt;a href="http://twitter.com/#!/codylindley"&gt;@codylindley&lt;/a&gt; on Twitter. It goes over some basic principles of jQuery, however the first part covers native JavaScript scoping. It is an interesting example to get an understanding about it.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
Take the following piece of JavaScript:&lt;br /&gt;
&lt;div style="text-align: right;"&gt;
&lt;a href="http://jsbin.com/ayibam/2/edit#javascript,live"&gt;&lt;span style="font-size: x-small;"&gt;Live example&lt;/span&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;pre class="brush:javascript"&gt;var x = "Hi";

var someFunction = (function(){
  document.getElementById("out").innerHTML = x;
});

someFunction();&lt;/pre&gt;
The example is quite simple. There is &lt;code&gt;x&lt;/code&gt;, which is defined in the global scope, followed by the definition of a function which gets stored in the &lt;code&gt;someFunction&lt;/code&gt; variable. &lt;code&gt;someFunction&lt;/code&gt; gets called immediately afterwards, printing out the value of &lt;code&gt;x&lt;/code&gt; to the HTML element "out". When executed, we get "Hi" as a result.&lt;br /&gt;
&lt;b&gt;Why does this happen?&lt;/b&gt;&amp;nbsp;In order to understand this, you need to understand that JavaScript has &lt;b&gt;function scope&lt;/b&gt;, meaning that when printing out x, it will first search for a definition within the function itself, and then it will walk up the prototype chain in order to find a corresponding variable definition. In the specific example above, it will go up till it reaches the global (window) object where x is defined.&lt;br /&gt;
&lt;br /&gt;
If now the example above gets modified as follows, can you guess what will be its output??&lt;br /&gt;
&lt;div style="text-align: right;"&gt;
&lt;a href="http://jsbin.com/ayibam/3/edit#javascript,live"&gt;&lt;span style="font-size: x-small;"&gt;Live example&lt;/span&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;pre class="brush:javascript"&gt;var x = "Hi";

var someFunction = (function(){
  document.getElementById("out").innerHTML = x;
  var x = "Hi, there!";
});

someFunction();&lt;/pre&gt;
Actually the output is "undefined". This is due to the &lt;b&gt;lexical function scoping&lt;/b&gt;, meaning the scoping rules are applied at &lt;b&gt;function-definition,&lt;/b&gt;&amp;nbsp;not at runtime. Btw, this kind of mechanism also allows for having &lt;b&gt;closures&lt;/b&gt;. Hence, x is defined within the function's scope, but just not at the moment when it was printed out.&lt;br /&gt;
&lt;br /&gt;
To fix this one would have to explicitly let x point to the globally defined one like&lt;br /&gt;
&lt;div style="text-align: right;"&gt;
&lt;a href="http://jsbin.com/ayibam/4/edit#javascript,live"&gt;&lt;span style="font-size: x-small;"&gt;Live example&lt;/span&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;pre class="brush:javascript"&gt;var x = "Hi";

var someFunction = (function(){
  document.getElementById("out").innerHTML = window.x;
  var x = "Hi, there!";
});

someFunction();&lt;/pre&gt;
Now it again works.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5211228043243414701-4308125703297976863?l=blog.js-development.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/BjyASUdpXlHZbk-zm0cez_uFT0k/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/BjyASUdpXlHZbk-zm0cez_uFT0k/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/BjyASUdpXlHZbk-zm0cez_uFT0k/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/BjyASUdpXlHZbk-zm0cez_uFT0k/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/juristrumpflohner/~4/TIR-iISCPSo" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/juristrumpflohner/~3/TIR-iISCPSo/javascript-scoping-by-example.html</link><author>noreply@blogger.com (Juri Strumpflohner)</author><thr:total>0</thr:total><feedburner:origLink>http://blog.js-development.com/2011/09/javascript-scoping-by-example.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5211228043243414701.post-586870377196621868</guid><pubDate>Sun, 28 Aug 2011 21:00:00 +0000</pubDate><atom:updated>2011-11-07T21:42:28.353+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">JavaScript</category><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Spring</category><category domain="http://www.blogger.com/atom/ns#">Web dev</category><category domain="http://www.blogger.com/atom/ns#">Software Design</category><title>Integrating Jersey with Spring</title><description>Spring provides a lot of benefits and promotes best practices with its dependency injection mechanism, application lifecycle management and Hibernate support (just to mention some). In addition when you want to have a clean server-side REST-like JSON Api, I found &lt;a href="http://www.vogella.de/articles/REST/article.html"&gt;Jersey&lt;/a&gt; to be quite handy. This article briefly highlights how both of them can be integrated.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
In my little spare time I'm currently trying to revive one of my earlier private projects which never exited the private beta (I'll write more about it once I publish it). The project consists of a JavaScript rich client interface with a Java server "back-end" hosted on Google AppEngine. I'm currently completely rewriting it and so I started out cleanly by creating a Jersey REST Api on the server-side, that exposes it's data in JSON. An example of such Jersey-exposed class is the following:&lt;br /&gt;
&lt;pre class="brush:java"&gt;@Path("/sourcecodeitems")
public class SourceCodeItemGateway {	
	...
	
	@GET
	@Produces(MediaType.APPLICATION_JSON)
	public List&amp;lt;SourceCodeItemDTO&amp;gt; index(){
		ArrayList&amp;lt;SourceCodeItemDTO&amp;gt; listOfItems = new ArrayList&amp;lt;SourceCodeItemDTO&amp;gt;();
		
		for (SourceCodeItem item : sourceCodeItems) {
			listOfItems.add(new SourceCodeItemDTO(item));
		}
		
		return listOfItems;
	}
	
	...	
}&lt;/pre&gt;
Actually this is quite similar (just a bit more complicated ;)) to an &lt;a href="http://blog.js-development.com/2011/08/why-did-it-have-to-be-so-complicated.html"&gt;ASP.net MVC controller as described here&lt;/a&gt;. The according web.config looks as follows:&lt;br /&gt;
&lt;pre class="brush:xml; highlight:[12,15]"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
	version="2.5"&amp;gt;
	&amp;lt;servlet&amp;gt;
        &amp;lt;servlet-name&amp;gt;Jersey Web Application&amp;lt;/servlet-name&amp;gt;
        &amp;lt;servlet-class&amp;gt;com.sun.jersey.spi.container.servlet.ServletContainer&amp;lt;/servlet-class&amp;gt;
        &amp;lt;init-param&amp;gt;
            &amp;lt;param-name&amp;gt;com.sun.jersey.config.property.packages&amp;lt;/param-name&amp;gt;
            &amp;lt;param-value&amp;gt;com.jsdev.myproject.service&amp;lt;/param-value&amp;gt;
        &amp;lt;/init-param&amp;gt;
        &amp;lt;init-param&amp;gt;
			&amp;lt;param-name&amp;gt;com.sun.jersey.api.json.POJOMappingFeature&amp;lt;/param-name&amp;gt;
			&amp;lt;param-value&amp;gt;true&amp;lt;/param-value&amp;gt;
		&amp;lt;/init-param&amp;gt;
        &amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;
    &amp;lt;/servlet&amp;gt;
    &amp;lt;servlet-mapping&amp;gt;
        &amp;lt;servlet-name&amp;gt;Jersey Web Application&amp;lt;/servlet-name&amp;gt;
        &amp;lt;url-pattern&amp;gt;/backend/*&amp;lt;/url-pattern&amp;gt;
    &amp;lt;/servlet-mapping&amp;gt;
	&amp;lt;welcome-file-list&amp;gt;
		&amp;lt;welcome-file&amp;gt;welcome.jsp&amp;lt;/welcome-file&amp;gt;
	&amp;lt;/welcome-file-list&amp;gt;
&amp;lt;/web-app&amp;gt;&lt;/pre&gt;
&lt;b&gt;Line 12&lt;/b&gt;&amp;nbsp;indicates the package where your Jersey resources lie and &lt;b&gt;line 15&lt;/b&gt;&amp;nbsp;activates the auto-mapping feature of your POJOs to Json.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: large;"&gt;&lt;b&gt;Integrating with Spring&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
In order to integrate Jersey with Spring, you first need to include the &lt;b&gt;jersey-spring-&amp;lt;version&amp;gt;.jar&lt;/b&gt;&amp;nbsp;that comes with the Jersey package download. Include it in your build-path. You can then either configure your Jersey resource (SourceCodeItemGateway above) using Spring annotations (@Component) or to do it xml-based like...&lt;br /&gt;
&lt;pre class="brush:xml; highlight:[8]"&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
	     http://www.springframework.org/schema/beans/spring-beans.xsd"&amp;gt;


	&amp;lt;bean name="sourceCodeItemGateway" class="com.jsdev.mydevbook.service.SourceCodeItemGateway"&amp;gt;
		&amp;lt;property name="pingService" ref="pingService"/&amp;gt;
	&amp;lt;/bean&amp;gt;
	
	&amp;lt;bean id="pingService" class="com.jsdev.myproject.service.PingService"&amp;gt;
	&amp;lt;/bean&amp;gt;

&amp;lt;/beans&amp;gt;&lt;/pre&gt;
&lt;b&gt;Line 8&lt;/b&gt;&amp;nbsp;shows the bean configuration of the Jersey resource class as well as a configured dependency (PingService) which will be managed and injected by Spring. Finally, you&amp;nbsp;need to adapt the web.config file to properly hook in Spring with Jersey:&lt;br /&gt;
&lt;pre class="brush:xml; highlight:[4,25,26]"&gt;&amp;lt;servlet&amp;gt;
    &amp;lt;servlet-name&amp;gt;jersey-servlet&amp;lt;/servlet-name&amp;gt;
    &amp;lt;servlet-class&amp;gt;
        com.sun.jersey.spi.spring.container.servlet.SpringServlet
    &amp;lt;/servlet-class&amp;gt;
	&amp;lt;init-param&amp;gt;
           &amp;lt;param-name&amp;gt;com.sun.jersey.config.property.packages&amp;lt;/param-name&amp;gt;
           &amp;lt;param-value&amp;gt;com.jsdev.myproject.service&amp;lt;/param-value&amp;gt;
       &amp;lt;/init-param&amp;gt;
	&amp;lt;init-param&amp;gt;
		&amp;lt;param-name&amp;gt;com.sun.jersey.api.json.POJOMappingFeature&amp;lt;/param-name&amp;gt;
		&amp;lt;param-value&amp;gt;true&amp;lt;/param-value&amp;gt;
	&amp;lt;/init-param&amp;gt;
	&amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;
&amp;lt;/servlet&amp;gt;

&amp;lt;servlet-mapping&amp;gt;
    &amp;lt;servlet-name&amp;gt;jersey-servlet&amp;lt;/servlet-name&amp;gt;
    &amp;lt;url-pattern&amp;gt;/backend/*&amp;lt;/url-pattern&amp;gt;
&amp;lt;/servlet-mapping&amp;gt;

&amp;lt;context-param&amp;gt;
	&amp;lt;param-name&amp;gt;contextConfigLocation&amp;lt;/param-name&amp;gt;
	&amp;lt;param-value&amp;gt;
		/WEB-INF/spring-service.xml
		/WEB-INF/spring-data.xml
   	&amp;lt;/param-value&amp;gt;
&amp;lt;/context-param&amp;gt;&lt;/pre&gt;
Note in &lt;b&gt;line 4&lt;/b&gt;&amp;nbsp;how we instantiate the Jersey SpringServlet. &lt;b&gt;Line 25 and 26&lt;/b&gt;&amp;nbsp;show the path to the Spring configuration files. The previously shown bean configuration is an excerpt from the spring-service.xml. spring-data.xml is supposed to contain everything related to the data access.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5211228043243414701-586870377196621868?l=blog.js-development.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/ZkaMSvOXTTn_ia0IYCqTFhg1QFo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ZkaMSvOXTTn_ia0IYCqTFhg1QFo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/ZkaMSvOXTTn_ia0IYCqTFhg1QFo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ZkaMSvOXTTn_ia0IYCqTFhg1QFo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/juristrumpflohner/~4/baOPUdr1J04" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/juristrumpflohner/~3/baOPUdr1J04/integrating-jersey-with-spring.html</link><author>noreply@blogger.com (Juri Strumpflohner)</author><thr:total>0</thr:total><feedburner:origLink>http://blog.js-development.com/2011/08/integrating-jersey-with-spring.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5211228043243414701.post-7922916862296504697</guid><pubDate>Fri, 26 Aug 2011 14:08:00 +0000</pubDate><atom:updated>2011-11-07T21:42:28.379+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">JavaScript</category><category domain="http://www.blogger.com/atom/ns#">Unit Testing</category><category domain="http://www.blogger.com/atom/ns#">MVC</category><category domain="http://www.blogger.com/atom/ns#">ASP.net</category><category domain="http://www.blogger.com/atom/ns#">Software testing</category><category domain="http://www.blogger.com/atom/ns#">Web dev</category><category domain="http://www.blogger.com/atom/ns#">.Net</category><title>Why Did it Have to Be So Complicated Before??</title><description>I started&amp;nbsp;web development using Java, basically during my studies at the university. When working on my bachelor degree thesis I needed a web server back-end system (to my mobile J2ME client); I decided to do it "right". Spring (especially Spring.Web) for the application server part and Hibernate for the object relational mapping. Although having quite a tough time getting up that initial learning curve, the result payed out so well: everything nicely decoupled and testable. I loved it. Then, when starting to work professionally as a .Net developer things got more painful...&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
After my studies (parallel to continuing with the MSc) I started to work professionally as a .Net developer, getting in touch with Asp.net (WebForms). And that&lt;b&gt; just felt so strange&lt;/b&gt;. "Postback", "ViewState",...it was like imposing the WinForms technology on top of the web. Where was the usual request/response pattern?? &lt;b&gt;Testability??&lt;/b&gt; Sure, you can, but you don't want to fight with all the necessary setup you need to deal with when testing an ASP.net WebForms Page. The only way is to ensure that you keep that logic at a minimum possible and to rather defer it to some business layer class which is completely web-agnostic and which then can definitely be tested. And indeed, this is what our internal framework/class-library helped us to do.&lt;br /&gt;
&lt;br /&gt;
Now we decided to change that, seriously evaluating ASP.net MVC as our server-side technology. And that&lt;b&gt; feels so much like returning home&lt;/b&gt; :). And I'm really satisfied what I've seen so far from Microsoft regarding MVC. They really seem to have gotten it right this time. Everything is clearly separated, abstracted, exchangeable and mainly, &lt;b&gt;testable!&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Consider this really dummy ASP.net MVC controller:&lt;br /&gt;
&lt;pre class="brush:c#"&gt;public class AccountController : Controller
{
   ...

   [HttpPost]
   public JsonResult Filter(Account account)
   {
       return Json(new List&amp;amp;lt;Account&amp;amp;gt;()
       {
           new Account()
       });
   }

   ...
}&lt;/pre&gt;
and the corresponding (if also naive) test case:&lt;br /&gt;
&lt;pre class="brush:c#"&gt;[TestMethod]
public void TestFilter_FilterJuriStrumpflohner_ShouldReturnAccountInstance()
{
    //Arrange
    Account filterAccount = new Account()
    {
            Lastname = "Strumpflohner"
    };

    //Act
    JsonResult result = new AccountController().Filter(filterAccount);
    IList&amp;amp;lt;Account&amp;amp;gt; filterResult = result.Data as IList&amp;amp;lt;Account&amp;amp;gt;;

    //Assert
    Assert.AreEqual(1, filterResult.Count, "There should be only one result");
}&lt;/pre&gt;
Now, isn't this simple??&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5211228043243414701-7922916862296504697?l=blog.js-development.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/xUf7ID4obB_wXOBSgPRB1Yn8eOg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/xUf7ID4obB_wXOBSgPRB1Yn8eOg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/xUf7ID4obB_wXOBSgPRB1Yn8eOg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/xUf7ID4obB_wXOBSgPRB1Yn8eOg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/juristrumpflohner/~4/dcCdHmp07-M" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/juristrumpflohner/~3/dcCdHmp07-M/why-did-it-have-to-be-so-complicated.html</link><author>noreply@blogger.com (Juri Strumpflohner)</author><thr:total>0</thr:total><feedburner:origLink>http://blog.js-development.com/2011/08/why-did-it-have-to-be-so-complicated.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5211228043243414701.post-2779059976708412297</guid><pubDate>Thu, 25 Aug 2011 06:36:00 +0000</pubDate><atom:updated>2011-11-07T21:42:47.492+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">JavaScript</category><category domain="http://www.blogger.com/atom/ns#">Tech vids</category><category domain="http://www.blogger.com/atom/ns#">Web dev</category><title>Chrome Developer Tools: 12 Tricks to Develop Quicker</title><description>This is definitely a "must-have-seen" video for every JavaScript developer. Chrome has some really nice features build into their developer tools which are being demonstrated in this short ~5 min video.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
Btw, you may want to subscribe to the following newsletters if you're interested in the latest web technologies:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://javascriptweekly.com/"&gt;JavaScript Weekly&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://html5weekly.com/"&gt;HTML5 Weekly&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;iframe allowfullscreen="" frameborder="0" height="345" src="http://www.youtube.com/embed/nOEw9iiopwI" width="560"&gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5211228043243414701-2779059976708412297?l=blog.js-development.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/-Dx_dTtGtySs5Qh6Hs1X9oaSXdo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-Dx_dTtGtySs5Qh6Hs1X9oaSXdo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/-Dx_dTtGtySs5Qh6Hs1X9oaSXdo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-Dx_dTtGtySs5Qh6Hs1X9oaSXdo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/juristrumpflohner/~4/GYaAPwbe_fc" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/juristrumpflohner/~3/GYaAPwbe_fc/chrome-developer-tools-12-tricks-to.html</link><author>noreply@blogger.com (Juri Strumpflohner)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://img.youtube.com/vi/nOEw9iiopwI/default.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://blog.js-development.com/2011/08/chrome-developer-tools-12-tricks-to.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5211228043243414701.post-75566894228736752</guid><pubDate>Sat, 20 Aug 2011 07:29:00 +0000</pubDate><atom:updated>2011-11-07T21:42:28.367+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">JavaScript</category><category domain="http://www.blogger.com/atom/ns#">annotated</category><category domain="http://www.blogger.com/atom/ns#">Android</category><title>Droidcon London 2011 - Europe's largest Android Conference</title><description>Droidcon London 2011 is &lt;b&gt;Europe's largest conference that exclusively covers Android development &lt;/b&gt;and applications. The conference will take place in &lt;b&gt;London on 6th-7th October 2011&lt;/b&gt;.&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://uk.droidcon.com/" style="margin-left: 1em; margin-right: 1em;"&gt;
&lt;img alt="Droidcon London Oct 6-7" border="0" src="http://uk.droidcon.com/sites/default/files/
640x150%20clear%20droids%20transp.gif" width="70%&amp;quot;" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;Droidcon London 2011 has grown tremendously since last year, in line with the exponential interest in the Android platform. This year, upward of 600 Android enthusiasts will rub shoulders with the premier experts in the field to dig into every aspect of Android and its ever-growing ecosystem. High on the agenda this time around are Android for the Tablet, Android in the Enterprise, Android for Games, Android for business, Augmented Reality, multi-mobile and a whole lot more.&lt;br /&gt;
&lt;br /&gt;
The first day will be community led with a full-day Barcamp and Democamp. The second day will be conference day, with presentations from some of the world's foremost Android experts, including two Google Developer Advocates for Android in &lt;a href="http://uk.droidcon.com/content/speakers-0#richard-hyndmann"&gt;Richard Hyndman&lt;/a&gt;&amp;nbsp;and &lt;a href="http://uk.droidcon.com/content/speakers-0#nick-butcher"&gt;Nick Butcher&lt;/a&gt;, &lt;a href="http://uk.droidcon.com/content/speakers-0#mark-murph"&gt;CommonsWare's Mark Murphy&lt;/a&gt; (author of the Busy Coder's Guide to Android Development), &lt;a href="http://uk.droidcon.com/content/speakers-0#mustafa-isik"&gt;Mustafa Isik aka CodeSurgeon&lt;/a&gt;&amp;nbsp;and &lt;a href="http://uk.droidcon.com/content/speakers-0#yosi-taguri"&gt;Yosi Taguri&lt;/a&gt; (programmer on the fantastic game, Ahhh-Pah)&amp;nbsp;with many more top class speakers still to be announced.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;You can register via the Droidcon London 2011 site:&lt;/b&gt; (&lt;a href="http://www.droidcon.co.uk/"&gt;http://www.droidcon.co.uk&lt;/a&gt;)&lt;br /&gt;
&lt;b&gt;Follow Droidcon London 2011 on Twitter:&lt;/b&gt; &lt;a href="http://twitter.com/#!/DroidconUK"&gt;@DroidconUK&lt;/a&gt; tags: #droidconUK #droidcon&lt;br /&gt;
&lt;b&gt;Follow Droidcon London 2011 on Facebook:&lt;/b&gt; &lt;a href="http://www.facebook.com/groups/droidconuk/"&gt;http://www.facebook.com/groups/droidconuk/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5211228043243414701-75566894228736752?l=blog.js-development.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/QWzBYAuMMsz-eTJswbL-IDLM6pc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/QWzBYAuMMsz-eTJswbL-IDLM6pc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/QWzBYAuMMsz-eTJswbL-IDLM6pc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/QWzBYAuMMsz-eTJswbL-IDLM6pc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/juristrumpflohner/~4/OGcrWy0qkFk" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/juristrumpflohner/~3/OGcrWy0qkFk/droidcon-london-2011-europes-largest.html</link><author>noreply@blogger.com (Juri Strumpflohner)</author><thr:total>0</thr:total><feedburner:origLink>http://blog.js-development.com/2011/08/droidcon-london-2011-europes-largest.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5211228043243414701.post-7551780055238939899</guid><pubDate>Mon, 15 Aug 2011 07:38:00 +0000</pubDate><atom:updated>2011-11-07T21:42:47.530+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">JavaScript</category><category domain="http://www.blogger.com/atom/ns#">Web dev</category><category domain="http://www.blogger.com/atom/ns#">jQuery</category><title>Experiencing the jQuery 1.6 Breaking Changes</title><description>Unfortunately I did not actively follow the &lt;b&gt;release of jQuery 1.6&lt;/b&gt; as I would probably have noted that they introduced some &lt;b&gt;breaking changes&lt;/b&gt; which would have prevented some issues at my side. So I needed to experience them the hard way :). Fortunately, though, our app was not yet in production but just end-user acceptance testing, so it didn't cause any major problem, but still...&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
Consider for instance the simple case of using the nice &lt;code&gt;.attr()&lt;/code&gt; jQuery function for verifying whether a checkbox is checked or not. So in &amp;amp;amp;lt; jQuery 1.6 I'd have written something like&lt;br /&gt;
&lt;pre class="brush:js"&gt;$("#mycheckBox").attr("checked") === true){
   //my custom logic
}
&lt;/pre&gt;
But, exactly this code would no more work reliably on jQuery 1.6 but rather I'd have to change it to&lt;br /&gt;
&lt;pre class="brush:js"&gt;$("#mycheckBox").prop("checked") === true){
   //my custom logic
}
&lt;/pre&gt;
This is because with the latest jQuery release, they made a clear &lt;b&gt;distinction between DOM attributes and properties&lt;/b&gt;.&lt;br /&gt;
&lt;blockquote&gt;
In the 1.6 release we’ve split apart the handling of DOM attributes and DOM properties into separate methods. The new .prop() method sets or gets properties on DOM elements, and .removeProp() removes properties. In the past, jQuery has not drawn a clear line between properties and attributes.&lt;br /&gt;
&lt;i&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Source: &lt;a href="http://blog.jquery.com/2011/05/03/jquery-16-released/"&gt;jQuery Blog&lt;/a&gt;&lt;/span&gt;&lt;/i&gt;&lt;/blockquote&gt;
So what is the exact difference between a DOM attribute and property? Again...&lt;br /&gt;
&lt;blockquote&gt;
Generally, DOM attributes represent the state of DOM information as retrieved from the document, such as the value attribute in the markup &lt;code&gt;&amp;amp;amp;lt;input type="text" value="abc"&amp;amp;amp;gt;&lt;/code&gt;. DOM properties represent the dynamic state of the document; for example if the user clicks in the input element above and types &lt;code&gt;def&lt;/code&gt; the &lt;code&gt;.prop("value")&lt;/code&gt; is &lt;code&gt;abcdef&lt;/code&gt; but the &lt;code&gt;.attr("value")&lt;/code&gt; remains &lt;code&gt;abc&lt;/code&gt;.&lt;br /&gt;
&lt;i&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Source: &lt;a href="http://blog.jquery.com/2011/05/03/jquery-16-released/"&gt;jQuery Blog&lt;/a&gt;&lt;/span&gt;&lt;/i&gt;&lt;/blockquote&gt;
&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5211228043243414701-7551780055238939899?l=blog.js-development.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/RtbPrspc60fsHwtHwkUq0sEgC8M/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/RtbPrspc60fsHwtHwkUq0sEgC8M/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/RtbPrspc60fsHwtHwkUq0sEgC8M/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/RtbPrspc60fsHwtHwkUq0sEgC8M/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/juristrumpflohner/~4/RgORp3WqCr0" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/juristrumpflohner/~3/RgORp3WqCr0/experiencing-jquery-16-breaking-changes.html</link><author>noreply@blogger.com (Juri Strumpflohner)</author><thr:total>0</thr:total><georss:featurename>39100 Bolzano Province of Bolzano-Bozen, Italy</georss:featurename><georss:point>46.4967153 11.3580048</georss:point><georss:box>46.4967153 11.3580048 46.4967153 11.3580048</georss:box><feedburner:origLink>http://blog.js-development.com/2011/08/experiencing-jquery-16-breaking-changes.html</feedburner:origLink></item></channel></rss>

