<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>iPROFS Technology Blog</title>
	<atom:link href="http://blog.iprofs.nl/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.iprofs.nl</link>
	<description>Java, Content Management and Portals</description>
	<lastBuildDate>Tue, 15 May 2012 09:28:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='blog.iprofs.nl' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>iPROFS Technology Blog</title>
		<link>http://blog.iprofs.nl</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.iprofs.nl/osd.xml" title="iPROFS Technology Blog" />
	<atom:link rel='hub' href='http://blog.iprofs.nl/?pushpress=hub'/>
		<item>
		<title>Bye bye XMLGregorianCalendar (part 2)</title>
		<link>http://blog.iprofs.nl/2012/05/14/bye-bye-xmlgregoriancalendar-part-2/</link>
		<comments>http://blog.iprofs.nl/2012/05/14/bye-bye-xmlgregoriancalendar-part-2/#comments</comments>
		<pubDate>Mon, 14 May 2012 10:14:31 +0000</pubDate>
		<dc:creator>mcbeelen</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[DateTime]]></category>
		<category><![CDATA[JAXB]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[xjc]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://blog.iprofs.nl/?p=2229</guid>
		<description><![CDATA[Change generated java classes with an XJC plugin. In the previous post on &#8216;Bye bye XMLGregorianCalendar&#8216; I wrote about how you can influence the (un)marshalling of xml to java objects by adding an XmlAdapter to the classpath and an XmlJavaTypeAdapter annotation to a field in the java class. This technique works fine when you are [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.iprofs.nl&#038;blog=13247689&#038;post=2229&#038;subd=iprofs&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>Change generated java classes with an XJC plugin.</h1>
<p>In the previous <a title="Bye bye XMLGregorianCalendar (part 1)" href="http://blog.iprofs.nl/2012/02/13/bye-bye-xmlgregoriancalendar-part-1/">post on &#8216;Bye bye XMLGregorianCalendar</a>&#8216; I wrote about how you can influence the (un)<a href="http://www.oracle.com/technetwork/articles/javase/index-140168.html">marshalling of xml</a> to java objects by adding an XmlAdapter to the classpath and an XmlJavaTypeAdapter annotation to a field in the java class. This technique works fine when you are actually writing the java classes your self, but: We don&#8217;t do that very often.  One of the main features of XML is that it can be validated against a schema, a contact which defines the valid options and structures with the XML. Most of the times, when we work with XML, there is a schema availabe, either as an standard defined for an industry / product or as part of the contract of a webservice. We can leverage the XSD (XML Schema Definition) to generate Java objects, which represent the elements in XML.</p>
<p>As a part of <a title="JAXB Reference Implementation" href="http://jaxb.java.net/">JAXB</a>, the Java SDK provides &#8216;xjc&#8217;, a Binding Compiler also known as an Xml-to-Java-Compiler. When running the xjc command you need to specify the location of the schema and it will generate a set of appropriate java classes for you. By default, the XJC binding compiler strictly enforces the rules outlined in the Compatibility chapter of the JAXB Specification, which will result in you having fields of the type javax.xml.datatype.XMLGregorianCalendar in your classes. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
<p>We don&#8217;t want that: We want to use DateTime of JodaTime as the type for our date fields.</p>
<p>By using the &#8220;-extension&#8221; switch of the xjc command, you are able to influence the process of java generation by activating custom JAXB Vendor Extensions. There are <a title="JAXB 2.x Commons project" href="http://java.net/projects/jaxb2-commons/pages/Home">common extensions</a> publically available, but none of those helps with replacing the XMLGregorianCalendar by properly annotated DateTime fields. Therefor you should write your own extension as an xjc plugin.</p>
<h2>Writing a custom XJC Plugin.</h2>
<p>So we are going to implement our own JodatimeJaxbPlugin, which will change the type of all date fields to DateTime and add the proper XmlJavaTypeAdapter-annotation to those fields. Implementing such an plugin is quite easy, since you just have to extend the <em>com.sun.tools.xjc.Plugin</em> and implement 3 abstract methods.</p>
<ol>
<li><span style="font-family:monospace;">String getOptionName()</span>, which specifies by which command line argument value this plugin will be triggered. The default conventions is to start your option name with a capital &#8216;X&#8217; to mark it as custom. For the JodatimeJaxbPlugin we use: &#8216;XuseJodatime&#8217;</li>
<li><span style="font-family:monospace;">String getUsage()</span>, which should return a description of this add-on.</li>
<li><span style="font-family:monospace;">boolean run(Outline outline, Options opt, ErrorHandler errorHandler)</span>. The XJC compiler will do it&#8217;s internal stuff and then invoke this method to allow the plugin to tweak some of the generated code. The generated code is provided as the &#8216;outline&#8217; of the generated classes.</li>
</ol>
<p>The generated code by the XJC compiler is being represented in a <em>com.sun.codemodel.JCodeModel</em>, which allows access to the outlines of generated classes and fields. Our implementation of the plugin iterates over all generated classes, finds the fields within those classes of the type XMLGregorianCalendar and replaces those fields by an appropriate DateTime variant. The JCodeModel API doesn&#8217;t allow us to change the type of a generated fields, so we need to remove the old fields and add them again with the proper type. In that process we do want to preserve all metadata (Annotations) of the original fields and of course the getters and setters for those fields should be replaced as well, since the return type and parameter type will changes.</p>
<p>In order make the plugin available to the xjc compiler it has to be on the classpath and it needs to use the <a title="ServiceLoader" href="http://docs.oracle.com/javase/6/docs/api/java/util/ServiceLoader.html">ServiceLoader API</a> to register the plugin. Adding a simple text file in META-INF/service-directory with the name &#8216;com.sun.tools.xjc.Plugin&#8217; and writing the fully qualified class name in that file is sufficient to register the plugin.</p>
<h2>Running xjb from maven with the plugin</h2>
<p>In order to trigger the custom plugin when the XJC compiler is being run from maven, you need to pass along the options to enable the extension and add the plugin to the classpath. The following sample snippet shows how to configure the maven-jabx-plugin for a custom plugin.</p>
<pre>&lt;plugin&gt;
  &lt;groupId&gt;org.jvnet.jaxb2.maven2&lt;/groupId&gt;
  &lt;artifactId&gt;maven-jaxb2-plugin&lt;/artifactId&gt;
  &lt;version&gt;0.8.1&lt;/version&gt;
  &lt;executions&gt;
    &lt;execution&gt;
      &lt;goals&gt;
        &lt;goal&gt;generate&lt;/goal&gt;
      &lt;/goals&gt;
    &lt;/execution&gt;
  &lt;/executions&gt;
  &lt;configuration&gt;
    &lt;extension&gt;true&lt;/extension&gt;
    &lt;schemaDirectory&gt;src/main/resources/xsd&lt;/schemaDirectory&gt;
    &lt;args&gt;
      &lt;arg&gt;-XuseJodatime&lt;/arg&gt;
    &lt;/args&gt;
    &lt;plugins&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;nl.iprofs.util.ws.jaxb&lt;/groupId&gt;
        &lt;artifactId&gt;jodatime-jabx-plugin&lt;/artifactId&gt;
        &lt;version&gt;1.0.0&lt;/version&gt;
      &lt;/plugin&gt;
     &lt;/plugins&gt;
  &lt;/configuration&gt;
  &lt;dependencies&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;nl.iprofs.util.ws.jaxb&lt;/groupId&gt;
      &lt;artifactId&gt;jodatime-jabx-plugin&lt;/artifactId&gt;
      &lt;version&gt;1.0.0&lt;/version&gt;
      &lt;scope&gt;runtime&lt;/scope&gt;
    &lt;/dependency&gt;
  &lt;/dependencies&gt;
&lt;/plugin&gt;</pre>
<br /> Tagged: <a href='http://blog.iprofs.nl/tag/datetime/'>DateTime</a>, <a href='http://blog.iprofs.nl/tag/jaxb/'>JAXB</a>, <a href='http://blog.iprofs.nl/tag/maven/'>maven</a>, <a href='http://blog.iprofs.nl/tag/plugin/'>plugin</a>, <a href='http://blog.iprofs.nl/tag/xjc/'>xjc</a>, <a href='http://blog.iprofs.nl/tag/xml/'>xml</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iprofs.wordpress.com/2229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iprofs.wordpress.com/2229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iprofs.wordpress.com/2229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iprofs.wordpress.com/2229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iprofs.wordpress.com/2229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iprofs.wordpress.com/2229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iprofs.wordpress.com/2229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iprofs.wordpress.com/2229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iprofs.wordpress.com/2229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iprofs.wordpress.com/2229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iprofs.wordpress.com/2229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iprofs.wordpress.com/2229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iprofs.wordpress.com/2229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iprofs.wordpress.com/2229/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.iprofs.nl&#038;blog=13247689&#038;post=2229&#038;subd=iprofs&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.iprofs.nl/2012/05/14/bye-bye-xmlgregoriancalendar-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1634a2815d3a7b9aeaa62ed403410c53?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mcbeelen</media:title>
		</media:content>
	</item>
		<item>
		<title>Character Encode your source</title>
		<link>http://blog.iprofs.nl/2012/05/09/character-encode-your-source/</link>
		<comments>http://blog.iprofs.nl/2012/05/09/character-encode-your-source/#comments</comments>
		<pubDate>Wed, 09 May 2012 11:13:55 +0000</pubDate>
		<dc:creator>jsnoeij</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Character Encoding]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[utf8]]></category>

		<guid isPermaLink="false">http://blog.iprofs.nl/?p=2103</guid>
		<description><![CDATA[When writing source code in your project, you’re always simply writing text and when you’re writing text you are saving this text on your disk in a certain encoding. This is a subtle field in which mistakes are easy and can lead to interesting side effects. In our project we’ve recently moved from JDK 1.5 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.iprofs.nl&#038;blog=13247689&#038;post=2103&#038;subd=iprofs&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When writing source code in your project, you’re always simply writing text and when you’re writing text you are saving this text on your disk in a certain encoding. This is a subtle field in which mistakes are easy and can lead to interesting side effects.</p>
<p>In our project we’ve recently moved from JDK 1.5 to JDK 1.6 and while local builds worked fine, the build server (running on Linux) started complaining:</p>
<p><strong>“Unmappable character for encoding UTF-8”<span id="more-2103"></span></strong></p>
<p>Also when starting the build (using maven) we say warnings on the file encoding.<br />
<code><br />
[INFO] <strong>[resources:resources {execution: default-resources}] </strong><span style="color:#ffcc00;">[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!</span><br />
[INFO] Copying 3 resources<br />
[INFO] <strong>[compiler:compile {execution: default-compile}] </strong><span style="color:#ffcc00;">[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!</span><br />
[INFO] Compiling 7 source files to /data/jenkins/workspace/trunk/email-service/target/classes<br />
[INFO] <strong>[resources:testResources {execution: default-testResources}] </strong><span style="color:#ffcc00;">[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!</span><br />
[INFO] Copying 2 resources<br />
</code></p>
<p>As it turns out, we had source files in our code base that were generated by a marshalling framework (like Jaxb, XmlBeans and JibX do) and these generated source file were stored in the platform encoding of our development machines (cp1252, because development machine run windows here).</p>
<p>We never ran into trouble before because of two reasons:</p>
<ol>
<li>Character encodings are often a super or sub set of each other. As long as you stick to the ‘standard’ western European characters, changes are that you are fine (so ‘public class Myclass {‘ will work).</li>
<li>On JDK 1.5 character encoding differences are marked as a <strong>warning</strong>, not an error. The compiler reads a character that is doesn’t understand and simply continue in good faith. On JDK 1.6 however this same situation results in an <strong>error</strong>.</li>
</ol>
<p>The generated code contained a comment block (generated from comments in the original XSD) with this text:</p>
<blockquote>
<pre>  /*
   * ...
   * to the front end application. When no user is available (e.g. call
   * from within a batch proces) the userNameActor `System’ must be used.
   */</pre>
</blockquote>
<p>The problem lies in the `System’ bit, the back tick character at the start is not common and encoded differently than the normal single quote at the end. Strangely enough both the Java 5 as well as the Java 6 compiler should have handle the input fine (comments are ignored any way), but the compiler stops after the character encoding <strong>error</strong> on JDK 1.6.</p>
<p>When using maven this problem can easily be resolved by either changing the character encoding of the offending file or changing the source encoding in your pom.xml:<br />
<code><br />
&lt;properties&gt;<br />
&lt;project.build.sourceEncoding&gt;cp1252&lt;/project.build.sourceEncoding&gt;<br />
&lt;project.reporting.outputEncoding&gt;cp1252&lt;/project.reporting.outputEncoding&gt;<br />
&lt;compileSource&gt;1.6&lt;/compileSource&gt;<br />
&lt;compileTarget&gt;1.6&lt;/compileTarget&gt;<br />
&lt;/properties&gt;<br />
</code><br />
Adding these general properties to the root pom of your project will force the compiler to use the given encoding instead of the platform default one.</p>
<p><strong>Always character encode your source!</strong></p>
<br /> Tagged: <a href='http://blog.iprofs.nl/tag/character-encoding/'>Character Encoding</a>, <a href='http://blog.iprofs.nl/tag/maven/'>maven</a>, <a href='http://blog.iprofs.nl/tag/utf8/'>utf8</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iprofs.wordpress.com/2103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iprofs.wordpress.com/2103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iprofs.wordpress.com/2103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iprofs.wordpress.com/2103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iprofs.wordpress.com/2103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iprofs.wordpress.com/2103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iprofs.wordpress.com/2103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iprofs.wordpress.com/2103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iprofs.wordpress.com/2103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iprofs.wordpress.com/2103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iprofs.wordpress.com/2103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iprofs.wordpress.com/2103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iprofs.wordpress.com/2103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iprofs.wordpress.com/2103/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.iprofs.nl&#038;blog=13247689&#038;post=2103&#038;subd=iprofs&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.iprofs.nl/2012/05/09/character-encode-your-source/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/674aa99135b12c65a0327c6cdf904df3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jsnoeij</media:title>
		</media:content>
	</item>
		<item>
		<title>The art of testing</title>
		<link>http://blog.iprofs.nl/2012/04/30/the-art-of-testing/</link>
		<comments>http://blog.iprofs.nl/2012/04/30/the-art-of-testing/#comments</comments>
		<pubDate>Mon, 30 Apr 2012 12:03:47 +0000</pubDate>
		<dc:creator>bjpbakker</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[clean code]]></category>
		<category><![CDATA[craftsmanship]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://blog.iprofs.nl/?p=2088</guid>
		<description><![CDATA[In a few other posts on this blog I talked about the importance of unit testing and Test-Driven Development (TDD). TDD helps us to ensure we&#8217;ve covered everything in our system by tests. Sure thing if you never write more production code than to satisfy a failing test, you&#8217;ve always covered all your production code [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.iprofs.nl&#038;blog=13247689&#038;post=2088&#038;subd=iprofs&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In a few other posts on this blog I talked about the importance of unit testing and Test-Driven Development (TDD).</p>
<p>TDD helps us to ensure we&#8217;ve covered everything in our system by tests. Sure thing if you never write more production code than to satisfy a failing test, you&#8217;ve always covered all your production code by tests.</p>
<p>But how do we write a good suite of tests? How do we ensure that our tests help us maintaining the system? And remember, in agile development maintenance starts after the first successful compilation.<span id="more-2088"></span></p>
<h2><strong>Purpose of tests</strong></h2>
<p>To know how to create a good suite of tests, we first must understand our expectations of these tests. What is the primary reason we need a good suite of tests?</p>
<p>The primary reason is <em>not</em> to prove that our code works. There are many ways to prove this, including an army of QA staff. Sure, it&#8217;s unprofessional to not know if <em>a</em><em>l</em><em>l</em><em> </em>your code works, but it&#8217;s not the primary reason for our suite of tests. Why do we need this suite of tests? What do we expect from it?</p>
<p>The primary reason for a suite of tests is to allows us to re-factor! The suite of tests eliminates the fear of changing the code. With a good suite of tests we can re-factor the code while having continuous feedback if we broke something.</p>
<h2><strong>Good tests</strong></h2>
<p>A good unit test is Fast, Independent, Repeatable, Self-Validating, and Timely. For details on this F.I.R.S.T. acronym, read Clean Code by Uncle Bob, Robert C. Martin. Seriously, if you haven&#8217;t read it yet, order a copy <em>n</em>o<em>w</em><em></em> and come back after to finish reading this post.</p>
<p>Tests that follow this acronym, support refactoring the production code quite well. But there&#8217;s more to create a sustainable suite of good tests. Not only is a unit test independent of other unit tests, it also validates something that no other test validates. In order words, a single feature of the system (under test) is unit tested once.</p>
<p>Furthermore, tests must be stable, meaning that things that things that commonly change should not be asserted. E.g. asserting text on a screen leads to fragile tests; whenever the text is changed, the test fails. It&#8217;s better not to assert this text, but stub it or only assert that some text is printed.</p>
<h2><strong>Design feedback<br />
</strong></h2>
<p>Tests not given feedback about the behavior of the system, they also provide feedback about its design. Let me clarify this with an example.</p>
<pre>    @Test public void shouldGetWeekOfYear() {
        int weekOfYear = Calendar.getInstance().get(Calendar.WEEK_OF_YEAR);
        assertThat(getWeekOfYear(), equalTo(weekOfYear));
    }</pre>
<div>
<div>As you can see the test determines the current week of the year, and then asserts the getWeekOfYear(..) function returning the same value. Most likely this function determines the week of the year pretty much the same way.</div>
<p>Quite often I see constructions like this; tests that repeat the production code to assert its behavior. Most of these are written after the fact, but either way this is a clear symptom of bad design.</p>
<h2><strong>Understand design feedback</strong></h2>
<p>To find a better way to test this function, we must understand the feedback from this test. We can hear it scream bad design at us, but what&#8217;s wrong with the design for this function? Isn&#8217;t the function too trivial to be burdened by bad design?</p>
</div>
<div>
<p>Remember the Single Responsibility Principle? It teaches us that each function in a system must do one thing, and one thing only. This function getWeekOfYear() in fact has two responsibilities; it determines the week of the year, of the current system date. Let&#8217;s see what the test would look like when we extract this second responsibility.</p>
<div>
<pre>    @Test public void shouldGetWeekOfYear() throws Exception {
        assertThat(getWeekOfYear(date(2012, APRIL, 30)), equalTo(18));
    }</pre>
</div>
<p>This is much better. We fixed the function&#8217;s design by extracting the extra responsibility from the function, and the test now is much more expressive. Note that I used a function date(..) to get a specific date, to improve expressiveness somewhat more.</p>
</div>
<h2><strong>Don&#8217;t fix the symptom</strong></h2>
<p>But wait a minute. It&#8217;s nice and all that the test now is more expressive, and that this specific function is left with only one responsibility. But now it became responsibility of the caller to determine the current date. How&#8217;s that better than having a low-level function to do two things?</p>
<p>Indeed. Our test helped finding a much more serious design problem: the concept of date/time is not properly separated in this particular system. Now that we&#8217;ve got this design flaw clear, we can fix it.</p>
<p>By the way, I&#8217;m not suggesting that you create your own date and time abstractions, but access to the current date/time is a separate concern that must not be spread throughout the system. We can introduce a Clock that gets the current date/time, and use this clock to pass the current date into the getWeekOfYear(..) function.</p>
<h2><strong>Conclusion</strong></h2>
<p>When you have trouble creating the scenario for a function to be tested, listen to this feedback from your test, take the time to understand what exactly is wrong, and fix it. This way tests help you from early on to separate concerns by constantly providing feedback about the system design.</p>
<p>Because tests given you loads of design feedback, writing tests after the fact is not really useful. If you get this feedback after you wrote the production code, you either have to rework the production code, or worse, ignore the design feedback. Writing tests after the fact therefore makes tests more likely to fail even on minor changes to the system, and thus they support but our primary purpose of tests: the ability to re-factor!</p>
<br /> Tagged: <a href='http://blog.iprofs.nl/tag/agile-2/'>agile</a>, <a href='http://blog.iprofs.nl/tag/clean-code/'>clean code</a>, <a href='http://blog.iprofs.nl/tag/craftsmanship/'>craftsmanship</a>, <a href='http://blog.iprofs.nl/tag/tdd/'>tdd</a>, <a href='http://blog.iprofs.nl/tag/test/'>test</a>, <a href='http://blog.iprofs.nl/tag/testing/'>testing</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iprofs.wordpress.com/2088/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iprofs.wordpress.com/2088/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iprofs.wordpress.com/2088/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iprofs.wordpress.com/2088/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iprofs.wordpress.com/2088/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iprofs.wordpress.com/2088/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iprofs.wordpress.com/2088/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iprofs.wordpress.com/2088/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iprofs.wordpress.com/2088/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iprofs.wordpress.com/2088/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iprofs.wordpress.com/2088/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iprofs.wordpress.com/2088/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iprofs.wordpress.com/2088/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iprofs.wordpress.com/2088/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.iprofs.nl&#038;blog=13247689&#038;post=2088&#038;subd=iprofs&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.iprofs.nl/2012/04/30/the-art-of-testing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/05f19becc7ad97834399ff6e6af8c54b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bbakker</media:title>
		</media:content>
	</item>
		<item>
		<title>Mini XPDay 2012 &#8211; a full and interesting day</title>
		<link>http://blog.iprofs.nl/2012/04/25/mini-xpday-2012-a-full-and-interesting-day/</link>
		<comments>http://blog.iprofs.nl/2012/04/25/mini-xpday-2012-a-full-and-interesting-day/#comments</comments>
		<pubDate>Wed, 25 Apr 2012 08:26:33 +0000</pubDate>
		<dc:creator>RuudRiet</dc:creator>
				<category><![CDATA[Scrum]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[report]]></category>
		<category><![CDATA[scrum]]></category>
		<category><![CDATA[XPdays]]></category>

		<guid isPermaLink="false">http://blog.iprofs.nl/?p=2083</guid>
		<description><![CDATA[On April 23rd, the Mini XPDay 2012 was held in conference center Kapellerput, in Heeze (NL). I went there to (re)connect with some people, and learn more about Agility and myself. It was a good day with interesting sessions in a lot of different areas. I had to leave pretty early in the morning to be on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.iprofs.nl&#038;blog=13247689&#038;post=2083&#038;subd=iprofs&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>On April 23rd, the <a href="http://www.xpday.net/Xpday2012/FrontPage.html">Mini XPDay 2012</a> was held in conference center Kapellerput, in Heeze (NL). I went there to (re)connect with some people, and learn more about Agility and myself. It was a good day with interesting sessions in a lot of different areas.</p>
<p><span id="more-2083"></span>I had to leave pretty early in the morning to be on time. Through the carpooling webpage I had procured me a passenger whose payment was to keep me awake, so the two-hour drive was a bit safer (thanks, Mark!). The traffic was not too bad and we arrived nicely on time for registration and my first coffee. After that the opening plenary began. The day was hosted by Nicole Belilos and Rob Westgeest, who also announced that this year was the 10th anniversary and something special would be upcoming for the full XP days. We’re looking forward to it!</p>
<p><a href="http://www.xpday.net/Xpday2012/sessions/FedEx%20Days.html">FedEx Days: Awakening Intrinsic Motivation</a><br />
This first presentation was done by Rob van Lanen and Rini van Solingen of iSense. They opted for a flexible content by letting the attendees dot-vote on the possible subjects upon entering the room. Luckily everybody wanted to know what it was, and that was explained quite nicely by Rob. He also gave very good pointers on how to organise one. Mainly: facilitate it; let it organise itself, but also some of the necessary preparations and follow-up, and some pitfalls that you have to watch out for, like management wanting to interfere with the chosen subjects.<br />
All attendees received a paper copy of Rob’s <a href="http://www.scrum.org/storage/articles/Formatted_20120124_FedEx%20Day%20-%20Lighting%20Corporate%20Passion.pdf">whitepaper about FedEx days</a>. It was a good session, that included everything I wanted to know about FedEx days.</p>
<p><a href="http://www.xpday.net/Xpday2012/sessions/Experience%20the%20power%20of%20visualization.html">Experience the power of visualization</a><br />
This session was done by Gero Vermaas and Sander van den Berg. It was based on the book <a href="http://www.danroam.com/the-back-of-the-napkin/">The back of the napkin</a> by Dan Roam. The presenters first drew the model of the 4 steps of visual thinking (look, see, imagine, show) and then gave us the assignment to visualise a solution to the financial crisis. My colleague and I got no further than the first step, but we drew something and we realised that of the four elements of the first step, we only consciously addressed the first (orientation), and the rest (position, identity, direction) came automatically. Which was of course interesting to note.<br />
After that we came to understand the working of the Map-Reduce pattern by living it; we played out the algorithm with people. This was an even more powerful visualisation as it used more senses than just our eyesight. This book definitely rose up on my wish-list, it will also be a nice book to read while on vacation. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><a href="http://www.xpday.net/Xpday2012/Agile%20Coaching%20Dojo.html">Agile Coaching Dojo</a><br />
After an excellent lunch and the afternoon opening plenary I joined the Agile coaching Dojo. This was presented by Nick Oostvogels and Bart Biernaux. They first explained the types of coaching followed by a preparation for an exercise: Personal Coaching, in which you have to listen closely, be sure to maintain trust, ask Powerful Questions, lend support to the seeker and guide him/her towards concrete actions.<br />
The excercise was very good: we made groups of four people, of which one Seeker, one Coach and two Observers. Every group had one person that was experienced in coaching, and the rest was of varying ability. We all took turns and so I was able to coach twice and get lots of good feedback. It was also very nice to see an experienced coach in action. Calmness &amp; Inventivity are words that now come to my mind when I think of coaching, in addition to ‘Show the path, do not walk the path’. All in all one of my favourites of the day.<br />
[<a href="http://www.slideshare.net/noostvog/agile-coaching-dojo">slides</a>]</p>
<p>The last timeslot had three sessions that <em>all</em> seemed very interesting to me, but you have to make choices, and so I chose<br />
<a href="http://www.xpday.net/Xpday2012/sessions/Training%20from%20the%20back%20of%20the%20Room.html">Training from the back of the Room</a><br />
This session, presented by Jef Cumps &amp; Kris Philippaerts, was based (unsurprisingly) on the book <a href="http://www.bowperson.com/books.htm">Training from the back of the room</a>by Sharon Bowman. This was yet another great session where the teachers really used the techniques to teach the techniques. Training from the back of the room is about the four C’s:</p>
<ul>
<li>Connect (learners connect with each other, the subject, their learning goals and the goals of the session),</li>
<li>Concepts (facts learners need to learn, the group collaboratively usually already knows some 80% of it),</li>
<li>Concrete examples (learners should practice with the subjects) and</li>
<li>Conclusions (summarize, celebrate, next steps after the training).</li>
</ul>
<p>At one point it got very meta, it even got meta meta when one group was teaching the other groups the concept of Concepts using Concepts as a tool. It almost made my brain explode&#8230; but all in all a whole lot of fun! Plus another book to rise on my wish-list.<br />
[<a href="http://www.ilean.be/docs/TFBORHandouts_XPDays2011.pdf">slides</a>]</p>
<p>The beers afterwards were a very welcome release of all energies built up over the day, but somehow I remained with my own group, so after two drinks we started our journey back to Amsterdam and Haarlem. The end of a very insightful and fun day!</p>
<br /> Tagged: <a href='http://blog.iprofs.nl/tag/agile-2/'>agile</a>, <a href='http://blog.iprofs.nl/tag/conference/'>conference</a>, <a href='http://blog.iprofs.nl/tag/report/'>report</a>, <a href='http://blog.iprofs.nl/tag/scrum-2/'>scrum</a>, <a href='http://blog.iprofs.nl/tag/xpdays/'>XPdays</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iprofs.wordpress.com/2083/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iprofs.wordpress.com/2083/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iprofs.wordpress.com/2083/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iprofs.wordpress.com/2083/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iprofs.wordpress.com/2083/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iprofs.wordpress.com/2083/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iprofs.wordpress.com/2083/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iprofs.wordpress.com/2083/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iprofs.wordpress.com/2083/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iprofs.wordpress.com/2083/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iprofs.wordpress.com/2083/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iprofs.wordpress.com/2083/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iprofs.wordpress.com/2083/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iprofs.wordpress.com/2083/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.iprofs.nl&#038;blog=13247689&#038;post=2083&#038;subd=iprofs&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.iprofs.nl/2012/04/25/mini-xpday-2012-a-full-and-interesting-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/731c91ff7561fca4f806f8ba7b5a8e61?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ruudriet</media:title>
		</media:content>
	</item>
		<item>
		<title>Captcha&#8217;s in Wicket</title>
		<link>http://blog.iprofs.nl/2012/04/22/captchas-in-wicket/</link>
		<comments>http://blog.iprofs.nl/2012/04/22/captchas-in-wicket/#comments</comments>
		<pubDate>Sun, 22 Apr 2012 08:27:30 +0000</pubDate>
		<dc:creator>avanderark</dc:creator>
				<category><![CDATA[Frontend]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[captcha]]></category>
		<category><![CDATA[recaptcha]]></category>
		<category><![CDATA[Wicket]]></category>

		<guid isPermaLink="false">http://blog.iprofs.nl/?p=2005</guid>
		<description><![CDATA[In this post I&#8217;ll describe how to add a captcha to your web application with Wicket. A captcha is a a type of challenge-response test used to ensure that the response is generated by a person. Adding one thwarts bots sending a large amount of filled in forms to be stored. This article deals with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.iprofs.nl&#038;blog=13247689&#038;post=2005&#038;subd=iprofs&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In this post I&#8217;ll describe how to add a captcha to your web application with Wicket. A captcha is a a type of challenge-response test used to ensure that the response is generated by a person. Adding one thwarts bots sending a large amount of filled in forms to be stored.</p>
<p>This article deals with the best known one: an image with a series of characters and an input field to which the user must fill the characters of the image. First I describe how to do this, using the captcha component that is shipped with Wicket. After that I describe how to add the well known recaptcha.<span id="more-2005"></span></p>
<h2>Standard Wicket Captcha</h2>
<p>First the Panel with the captcha that can be inserted to your form.</p>
<div></div>
<div>&lt;img wicket:id=&#8221;image&#8221;/&gt;</div>
<div></div>
<p>The java code is also fairly simple: A class extending Panel, having a text field with a validator and an image for the the capthca.</p>
<pre>public class CaptchaPanel extends Panel {
  public CaptchaPanel(String id, int nrChars, boolean inError) {
    super(id);

    RandomString randomString = new RandomString(nrChars);
    String random = randomString.nextString();
    TextField textField = new TextField("imagePassword");
    textField.setRequired(true);
    textField.add(StringValidator.maximumLength(nrChars));
    if(inError){
      textField.add(new AttributeModifier("class", "error"));
    }
    Image image = new NonCachingImage("image", 
                                      new CaptchaImageResource(random));
    textField.add(new CaptchaValidator(random));
    add(image);
    add(textField);    
    }
}</pre>
<p>Finally the validator, again a fairly simple class that performs a String comparison.</p>
<pre>public class CaptchaValidator extends AbstractValidator {

  private String randomString;

  public CaptchaValidator(String randomString) {
    this.randomString = randomString;
  }

  protected void onValidate(IValidatable validatable) {
    if (!randomString.equals(validatable.getValue())) {
      error(validatable, "CaptchaValidators.invalidcaptcha");
    }
  }
}</pre>
<p>The image below gives an example of the Wicket captcha:<br />
<img src="https://lh4.googleusercontent.com/-zhlbXwwhPQo/T3rnlIpp3KI/AAAAAAAAAA8/RokpUb1tCng/s800/capthca.png" alt="Wicket Captcha" /></p>
<h2>Recaptcha</h2>
<p>This all works well. A little too well to be honest. The captcha is too hard to read. This can could be solved by using recaptcha. Recaptcha is used widely across the internet, and as an added bonus comes with audio, so that visually impaired visitors can also use the captcha. Integrating this to your application requires a little more effort. (To read more about recaptcha follow this: <a title="recapthca site" href="http://www.google.com/recaptcha">link</a>)</p>
<p>Again first the html:</p>
<pre>&lt;wicket:panel&gt;
  &lt;div/&gt;
  &lt;div  wicket:id="imagePassword"&gt;&lt;/div&gt;
  &lt;div/&gt;  
&lt;/wicket:panel&gt;</pre>
<p>Then the Java code: again a Panel. In this case the validation is done by a the validate method, so no validator class. The recaptcha classes com from recaptcha4j.</p>
<pre>public class RecaptchaPanel extends Panel {

  @SpringBean
  private ClientSettings clientSettings;

  public RecaptchaPanel(String id, final int tabIndex) {
    super(id);
    final String privateCaptchaKey = clientSettings.getPrivateCaptchaKey();
    String publicCaptchaKey = clientSettings.getPublicCaptchaKey();

    final ReCaptcha recaptcha = ReCaptchaFactory.newReCaptcha(publicCaptchaKey, 
                                privateCaptchaKey, false);
    add(new FormComponent("imagePassword") {

      public void onComponentTagBody(final MarkupStream markupStream, 
                                     final ComponentTag openTag) {
        Properties properties = new Properties();
        properties.put("theme", "clean");
        properties.put("tabindex", ""+tabIndex);
        replaceComponentTagBody(markupStream, openTag, 
                                recaptcha.createRecaptchaHtml(null, 
                                                              properties));
      }

      public void validate() {
        WebRequest request = 
              (WebRequest) RequestCycle.get().getRequest();
        HttpServletRequest servletRequest = 
            HttpServletRequest) getRequest().getContainerRequest();

        String remoteAddr = servletRequest.getRemoteAddr();
        ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
        reCaptcha.setPrivateKey(privateCaptchaKey);

        String challenge = 
              request.getRequestParameters()
                     .getParameterValue("recaptcha_challenge_field")
                     .toString();
        String response = 
              request.getRequestParameters()
                     .getParameterValue("recaptcha_response_field")
                     .toString();
        ReCaptchaResponse reCaptchaResponse = 
              reCaptcha.checkAnswer(remoteAddr, challenge, response);

        if (!reCaptchaResponse.isValid()) {
          error("Invalid captcha");
        }
      }
    });
  }
}</pre>
<p>To make the it work you&#8217;ll have to request a private and a public key for your site from google. To do this follow the instructions at this page:<br />
<a title="go to page to retrieve keys" href="https://www.google.com/recaptcha/admin/list">https://www.google.com/recaptcha/admin/list</a></p>
<p>The default recapthca is displayed with colors in yellow and red and the styling instructions are in the rendered HTML. In most cases this will not match the rest of the site. Although styling options are limited, above mentioned solution supports some alternative themes. I choose clean, a mainly white theme. The other themes are: red(=default), white, blackglass and custom. The latter is for implementing your own custom theme, but that is outside the scope of this posting.</p>
<p>The image below gives an example of Recapthca styled as clean:<br />
<img src="https://lh5.googleusercontent.com/-ZnqxWvMk9y4/T3rnlECG5SI/AAAAAAAAABE/c-M-cD1ROuQ/s800/recaptcha.png" alt="Recaptcha" /></p>
<h2>Conclusion</h2>
<p>For implementing capthca&#8217;s in wicket multiple options are available. The one that is shipped with Wicket is relatively simple to implement and gives almost full control of the styling. Recaptcha, now serviced by Google, is friendlier to the visitors of your application, but requires more programming effort and is a lot harder to match the looks of your application.</p>
<br /> Tagged: <a href='http://blog.iprofs.nl/tag/captcha/'>captcha</a>, <a href='http://blog.iprofs.nl/tag/recaptcha/'>recaptcha</a>, <a href='http://blog.iprofs.nl/tag/wicket/'>Wicket</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iprofs.wordpress.com/2005/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iprofs.wordpress.com/2005/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iprofs.wordpress.com/2005/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iprofs.wordpress.com/2005/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iprofs.wordpress.com/2005/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iprofs.wordpress.com/2005/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iprofs.wordpress.com/2005/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iprofs.wordpress.com/2005/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iprofs.wordpress.com/2005/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iprofs.wordpress.com/2005/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iprofs.wordpress.com/2005/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iprofs.wordpress.com/2005/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iprofs.wordpress.com/2005/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iprofs.wordpress.com/2005/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.iprofs.nl&#038;blog=13247689&#038;post=2005&#038;subd=iprofs&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.iprofs.nl/2012/04/22/captchas-in-wicket/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e1292a0e5d7ed0aa46161723a93c00a9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">avanderark</media:title>
		</media:content>

		<media:content url="https://lh4.googleusercontent.com/-zhlbXwwhPQo/T3rnlIpp3KI/AAAAAAAAAA8/RokpUb1tCng/s800/capthca.png" medium="image">
			<media:title type="html">Wicket Captcha</media:title>
		</media:content>

		<media:content url="https://lh5.googleusercontent.com/-ZnqxWvMk9y4/T3rnlECG5SI/AAAAAAAAABE/c-M-cD1ROuQ/s800/recaptcha.png" medium="image">
			<media:title type="html">Recaptcha</media:title>
		</media:content>
	</item>
		<item>
		<title>Debugging web pages on mobile devices</title>
		<link>http://blog.iprofs.nl/2012/04/18/debugging-web-pages-on-mobile-devices/</link>
		<comments>http://blog.iprofs.nl/2012/04/18/debugging-web-pages-on-mobile-devices/#comments</comments>
		<pubDate>Wed, 18 Apr 2012 08:31:53 +0000</pubDate>
		<dc:creator>Gijs Mollema</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[firebug]]></category>
		<category><![CDATA[html5 css3]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[phonegap]]></category>
		<category><![CDATA[webkit inspector]]></category>
		<category><![CDATA[weinre]]></category>

		<guid isPermaLink="false">http://blog.iprofs.nl/?p=1883</guid>
		<description><![CDATA[As a web developer I often use front-end debugging tools like Firebug (Firefox) or Webkit Inpector (Chrome) to inspect or edit html &#38; css and to run JavaScript (for example JQuery). Regular web pages shown by the browser can be inspected using such tooling as soon as the page is loaded. With mobile devices however [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.iprofs.nl&#038;blog=13247689&#038;post=1883&#038;subd=iprofs&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As a web developer I often use front-end debugging tools like Firebug (Firefox) or Webkit Inpector (Chrome) to inspect or edit html &amp; css and to run JavaScript (for example JQuery). Regular web pages shown by the browser can be inspected using such tooling as soon as the page is loaded.<br />
With mobile devices however this principle is not (directly) possible. Of course you can run debug tooling opening the html as a file on your pc, deploy the application to a mobile device keeping your fingers crossed hoping it will run ok. It will be frustrating to see that web pages show and act different on a mobile device compared to the content being shown in a web browser on a pc. In this case the device is a black box and most of the times you have no clue what is causing the layout and behavior problem.<br />
Searching the internet I have found a way to actually debug web pages on the mobile device using the browser of the pc. This article will show you on how to set this up, so that you can debug mobile web apps.</p>
<p><span id="more-1883"></span></p>
<h2>Weinre to the rescue</h2>
<p>First thing I was looking for in a tool is one that can be used with any kind of mobile device regardless the operating system it uses. It also has to be easy to install and configure and in usability. Last but not least: it should work like the Firebug or Web Inspector and supports the following:</p>
<ul>
<li>inspect / edit / delete html and css</li>
<li>localstorage / WebSQL inspector</li>
<li>add new events to timeline</li>
<li>a console to run JavaScript code in the web page</li>
</ul>
<p>The tool I eventually found is <a href="http://phonegap.github.com/weinre">Weinre &#8211; WEb INspector REmote</a>. The basic idea is that you run a server to which you connect with your mobile device and the web browser.</p>
<h2></h2>
<h2>How does it work?</h2>
<p>The browser will be used to debug web pages on the mobile device (while the server is the mediator). As the site has loads of information I will give you just information you&#8217;ll need to get started.</p>
<p><img class="aligncenter" src="https://lh4.googleusercontent.com/-gpg2KAAbMOc/T3Sx9C6TBCI/AAAAAAAAAAw/rvsYdAkRSP8/s400/MOBILE_WEB_DEB1.png" alt="" /></p>
<p>Basically you&#8217;ll need (as shown in the diagram):</p>
<ul>
<li>the server</li>
<li>the inspector / debug client (browser)</li>
<li>the target to debug (mobile device)</li>
</ul>
<p>In order to implement this setup, you only need to do these two steps:</p>
<ul>
<li>(configure and) start the server.</li>
<li>add a JavaScript reference in the page(s) of the web application (referencing a JavaScript file on the server) to be deployed to the mobile device.</li>
</ul>
<p>The next paragraph will show you how to accomplish this.</p>
<h2>Setting up your debugging environment</h2>
<h3>Server</h3>
<p>Regarding the server you want to connect to, you have two choices:</p>
<ul>
<li>Use the debugging server of <a href="http://debug.phonegap.com/">PhoneGap</a> (http://debug.phonegap.com)</li>
<li>Run your own local server (<a href="https://github.com/callback/callback-weinre/archives/master">download link</a>).</li>
</ul>
<p>When your want to run the server locally then download the jar file and start it with the following command (in this case using port 8081)* :</p>
<p><strong>java -jar weinre.jar -httpPort 8081 -boundHost -all-</strong></p>
<p>* Per default localhost is used. In this case the server is only reachable from the machine itself. This is overridden with the boundHost argument. In this case it will accept requests from any interface on the current machine. Run<strong> java -jar weinre.jar -help</strong> for more details.</p>
<h3>Debug target</h3>
<p>The web page to be debugged on the mobile device has to include a simple JavaScript reference in the head par of the html (index.html in case the app is based on the PhoneGap framework):</p>
<p><strong>// &lt;![CDATA[<br />
src="http://localhost:8081/target/target-script-min.js#anonymous"&gt;<br />
// ]]&gt;</strong></p>
<p>The part after the hash is the GUID (unique ids), to make sure that the client does connect to the right target (as no security mechanism is in place).<br />
A local server uses per default the anonymous GUID, so no change is needed.<br />
In case you want to use the PhoneGap debug server, open the <a href="http://debug.phonegap.com/">phonegap debug web page</a> and enter a GUID of your choosing.<br />
In your mobile app page use the reference as shown above and replace the anonymous GUID with the one you have entered on the PhoneGap debug page.</p>
<h3>Debug client (inspector)</h3>
<p>The browser that connects to the server to debug the website .<br />
Currently browsers which are supported Google Chrome 8.x and Apple Safari 5.x.<br />
<strong></strong></p>
<h2></h2>
<h2>Run the server, client &amp; app and start debugging!</h2>
<p>Now that everything is in place, start-up the server if you are running it locally:</p>
<p><strong>java -jar weinre.jar -httpPort 8081 -boundHost -all-</strong></p>
<p>Open the browser and open the root url to the server:</p>
<ul>
<li>http://localhost:8081/client/#anonymous (for localhost)</li>
<li>http://debug.phonegap.com/client/#(using phonegap debug site)</li>
</ul>
<p>The top of the screen will show you if a target device is connected. Once connected, you&#8217;re ready to go and do some cool mobile debugging!</p>
<br /> Tagged: <a href='http://blog.iprofs.nl/tag/android-2/'>android</a>, <a href='http://blog.iprofs.nl/tag/debug/'>debug</a>, <a href='http://blog.iprofs.nl/tag/firebug/'>firebug</a>, <a href='http://blog.iprofs.nl/tag/html5-css3/'>html5 css3</a>, <a href='http://blog.iprofs.nl/tag/ios/'>ios</a>, <a href='http://blog.iprofs.nl/tag/phonegap/'>phonegap</a>, <a href='http://blog.iprofs.nl/tag/webkit-inspector/'>webkit inspector</a>, <a href='http://blog.iprofs.nl/tag/weinre/'>weinre</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iprofs.wordpress.com/1883/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iprofs.wordpress.com/1883/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iprofs.wordpress.com/1883/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iprofs.wordpress.com/1883/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iprofs.wordpress.com/1883/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iprofs.wordpress.com/1883/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iprofs.wordpress.com/1883/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iprofs.wordpress.com/1883/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iprofs.wordpress.com/1883/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iprofs.wordpress.com/1883/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iprofs.wordpress.com/1883/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iprofs.wordpress.com/1883/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iprofs.wordpress.com/1883/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iprofs.wordpress.com/1883/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.iprofs.nl&#038;blog=13247689&#038;post=1883&#038;subd=iprofs&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.iprofs.nl/2012/04/18/debugging-web-pages-on-mobile-devices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/db555633482addc742f52b1aea9752c1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gmollema</media:title>
		</media:content>

		<media:content url="https://lh4.googleusercontent.com/-gpg2KAAbMOc/T3Sx9C6TBCI/AAAAAAAAAAw/rvsYdAkRSP8/s400/MOBILE_WEB_DEB1.png" medium="image" />
	</item>
		<item>
		<title>Quickstart Android 4.0 mobile app development</title>
		<link>http://blog.iprofs.nl/2012/04/16/quickstart-android-4-0-mobile-app-development/</link>
		<comments>http://blog.iprofs.nl/2012/04/16/quickstart-android-4-0-mobile-app-development/#comments</comments>
		<pubDate>Mon, 16 Apr 2012 14:48:07 +0000</pubDate>
		<dc:creator>Gijs Mollema</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[intellij]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[netbeans]]></category>

		<guid isPermaLink="false">http://blog.iprofs.nl/?p=1733</guid>
		<description><![CDATA[It probably does not come as a surprise to you that mobile devices &#38; mobile apps are hot. As more and more new mobile devices like smartphones and tablets come to market, the demand of apps increases as well. In 2011 the mobile devices market growth (tablets in particular) has exceeded the pc market growth by [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.iprofs.nl&#038;blog=13247689&#038;post=1733&#038;subd=iprofs&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div>
<div style="display:inline-block;width:75%;">It probably does not come as a surprise to you that mobile devices &amp; mobile apps are hot. As more and more new mobile devices like smartphones and tablets come to market, the demand of apps increases as well. In 2011 the mobile devices market growth (tablets in particular) has exceeded the pc market growth by far. Based on the statistics of <a href="http://www.onlinemarketing-trends.com/2012/02/global-smartphone-sales-outpace-pc-grow.html">onlinemarketing-trends.com</a> almost half of the smartphones sold in 2011 run Google Android. This post will focus on the Android platform and will give you a few easy steps for setting up, building and deploying a basic Android project using Maven and the Android SDK.</div>
<div style="display:inline-block;float:right;"><img src="https://lh6.googleusercontent.com/-jiXYJGtwVUc/T3s2UDIi0dI/AAAAAAAAF-U/dSrDxXCeKoA/s288/ANDROID-LOGO.png" alt="" width="118" height="163" /></div>
</div>
<p><span id="more-1733"></span></p>
<h2>Installing and configuring the Android SDK</h2>
<p>The Android SDK contains tools and sample code for developing Android apps.</p>
<h3>Install the Android SDK</h3>
<p>To install the SDK follow the next three steps:</p>
<ul>
<li>Download the sdk zip file from here: <a href="http://developer.android.com/sdk/index.html">http://developer.android.com/sdk/index.html</a> and unzip the file.</li>
<li>Create a new environment variable ANDROID_SDK pointing to the root of the exploded zip directory (used by maven) and extend your environment variable PATH by adding ANDROID_SDK/tools and ANDROID_SDK/platform-tools (in order to find the SDK executables).</li>
<li>Test if all SDK commands can be run from anywhere in your OS console/shell. Open a new console and try if the following command works: adb version.</li>
</ul>
<h3>Configure the Android SDK</h3>
<p>In order to use the SDK you need to configure it. This can be done by:</p>
<ul>
<li>Run the following command (plain and simple:) in the console: <strong>android</strong></li>
<li>Check the complete folder <strong>Tools </strong>and from the <strong>Android version(s)</strong> you want to support expand the folder and check the <strong>SDK Platform</strong>.</li>
<li>Click on the &#8216;install packages&#8217; button.</li>
</ul>
<p><img src="https://lh4.googleusercontent.com/-JsaYH8j3hcQ/T3Sx8j7xyDI/AAAAAAAAAAc/pwgQfbIdcXg/s800/ANDROID-IMAGE1.png" alt="" /><br />
<strong></strong></p>
<h2></h2>
<h2>Create, build, deploy and run a basic android application</h2>
<p>To quickly setup a basic maven project, the maven <a href="https://github.com/akquinet/android-archetypes/wiki">Maven-Android-Archetypes</a> will be used.<br />
Navigate to the folder where you want the create the project and set up the project by running the command below.<br />
Do notice that the value for the platform option must match the API version of the SDK you have installed (in this case 15).<br />
You can change the groupid and artifactid if you like before running it. While running just hit enter two times to complete the creation of the project.</p>
<p><strong>mvn archetype:generate \<br />
-DarchetypeArtifactId=android-quickstart \</strong><br />
<strong>-DarchetypeGroupId=de.akquinet.android.archetypes \</strong><br />
<strong>-DarchetypeVersion=1.0.7 \<br />
-DgroupId=your.company \</strong><br />
<strong>-DartifactId=my-android-application \ </strong><br />
<strong> -Dplatform=15</strong></p>
<p>Change your dir location to the root of  &#8216;my-android-application&#8217; folder.<br />
The project is ready to be build and to be deployed to your mobile device*. The install argument will create an .apk deployment in the target directory. The android:deploy argument will use the android SDK to actually deploy this .apk to your device. Connect it via usb and run the following command:</p>
<p><strong>mvn clean install android:deploy<code></code></strong></p>
<p>There you go. The app is installed! Check your device. It should contain a new app called &#8216;my-android-application&#8217; . When running it, it will show you a plain nice hello message.</p>
<p>* If you should not have a device running the Android OS, you can alternatively configure and run the Android emulator. See the section Android emulator and SDK tools on how configure it. The installation / deployment step mentioned above will be the same for an emulator.</p>
<h2>Integration of Android SDK into your IDE</h2>
<p>If you want to integrate the Android SDK with one of the following IDEs then install the mentioned plugin:</p>
<ul>
<li>Netbeans  -  <a href="http://plugins.netbeans.org/plugin/19545/nbandroid">NBAndroid</a></li>
<li>Eclipse &#8211; <a href="http://developer.android.com/sdk/eclipse-adt.html">ADT (Android development tools)</a></li>
<li>IntelliJ &#8211; IntelliJ IDEA Ultimate edition version 10.5 or higher supports Android development by default</li>
</ul>
<h2>Android emulator and SDK tools</h2>
<h3>Running the Android emulator</h3>
<p>When you do not have a mobile device or just want to run the Android emulator, you have to create an Android Virtual Device (AVD)..<br />
In order to do this follow these steps:</p>
<ul>
<li>Run the <strong>android</strong> command again.</li>
<li><strong>If the Android API is 14 or higher</strong> (4.0 and up) then install from the same Android version, select the <strong>ARM EABI 7a System Image</strong> (check box below the SDK) and install it.*</li>
<li>Run <strong>android list targets</strong> to list all available Android targets.<strong> </strong></li>
<li><strong>android create avd -n -t </strong> (name is the logical name of AVD to be created, id is the target id of one of the Android targets from the previous step).</li>
</ul>
<p>Now that you have created an AVD lets run it the emulator. Do know that API 14 and up may take some time to load.</p>
<ul>
<li><strong>emulator -avd </strong><strong></strong><strong>&lt;avd-name&gt;</strong></li>
</ul>
<h3>Other interesting SDK commands</h3>
<p>Show running devices (mobile devices as well as emulators): <strong>adb devices<br />
</strong>Install an apk deployment (-s is optional): <strong>adb install<br />
</strong>Remove app from device: <strong>adb uninstall</strong><br />
Run<strong> adb help</strong> for more information.</p>
<p>*If you don&#8217;t execute this step for these APIs then you will get the following error when you try to create an AVD:<br />
Valid ABIs: no ABIs.<br />
Error: This platform has more than one ABI. Please specify one using &#8211;abi.</p>
<h2>More info on Android app development</h2>
<p>To get more info on Android development a lot of resources are available. A good starting point would be <a href="http://developer.android.com">developer.android.com</a> in particular the <a href="http://developer.android.com/guide/developing/index.html">dev guide</a> section and the <a href="http://developer.android.com/resources/tutorials/hello-world.html">tutorial resource</a> section. In addition I recommend the following resources:</p>
<ul>
<li><a href="http://www.anddev.org/">Android Development Community</a></li>
<li><a href="http://stonetrip.com/">Shiva3D</a></li>
</ul>
<p>Amongst others these books contain more on Android as well:</p>
<ul>
<li>Professional Android Application Development &#8211; Reto Meier</li>
<li>Unlocking Android &#8211; W. Frank Ableson, Charlie Collins, and Robi Sen</li>
<li>Hello, Android  &#8211; Ed Burnette</li>
</ul>
<br /> Tagged: <a href='http://blog.iprofs.nl/tag/android-2/'>android</a>, <a href='http://blog.iprofs.nl/tag/eclipse/'>Eclipse</a>, <a href='http://blog.iprofs.nl/tag/intellij/'>intellij</a>, <a href='http://blog.iprofs.nl/tag/java-2/'>java</a>, <a href='http://blog.iprofs.nl/tag/maven/'>maven</a>, <a href='http://blog.iprofs.nl/tag/netbeans/'>netbeans</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iprofs.wordpress.com/1733/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iprofs.wordpress.com/1733/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iprofs.wordpress.com/1733/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iprofs.wordpress.com/1733/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iprofs.wordpress.com/1733/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iprofs.wordpress.com/1733/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iprofs.wordpress.com/1733/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iprofs.wordpress.com/1733/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iprofs.wordpress.com/1733/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iprofs.wordpress.com/1733/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iprofs.wordpress.com/1733/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iprofs.wordpress.com/1733/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iprofs.wordpress.com/1733/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iprofs.wordpress.com/1733/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.iprofs.nl&#038;blog=13247689&#038;post=1733&#038;subd=iprofs&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.iprofs.nl/2012/04/16/quickstart-android-4-0-mobile-app-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/db555633482addc742f52b1aea9752c1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gmollema</media:title>
		</media:content>

		<media:content url="https://lh6.googleusercontent.com/-jiXYJGtwVUc/T3s2UDIi0dI/AAAAAAAAF-U/dSrDxXCeKoA/s288/ANDROID-LOGO.png" medium="image" />

		<media:content url="https://lh4.googleusercontent.com/-JsaYH8j3hcQ/T3Sx8j7xyDI/AAAAAAAAAAc/pwgQfbIdcXg/s800/ANDROID-IMAGE1.png" medium="image" />
	</item>
		<item>
		<title>Devnology Community Day Review</title>
		<link>http://blog.iprofs.nl/2012/04/16/devnology-community-day-review/</link>
		<comments>http://blog.iprofs.nl/2012/04/16/devnology-community-day-review/#comments</comments>
		<pubDate>Mon, 16 Apr 2012 14:41:48 +0000</pubDate>
		<dc:creator>lvdpal</dc:creator>
				<category><![CDATA[iPROFS]]></category>
		<category><![CDATA[code quality]]></category>
		<category><![CDATA[developers]]></category>
		<category><![CDATA[devnology]]></category>
		<category><![CDATA[extreme startup]]></category>
		<category><![CDATA[infinity]]></category>
		<category><![CDATA[maths]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://blog.iprofs.nl/?p=1977</guid>
		<description><![CDATA[This year I had finally convinced my partner to join me for the Devnology community day, convincing him that there would be several other C# programmers there. So we set out early, braving the slippery roads (which didn&#8217;t turn out all that bad). We arrived just after the building was supposed to be open. Which [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.iprofs.nl&#038;blog=13247689&#038;post=1977&#038;subd=iprofs&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This year I had finally convinced my partner to join me for the <a href="http://devnology.nl/">Devnology</a> community day, convincing him that there would be several other C# programmers there. So we set out early, braving the slippery roads (which didn&#8217;t turn out all that bad). We arrived just after the building was supposed to be open. Which would have been great if it wasn&#8217;t for the fact that it was in fact still closed. There was quite a crowd standing before the gates already. But as it was -15 degrees Celcius, we decided to stay in the car under the emergency blankets we had brought. After about forty minutes, somebody with a key showed up and we went inside. I didn&#8217;t take off my coat until after I&#8217;d finished my first cup of tea. And so the day started about fifteen minutes late.</p>
<h2>How to show code quality – Joost Visser</h2>
<p>The session started out well with an open discussion, trying to find out what quality is. According to Joost there are two kinds of quality: funtionality and technical quality. Whereas functional quality (the code does what was specified) is relatively easy to point out, technical quality is less tangible. This lead to a discussion on what makes code beautiful. Some aspects that were pointed out are easy to understand, performance, loosely coupled code, code split according to responsibilities, and compliance to coding standards, to name a few.</p>
<p><span id="more-1977"></span></p>
<p>Sadly, it seemed to me that this discussion took a bit too long for the allotted time, as afterwards the presentation didn&#8217;t quite live up to the standards that had been set in the first half. The second half went on to talk about quality certificates, while I had been expecting to be shown some tools or other useful tips on how to show code quality to management and clients. One final important statement I took away was that quality measurements merely indicate symptoms, and that after they are done you have to spend time analysing what the actual problem is.</p>
<h2>To infinity&#8230; and beyond (no seriously!) – Felienne Hermans</h2>
<p>Felienne warned us in advance that this session would not have any practical applicability for us, as it would be highly theoretical mathematics. She told us about Brazilian tribes that had no numbers larger than three, and how they put numbers (explained to them with a number of dots) on a logarithmic scale, instead of the regular linear one. Which turns out to be what young children do too. Then she showed us Zenos theorems, and Galileos paradox. She explained Hilberts hotel and showed us how there are just as many numbers in between 0 and 1 as there are between -∞ and ∞.</p>
<p>But what boggled me the most was that as there can be nothing in between 0,999&#8230; (followed by an infinite amount of nines) and 1 they must be equal. I tried arguing that the same would be valid for 0,999&#8230;98 and 0,999&#8230;99, but she explained that defining an end to the number makes it a different case. I&#8217;m not sure I quite understand, but it was a lovely demonstration of maths.</p>
<h2>Extreme startup – Willem van den Ende</h2>
<p>My final session of the day was a programming session for which I&#8217;d specifically brought my laptop. Alas, I didn&#8217;t quite have my IDE ready yet, having only gotten the laptop a few days earlier, so I didn&#8217;t have the proper tools installed yet. So it took me quite some time to get ready (which was not something my team mates could help me with). The idea was that you had to build a HTTP request handler and that the requests would contain questions that you would have to reply to.</p>
<p>There were nine participants and we teamed up in groups of three. The team I was in consisted of three ladies, so naturally I opted to call us Team Duchess (as we were programming in Java). To Willems great despair, all teams used Windows. It took ages to find out that my laptop was having trouble with a firewall. But then we finally got it working. We had nearly run out of time, but we did get to answer about four different questions. If we&#8217;d had more time, we probably would have won. As it was, we joined the market so late, we didn&#8217;t have a chance anymore. It was a really great workshop that showed how code quality is often set aside in favor of deadlines.</p>
<p>I skipped the fourth session, as I was quite tired already. I would have gone to join in the coding kata otherwise, but that&#8217;s something you need a clear head for. All in all I had a lovely day.</p>
<br /> Tagged: <a href='http://blog.iprofs.nl/tag/code-quality/'>code quality</a>, <a href='http://blog.iprofs.nl/tag/developers/'>developers</a>, <a href='http://blog.iprofs.nl/tag/devnology/'>devnology</a>, <a href='http://blog.iprofs.nl/tag/extreme-startup/'>extreme startup</a>, <a href='http://blog.iprofs.nl/tag/infinity/'>infinity</a>, <a href='http://blog.iprofs.nl/tag/maths/'>maths</a>, <a href='http://blog.iprofs.nl/tag/programming/'>programming</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iprofs.wordpress.com/1977/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iprofs.wordpress.com/1977/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iprofs.wordpress.com/1977/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iprofs.wordpress.com/1977/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iprofs.wordpress.com/1977/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iprofs.wordpress.com/1977/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iprofs.wordpress.com/1977/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iprofs.wordpress.com/1977/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iprofs.wordpress.com/1977/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iprofs.wordpress.com/1977/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iprofs.wordpress.com/1977/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iprofs.wordpress.com/1977/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iprofs.wordpress.com/1977/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iprofs.wordpress.com/1977/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.iprofs.nl&#038;blog=13247689&#038;post=1977&#038;subd=iprofs&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.iprofs.nl/2012/04/16/devnology-community-day-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/54cdc75590b54d20a4ae3b0b04f55b6b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lvdpal</media:title>
		</media:content>
	</item>
		<item>
		<title>Patching open-source java software with Maven</title>
		<link>http://blog.iprofs.nl/2012/04/16/patching-open-source-java-software-with-maven/</link>
		<comments>http://blog.iprofs.nl/2012/04/16/patching-open-source-java-software-with-maven/#comments</comments>
		<pubDate>Mon, 16 Apr 2012 09:31:14 +0000</pubDate>
		<dc:creator>mcbeelen</dc:creator>
				<category><![CDATA[iPROFS]]></category>

		<guid isPermaLink="false">http://blog.iprofs.nl/?p=2072</guid>
		<description><![CDATA[As soon as you start using third party libraries in your project, you also introduce all the bugs in those libraries into your project. There are various ways to handle these kinds of situations: Sometimes you won&#8217;t even notice the bugs being present, when you don&#8217;t use that section of the library. When you do [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.iprofs.nl&#038;blog=13247689&#038;post=2072&#038;subd=iprofs&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As soon as you start using third party libraries in your project, you also introduce all the bugs in those libraries into your project.</p>
<p>There are various ways to handle these kinds of situations:</p>
<ul>
<li>Sometimes you won&#8217;t even notice the bugs being present, when you don&#8217;t use that section of the library.</li>
<li>When you do notice a bug, you can upgrade to newer version of the library in which the bug was already fixed.</li>
<li>You might create a work-around in your code.</li>
<li>Or you could patch the third-party library.</li>
</ul>
<p>Sometimes the patch already is present in the trunk of the project, but no newer release is made yet. Encouraging a release-early, release-ofter strategy sometimes work to get a stable release without the bug being present, but it&#8217;s good to have alternatives. Most likely you aren&#8217;t a committer on the project of the library, so you become dependend on other developers, which could create problems for your deadlines.</p>
<p>This procedure in this post will describe a way to create a stable patched released version of the third party library in your own software repository.</p>
<p>In this post I will use the recaptcha4j library as the example of the software to patch. The only available released version of that library is net.tanesha.recaptcha4j:recaptcha4j:0.0.7. The code in this library still references the server URL&#8217;s on https://api-secure.recaptcha.net instead of the newer https://www.google.com/recaptcha/api. Since the names in the SSL certificates won&#8217;t match various browsers will show warnings or won&#8217;t work at all on the old URL&#8217;s. So the task at hand is to create a patched version of the library, which will use the new URL&#8217;s.</p>
<p>One way of doing this is copying the entire project into your own source code management tool, make the changes and release software. I prefer to keep the original software as seperate as possible from my own changes. So my way of doing this is:</p>
<ol>
<li>Create a maven project for the patched version.</li>
<li>Extracting the original classes out of the third party library during a maven build cycle.</li>
<li>Replace the classes, which need to be patched by custom versions.</li>
<li>Create a new jar-file containing the combination of original and patched classes.</li>
</ol>
<p>Note: Of course I use some naming convention to prevent version conflict between the original software and the patched version.</p>
<h3>Create a maven project for the patched version.</h3>
<p>Of course you need a project location in your own source code management tool and create the default maven project structure with a pom.xml.</p>
<p>To identify the patched version of the library I use the groupId and artifactId of the original library, so everybody will still recognize dependency on the third party library. Within the version of I add an extra version-digit plus a describtion of the patched.<br />
In our example it would become:</p>
<pre>  &lt;groupId&gt;net.tanesha.recaptcha4j&lt;/groupId&gt;
  &lt;artifactId&gt;recaptcha4j&lt;/artifactId&gt;
  &lt;version&gt;0.0.7.1-iprofs-https-patched-SNAPSHOT&lt;/version&gt;</pre>
<p>Within this pom I add a dependency to the original &#8216;broken&#8217; version of the third party library. This will add all classes and dependencies to the classpath of my project enabling my IDE to use those classes during the build.</p>
<pre>  &lt;dependency&gt;
    &lt;groupId&gt;net.tanesha.recaptcha4j&lt;/groupId&gt;
    &lt;artifactId&gt;recaptcha4j&lt;/artifactId&gt;
    &lt;version&gt;${original.recaptcha4j.version}&lt;/version&gt;
    &lt;type&gt;jar&lt;/type&gt;
  &lt;/dependency&gt;</pre>
<h3>Extracting the original classes</h3>
<p>During the build I use the<a title="maven-dependency-plugin" href="http://maven.apache.org/plugins/maven-dependency-plugin/"> maven-dependency-plugin</a> to extract the classes from the original version to the target build location. This will ensure all classes will become part of the new patched jar-file. You need to exclude all broken classes from extraction, because your patched versions will not become part of the jar-file if the originals are already present in the target location.</p>
<pre>&lt;plugin&gt;
  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
  &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
  &lt;executions&gt;
    &lt;execution&gt;
      &lt;id&gt;unpack&lt;/id&gt;
      &lt;phase&gt;generate-sources&lt;/phase&gt;
	&lt;goals&gt;
	  &lt;goal&gt;unpack&lt;/goal&gt;
	&lt;/goals&gt;
	&lt;configuration&gt;
	  &lt;artifactItems&gt;
	    &lt;artifactItem&gt;
		&lt;groupId&gt;net.tanesha.recaptcha4j&lt;/groupId&gt;
		&lt;artifactId&gt;recaptcha4j&lt;/artifactId&gt;
		&lt;version&gt;${original.recaptcha4j.version}&lt;/version&gt;
		&lt;type&gt;jar&lt;/type&gt;
		&lt;overWrite&gt;true&lt;/overWrite&gt;
		&lt;outputDirectory&gt;${project.build.directory}/classes&lt;/outputDirectory&gt;
		&lt;excludes&gt;
		  **/ReCaptchaImpl.class,**/ReCaptchaFactory.class
		&lt;/excludes&gt;
	    &lt;/artifactItem&gt;
	  &lt;/artifactItems&gt;
	&lt;/configuration&gt;
     &lt;/execution&gt;
   &lt;/executions&gt;
 &lt;/plugin&gt;</pre>
<h3>Replace the classes, which need to be patched by custom versions.</h3>
<p>Within my project I create the same package structure and classes for all classes, which need to be patched.<br />
Extracting them from a source jar is a very good way to get started or copy them from the libraries version control system.<br />
In my example it would be net.tanesha.recaptcha.ReCaptchaImpl.</p>
<h3>Create the patched jar-file.</h3>
<p>For this step you don&#8217;t need to do anything special. If you properly excluded the patched classes the maven build process will extract and compile all classes to the proper locations and the maven-jar-plugin will build your patched jar-file. Using your normal <a href="http://maven.apache.org/developers/release/maven-project-release-procedure.html">maven release process</a> you are now able to create a patched stable release version and deploy it into your own software repository.</p>
<h2>Tricky situations.</h2>
<p>After using this procedure to create a patched version of the recaptha library and redeploying the software I still noticed that references to the old server URL&#8217;s were being used. The cause of this weird behaviour was a compiler optimalization called &#8216;<a title="Constant Folding" href="http://en.wikipedia.org/wiki/Constant_folding">Constant folding</a>&#8216;. &#8217;Constant folding&#8217; is the proces of replacing all references to or calculations of constants values by the final constant value in the byte code of the compiled classes.</p>
<p>Within the recaptcha library the ReCaptchaFactory references the constants defined in the ReCaptchaImpl. In the original class file for the ReCapthcaFactory the values still were the server URL&#8217;s which we needed to patch in the first place. Therefor the exclusions in the dependency extraction does contain that Factory as well.</p>
<h2>Recommendations.</h2>
<h4>Contribute back to the original project.</h4>
<p>If you went through all this trouble to fix a bug in an open source library, it is recommended that you create a patch of your changes and submit those to the open source project. Many project welcome such contributions and you get to make the world a better place for everybody.</p>
<h4>Monitor releases for the original project.</h4>
<p>Subscribe to the release mailing list of the original project and monitor their future releases. As soon as the provided a release, which incorporated your patch, switch to using the normal orginal library again.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iprofs.wordpress.com/2072/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iprofs.wordpress.com/2072/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iprofs.wordpress.com/2072/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iprofs.wordpress.com/2072/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iprofs.wordpress.com/2072/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iprofs.wordpress.com/2072/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iprofs.wordpress.com/2072/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iprofs.wordpress.com/2072/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iprofs.wordpress.com/2072/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iprofs.wordpress.com/2072/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iprofs.wordpress.com/2072/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iprofs.wordpress.com/2072/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iprofs.wordpress.com/2072/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iprofs.wordpress.com/2072/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.iprofs.nl&#038;blog=13247689&#038;post=2072&#038;subd=iprofs&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.iprofs.nl/2012/04/16/patching-open-source-java-software-with-maven/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1634a2815d3a7b9aeaa62ed403410c53?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mcbeelen</media:title>
		</media:content>
	</item>
		<item>
		<title>Software licenses and commercial use</title>
		<link>http://blog.iprofs.nl/2012/04/13/software-licenses-and-commercial-use/</link>
		<comments>http://blog.iprofs.nl/2012/04/13/software-licenses-and-commercial-use/#comments</comments>
		<pubDate>Fri, 13 Apr 2012 15:08:42 +0000</pubDate>
		<dc:creator>hhazewinkel</dc:creator>
				<category><![CDATA[iPROFS]]></category>

		<guid isPermaLink="false">http://blog.iprofs.nl/?p=2065</guid>
		<description><![CDATA[Many developers already use a lot of open-source software in their development process. They mostly use libraries offered as open-source by developer groups, but some companies even offer their complete product as open-source. This all looks as one can use it for free and with any form of integration. However, most of those software package [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.iprofs.nl&#038;blog=13247689&#038;post=2065&#038;subd=iprofs&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Many developers already use a lot of open-source software in their development process. They mostly use libraries offered as open-source by developer groups, but some companies even offer their complete product as open-source. This all looks as one can use it for free and with any form of integration. However, most of those software package come with a software license similar as almost commercial software does. Only open-source software is by many considered &#8216;free&#8217;, but what is a free software license? A free software license grants recipients extensive rights to modify and redistribute, which would otherwise be prohibited by copyright law.</p>
<p><em><strong>HISTORY</strong></em></p>
<p>In the mid-1980s, the GNU project created for each of hist software packages a free software license. The first free license in history, the GCC General Public License, was applied to the GNU Compiler Collection and was initially published in 1987. The first BSD license dates to 1989 and was amongst the first free software licenses. In 1989, the first version of the GNU General Public License (GPL) was published, but within 2 years an updated Version 2 of the GPL (GPLv2) was released. GPLv2 went on to become the most widely used free software license. With the rise of the Internet to the public in the mid-90s and until the mid-00s, a new trend started where companies and projects wrote their own licenses, or adapting others&#8217; licenses to insert their own name. From that point on also the complexity of licenses increased significantly due to incompatibilities. For instance, the GNU GPL version 2 license, has been brought to court, first in Germany and later in the USA. In the German case the judge did not explicitly discuss the validity of the GPL&#8217;s clauses but accepted that the GPL had to be adhered to &#8220;If the GPL were not agreed upon by the parties, defendant would notwithstanding lack the necessary rights to copy, distribute, and make the software &#8216;netfilter/iptables&#8217; publicly available&#8221;, because the defendant did not comply with the GPL, it had to stop using the GPL-ed software. The US case (MySQL vs Progress) was settled before a verdict was arrived at, but at an initial hearing the judge &#8220;saw no reason&#8221; that the GPL would not be enforceable. After this, different groups promoting and defending specific software licenses started to exist.</p>
<p><em><strong>SOME MAINSTREAM LICENSES</strong></em></p>
<p>The following section provides a summary of well-known licenses and how they could be used effectively in commercial software.</p>
<p>NOTE: The following statements are guidelines, but for usage of software with a specific license is advised to search legal council as, for instance, this might also change per country&#8217;s law.</p>
<p><em>GPL [1]</em></p>
<p>The GNU General Public License (GNU GPL or simply GPL) is the most widely used free software license, originally written by Richard Stallman for the GNU Project. GPL is based on the copyleft license that derived works van only be distributed under the same license terms. Anyone using a software library with a GPL license must effectively assign the same GPL license to its final software product.<br />
With the concept &#8216;copyleft&#8217; an author surrenders some but not all rights under copyright law. Instead of allowing a work to fall completely into the public domain (where no ownership of copyright is claimed), copyleft allows an author to impose some restrictions on those who want to engage in activities that would more usually be reserved by the copyright holder. Under copyleft, derived works may be produced provided they are released under the compatible copyleft scheme.</p>
<p><em>BSD license [2]</em></p>
<p>The original BSD license was used for the Berkeley Software Distribution (BSD), a Unix-like operating system after which it is named. The license was initially written by the Regents of the University of California, because BSD was first written at the University of California, Berkeley.<br />
The BSD license are a family of permissive free software licenses and software libraries with the BSD license allows proprietary use. Such a software library can be incorporated without enforcing the newly created software to be release under the same BSD license as GPL would have done. Therefore, works based on the software may be released under a proprietary license or as closed source software.</p>
<p><em>MIT License [3]</em></p>
<p>The MIT License is a permissive free software license originating at the Massachusetts Institute of Technology (MIT). The license allows reuse within proprietary software provided all copies of the licensed software include a copy of the MIT License terms. The resulting software that incorporates a library with a MIT license  retains its proprietary nature even though it incorporates software under the MIT License. In short, all derived works require that the copyrights of the incorporated software is attributed, but may have a different license.<br />
A well-know derived license is the XFree86 project that was the X-Windows system for Unix like operating <em>systems.</em></p>
<p><em>Lesser GPL [4]</em></p>
<p>The GNU Lesser General Public License (LGPL) is created by the Free Software Foundation as a compromise between the strong-copyleft GNU General Public License (GPL) and permissive licenses such as the BSD licenses and the MIT License. The main difference between GPL and LPGL is that the latter allows software linked against LGPL software to be any other type of software license, but any derivative work of the LPGL-ed software falls under the LGPL license. Essentially, if you use the LGPL software you have the freedom to choose the license, but if you are modifying the software itself those changes must be published under LGPL.</p>
<p><em>Apache License [5]</em></p>
<p>The apache License is a free software license created by the Apache Software Foundation. This type of license allows users of the software the freedom to use the software for any purpose, to distribute it, to modify it, and to distribute modified versions of the software, under the terms of the license. But the Apache License does not require modified versions of the software to be distributed using the same license (in contrast to copyleft licenses), but in every licensed file, any original copyright, patent, trademark, and attribution notices in redistributed code must be preserved. In case a licensed file has been changed also a statement must be added that it is changed compared to the original licensed file.</p>
<p><em>Multi-License</em></p>
<p>This approach to licensing is used by commercial companies that like to have their product offered as open source. That way and most commonly done, commercial companies offer under an open source license the software to be used for free as long it is not for commercial usage. As soon the user would like to use the software commercially a different commercial license is applicable.</p>
<p><em><strong>SUMMARY</strong></em></p>
<p>When choosing open source software as components for your application it is important to realize the eventual use of the application. Is it commercially used or distributed are the main questions that impact the choice. Almost any software that is used commercially is better not to implement with GPL licensed software as you application is that also GPL and should be distributed as open source. Various other licenses, such as BSD, MIT, Apache or the LGPL license, have little impact on your choice of license of the new application and allow commercial usage.</p>
<p><em><strong>References:</strong></em></p>
<p>[1] http://en.wikipedia.org/wiki/GNU_General_Public_License<br />
[2] http://en.wikipedia.org/wiki/BSD_licenses<br />
[3] http://en.wikipedia.org/wiki/MIT_License<br />
[4] http://en.wikipedia.org/wiki/LGPL_license<br />
[5] http://en.wikipedia.org/wiki/Apache_license</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iprofs.wordpress.com/2065/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iprofs.wordpress.com/2065/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iprofs.wordpress.com/2065/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iprofs.wordpress.com/2065/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iprofs.wordpress.com/2065/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iprofs.wordpress.com/2065/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iprofs.wordpress.com/2065/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iprofs.wordpress.com/2065/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iprofs.wordpress.com/2065/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iprofs.wordpress.com/2065/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iprofs.wordpress.com/2065/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iprofs.wordpress.com/2065/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iprofs.wordpress.com/2065/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iprofs.wordpress.com/2065/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.iprofs.nl&#038;blog=13247689&#038;post=2065&#038;subd=iprofs&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.iprofs.nl/2012/04/13/software-licenses-and-commercial-use/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d2e5d50d10a3a382abc103dba89f8010?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hhazewinkel</media:title>
		</media:content>
	</item>
	</channel>
</rss>
