<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://andersnoras.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Community Server</title><link>http://andersnoras.com/blogs/default.aspx</link><description>The platform that enables you to build rich, interactive communities</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.2)</generator><item><title>WTF: Build Failed: No Failed Tests Found</title><link>http://andersnoras.com/blogs/anoras/archive/2008/04/16/wtf-build-failed-no-failed-tests-found.aspx</link><pubDate>Wed, 16 Apr 2008 20:47:02 GMT</pubDate><guid isPermaLink="false">719912c1-f1f1-4ca9-83e8-cfd07bb165d8:556</guid><dc:creator>andersnoras</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;The guys at &lt;a href="http://www.codehaus.org"&gt;Codehaus&lt;/a&gt; are moving the continuous integration servers. I must say that I had a WTF-moment when this build failure notification dropped in my inbox: &lt;img src="http://andersnoras.com/blogs/anoras/2008-04-16_bamboo_wtf.png" alt="Bamboo wtf" title=""&gt; I find it amusing that the build failed because &amp;#8220;all the tests passed&amp;#8221;. The real reason was that it was unable to find Maven on the build server&amp;#8230;&lt;/p&gt;&lt;img src="http://andersnoras.com/aggbug.aspx?PostID=556" width="1" height="1"&gt;</description><category domain="http://andersnoras.com/blogs/anoras/archive/tags/Musings/default.aspx">Musings</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/Java/default.aspx">Java</category></item><item><title>Reminder: Quick and Dirty Fixes Are Expensive</title><link>http://andersnoras.com/blogs/anoras/archive/2008/04/15/reminder-quick-and-dirty-fixes-are-expensive.aspx</link><pubDate>Tue, 15 Apr 2008 21:35:00 GMT</pubDate><guid isPermaLink="false">719912c1-f1f1-4ca9-83e8-cfd07bb165d8:549</guid><dc:creator>andersnoras</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;&lt;a href="http://andersnoras.com/blogs/anoras/archive/2008/04/09/reminder-getting-bduf-wrong-is-expensive.aspx"&gt;Last week I wrote a short anecdote about getting big, upfront design wrong&lt;/a&gt;. The next chapter is on quick and dirty fixes. You know, those hacks we do to &amp;#8220;make something work&amp;#8221;. These often come about after frenetic debugging session, where we debug a system into existence. Smacking a piece of drywall on top of the existing drywall is a real-world example.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://andersnoras.com/blogs/anoras/2008-04-15_dscf8125.jpg" alt="Dscf8125" title=""&gt;&lt;/p&gt;

&lt;p&gt;Quick and dirty fixes often have side-effects and so does this. Notice that a drawer is missing? Its because it won&amp;#8217;t fit when the wall is 1 centimeter, or about half an inch, thicker.&lt;/p&gt;

&lt;p&gt;Fixes like these need to be done over, taking (almost) twice as long as doing it right the first time around.&lt;/p&gt;&lt;img src="http://andersnoras.com/aggbug.aspx?PostID=549" width="1" height="1"&gt;</description><category domain="http://andersnoras.com/blogs/anoras/archive/tags/Musings/default.aspx">Musings</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/Agile/default.aspx">Agile</category></item><item><title>I'm on Twitter</title><link>http://andersnoras.com/blogs/anoras/archive/2008/04/14/i-m-on-twitter.aspx</link><pubDate>Tue, 15 Apr 2008 13:58:00 GMT</pubDate><guid isPermaLink="false">719912c1-f1f1-4ca9-83e8-cfd07bb165d8:548</guid><dc:creator>andersnoras</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;OK, I know I'm late to the party here, but I've started to upgrade from Web 1.0 to Web 2.0. I've even got myself a Twitter profile. You guys can keep an eye on what I'm wasting time on at &lt;a href="http://twitter.com/anoras"&gt;http://twitter.com/anoras.&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://andersnoras.com/aggbug.aspx?PostID=548" width="1" height="1"&gt;</description></item><item><title>CodeDomProviders and Compiler Magic</title><link>http://andersnoras.com/blogs/anoras/archive/2008/04/13/codedomproviders-and-compiler-magic.aspx</link><pubDate>Mon, 14 Apr 2008 12:05:34 GMT</pubDate><guid isPermaLink="false">719912c1-f1f1-4ca9-83e8-cfd07bb165d8:543</guid><dc:creator>andersnoras</dc:creator><slash:comments>3</slash:comments><description>&lt;p&gt;Before .NET 3.5 was released the choice of whether you should choose Visual Basic or C# as your programming language was more or less a matter of taste. With the first incarnations of these languages, you could do virtually the same things with both. Visual Basic 9.0 introduced quite a few new interesting features, and the support for XML literals is my favorite. For those unfamiliar with Visual Basic, XML literals allows you to work with XML DOMs using the all so familiar markup syntax. For instance you this code will build a DOM.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Dim myDOM = &amp;lt;SomeElement&amp;gt; _
                &amp;lt;SomeOtherElement withAnAttribute="42"&amp;gt; _
                    The time is &amp;lt;%= DateTime.Now %&amp;gt; _
                &amp;lt;/SomeOtherElement&amp;gt; _
            &amp;lt;/SomeElement&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Notice that you can have inline code similar to what you&amp;#8217;re familiar with from ASP.NET. You can also use XML literals as a replacement for DOM methods to reference elements within the DOM.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Dim someDocument = XDocument.Load("somedocument.xml")
XElement someOtherElement = someDocument.&amp;lt;SomeElement&amp;gt;.&amp;lt;SomeOtherElement&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;XML literals can be used in combination with LINQ and other Visual Basic features, and is a powerful tool when working with XML.&lt;/p&gt;

&lt;p&gt;A couple of weeks ago I had a discussion with a team who were planning to use IBM&amp;#8217;s Process Server and ESB to produce direct marketing campaigns from Excel documents with assorted information like customer names, addresses, key account managers and so forth. Their idea was to write an adapter for the ESB to be able to consume Excel spreadsheets as data sources, convert these into Service Data Objects and use the Process Server&amp;#8217;s mapping abilities to transform the Excel documents into XML that can be passed on to our document production service.
Can you imagine how loud my &amp;#8220;YANGI&amp;#8221;-scream was? This was the perfect moment to exploit Visual Basic&amp;#8217;s XML literals to fight enterpriceyness, so I decided to spend a few hours to build a light-weight solution for this. The application accepts an Excel spreadsheet and row template, and produces an XML document with the result. The row template is written using Visual Basic&amp;#8217;s XML literals and looks similar to this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;Letter&amp;gt;
    &amp;lt;FirstName&amp;gt;&amp;lt;%= row("First Name") %&amp;gt;&amp;lt;/FirstName&amp;gt;
    &amp;lt;LastName&amp;gt;&amp;lt;%= row("Last Name") %&amp;gt;&amp;lt;/LastName&amp;gt;
    &amp;lt;HasSameLastNameAsSpouse&amp;gt;
        &amp;lt;=% IIf (row("Last Name") = row("Spouse's Last Name"),"Yes","No") %&amp;gt;
    &amp;lt;/HasSameLastNameAsSpouse&amp;gt;&amp;lt;
    &amp;lt;!-- And so on... --&amp;gt;
&amp;lt;/Letter&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I took me about 45 minutes to write the application, but there was one small problem. The row templates wouldn&amp;#8217;t compile using Visual Basic&amp;#8217;s CodeDomProvider - even if the generated code built perfectly using the Visual Basic compiler.
It turned out that the reason for this was that even when using .NET 3.5, the CodeDomProviders default to using version 2.0 of the compilers. If you&amp;#8217;re targeting Visual Basic 9.0, you&amp;#8217;ll have to specify this when you create a new CodeDomProvider. The MSDN documentation does not mention this at all, and the many ways of getting hold of a CodeDomProvider makes this even more confusing.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;CodeDomProvider vbProvider = CodeDomProvider.CreateProvider("vb");
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;When you use the factory, you can only specify which language you&amp;#8217;re targeting, so we&amp;#8217;ll have to instantiate the provider via its constructor. The constructors for the VBCodeProvider and the CSCodeProvider accept an undocumented IDictionary as its argument. It turns out that you can pass configuration options in this dictionary. So to create a .NET 3.5 VBCodeProvider you&amp;#8217;ll need to this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;CodeDomProvider provider = new VBCodeProvider(
    new Dictionary&amp;lt;string, string&amp;gt;{{"CompilerVersion","v3.5"}});
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This is also the case if you&amp;#8217;re looking to use the CodeDOM with C# 3.0 code. The only difference is that you&amp;#8217;ll need to create a CSCodeProvider rather than the Visual Basic one. Below is the complete code for my super simple &amp;#8220;template engine&amp;#8221;.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;var className = Guid.NewGuid().ToString("n");
var src = GetTemplate(className);            
CodeDomProvider provider = new VBCodeProvider(
    new Dictionary&amp;lt;string, string&amp;gt;{{"CompilerVersion","v3.5"}});
    var compilerParameters=new CompilerParameters {GenerateInMemory = true};
    var compilerResults = provider.CompileAssemblyFromSource(compilerParameters, src);
    if (compilerResults.Errors.HasErrors)
    {
        throw new CompilationException(compilerResults, src);
    }
return Activator.CreateInstance(compilerResults.CompiledAssembly.GetType(className));
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Even if it is confusing, it&amp;#8217;s still very easy to compile code using these new language features. Just remember that you&amp;#8217;ll need to specify some magic strings to get the compiler to apply it&amp;#8217;s magic. &lt;/p&gt;&lt;img src="http://andersnoras.com/aggbug.aspx?PostID=543" width="1" height="1"&gt;</description><category domain="http://andersnoras.com/blogs/anoras/archive/tags/.NET/default.aspx">.NET</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/Visual+Basic/default.aspx">Visual Basic</category></item><item><title>Reminder: Getting BDUF Wrong Is Expensive</title><link>http://andersnoras.com/blogs/anoras/archive/2008/04/09/reminder-getting-bduf-wrong-is-expensive.aspx</link><pubDate>Wed, 09 Apr 2008 22:39:40 GMT</pubDate><guid isPermaLink="false">719912c1-f1f1-4ca9-83e8-cfd07bb165d8:541</guid><dc:creator>andersnoras</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Last November my family and I move into a brand new apartment. Since we&amp;#8217;ve moved in, we&amp;#8217;ve had builders coming in to fix things over and over again. Today they started to &amp;#8220;refactor&amp;#8221; the wiring in our kitchen. Maybe I should get this picture framed as a reminder of not to trust Big Design Upfront (which is the way they build stuff). &lt;/p&gt;

&lt;p&gt;&lt;img src="http://andersnoras.com/blogs/anoras/2008-04-10_dscf8106.jpg" alt="Dscf8106" title=""&gt;&lt;/p&gt;

&lt;p&gt;The carpenter has a rather agile aporach to his work, and he&amp;#8217;ll be tearing down parts of the kitchen to replace the entire wall tomorrow. Luckily, I&amp;#8217;m not paying for this.&lt;/p&gt;&lt;img src="http://andersnoras.com/aggbug.aspx?PostID=541" width="1" height="1"&gt;</description><category domain="http://andersnoras.com/blogs/anoras/archive/tags/Musings/default.aspx">Musings</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/Agile/default.aspx">Agile</category></item><item><title>More on generics and Inversion of Control</title><link>http://andersnoras.com/blogs/anoras/archive/2008/04/06/more-on-generics-and-inversion-of-control.aspx</link><pubDate>Mon, 07 Apr 2008 13:29:54 GMT</pubDate><guid isPermaLink="false">719912c1-f1f1-4ca9-83e8-cfd07bb165d8:539</guid><dc:creator>andersnoras</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;My last post on &lt;a href="http://andersnoras.com/blogs/anoras/archive/2008/04/03/generics-inversion-of-control-and-repository-t.aspx"&gt;Java generics and the Repository pattern&lt;/a&gt; got a bit of interest. Judging from the feedback I got, I feel the need to elaborate on the Inversion of Control part of this. As some readers pointed out, Google&amp;#8217;s &lt;a href="http://code.google.com/p/google-guice/"&gt;Guice container&lt;/a&gt; employes super type tokens to support generics to some extent. The IoC example I gave in my previous post can be implemented with Guice by binding a TypeLiteral of the interface to a concrete implementation of that interface.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;public class RepositoriesModule implements Module {
   public void configure(Binder binder) {
       binder.bind(new TypeLiteral&amp;lt;Repository&amp;lt;Product&amp;gt;&amp;gt;() {}).to(ProductRepository.class);
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can resolve an implementation of a Repository by asking the injector for an instance of the same TypeLiteral that instance is bound to.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Injector injector = Guice.createInjector(new RepositoriesModule());
Repository&amp;lt;Product&amp;gt; repository = injector.getInstance(Key.get(new TypeLiteral&amp;lt;Repository&amp;lt;Product&amp;gt;&amp;gt;() {}));
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;However, this does provide a solution similar to how we can inject generic repositories using something like &lt;a href="http://www.castleproject.org"&gt;the Windsor container&lt;/a&gt; for .NET. With Windsor, you can bind a generic interface, say IRepository, to a generic implementation of that interface such as ConcreteRepository : IRepository.
This allows us to resolve a useable repository instance like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;WindsorContainer container = new WindsorContainer();
IRepository&amp;lt;Product&amp;gt; repository = container.Resolve&amp;lt;IRepository&amp;lt;Product&amp;gt;&amp;gt;();
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;One thing to note here is that there is no need to have concrete implementations for every domain object (Product, Order, Customer and similar), a generic implementation of the ConcreteRepository is sufficient because .NET has bona fide generics implemented in the Common Language Runtime (CLR) and the CLR will create a new bound type of the generic class at runtime. This is even the case if we use reflection to create the instance.&lt;/p&gt;

&lt;p&gt;The Guice container allows us to specify providers to which the creation of a dependency will be delegated. However, this provider is bound to the type arguments for the TypeLiteral and wild card type arguments cannot be used because the compiler is unable to infer the runtime type of such an argument. As a result we would need to bind all the TypeLiterals to different concrete implementations or different providers to support this pattern with Guice. This is a show stopper because it takes away the pattern&amp;#8217;s flexibility.
To exemplify the concept, I changed my naïve IoC container from my previous post to support this pattern using Guice&amp;#8217;s TypeLiterals. Here is an example of binding the Repository interface to a provider which will create the typed instances via the RepositoryFactory shown in my previous post. (If you haven&amp;#8217;t read that post, &lt;a href="http://andersnoras.com/blogs/anoras/archive/2008/04/03/generics-inversion-of-control-and-repository-t.aspx"&gt;now is a good time&lt;/a&gt;.) &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;@Test
public void canRegisterAnOpenGenericInterfaceAndResolveItsImplementationViaABoundInterface()
{
    // Register the open generic interface and bind it to a provider.
    IoC.register(new TypeLiteral&amp;lt;Repository&amp;gt;() {},new Provider&amp;lt;Repository&amp;gt;() {
        @SuppressWarnings({"unchecked"})
        public Repository get(TypeLiteral&amp;lt;? extends Repository&amp;gt; type) {
            ParameterizedType pt = (ParameterizedType) type.getType();
            return RepositoryFactory.create((Class&amp;lt;?&amp;gt;) pt.getActualTypeArguments()[0]);
        }
    });
    // Resolve an instance of a bound interface.
    Repository&amp;lt;Order&amp;gt; repository = IoC.resolve(new TypeLiteral&amp;lt;Repository&amp;lt;Order&amp;gt;&amp;gt;() {});
    Assert.assertTrue(repository instanceof AbstractRepository);
    Assert.assertSame(Order.class,repository.getEntityClass());
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In this example we first register the open generic interface, akin to IRepository&amp;lt;&gt; in .NET, to a provider for that interface. The provider implementation has to perform some unchecked operations to allow this to work, but this is not really something to worry about. When we resolve the instance, we pass a fully bound TypeLiteral to the container. The provider is passed this TypeLiteral as an argument, and the type argument is extracted from it. In this example this will be a TypeLiteral&gt;. Since the provider is bound to the open generic type Repository, the extracted type argument will be Order. This provides us with enough type information to create a strongly type instance of the AbstractRepository via the RepositoryFactory class.&lt;/p&gt;

&lt;p&gt;We also need to be able to distinguish between generic implementations and concrete ones. So lets bring in the ProductRepository class from my previous post.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;@Test
public void boundServicesHavePrecedenceOverOpenGenericServices()
{
    IoC.register(new TypeLiteral&amp;lt;Repository&amp;gt;() {},new Provider&amp;lt;Repository&amp;gt;() {
        @SuppressWarnings({"unchecked"})
        public Repository get(TypeLiteral&amp;lt;? extends Repository&amp;gt; type) {
            ParameterizedType pt = (ParameterizedType) type.getType();
            return RepositoryFactory.create((Class&amp;lt;?&amp;gt;) pt.getActualTypeArguments()[0]);
        }
    });
    IoC.register(new TypeLiteral&amp;lt;Repository&amp;lt;Product&amp;gt;&amp;gt;() {},ProductRepository.class);

    Repository&amp;lt;Product&amp;gt; repository = IoC.resolve(new TypeLiteral&amp;lt;Repository&amp;lt;Product&amp;gt;&amp;gt;() {});
    Assert.assertTrue(repository instanceof ProductRepository);
    Assert.assertSame(Product.class, repository.getEntityClass());
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This is basically the same test case over, but with one important difference. In this example two services are registered in the container. First the provider for the open generic Repository interface is registered, and then the concrete implementation for the bound Repository is registered. When we resolve the service for TypeLiteral&gt; we expect to get an instance of ProductRepository back, rather than a runtime generated instance of the AbstractRepository.&lt;/p&gt;

&lt;p&gt;Below is the entire implementation of the &amp;#8220;container&amp;#8221; used in these tests.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;public class IoC {
    static Map&amp;lt;TypeLiteral, Provider&amp;gt; registry = new HashMap&amp;lt;TypeLiteral, Provider&amp;gt;();
    public static &amp;lt;T&amp;gt; void register(TypeLiteral&amp;lt;T&amp;gt; service, Provider&amp;lt;T&amp;gt; provider) {
        registry.put(service, provider);
    }
    public static &amp;lt;T&amp;gt; void register(TypeLiteral&amp;lt;T&amp;gt; service, Class&amp;lt;? extends T&amp;gt; impl) {
        registry.put(service, new ConcreteProvider(impl));
    }
    @SuppressWarnings({"unchecked"})
    public static &amp;lt;T&amp;gt; T resolve(TypeLiteral&amp;lt;T&amp;gt; type) {
        if (registry.containsKey(type)) {
            return (T) registry.get(type).get(type);
        } else {
            Type c = type.getRawType();
            while (c != Object.class) {
                ManualTypeLiteral&amp;lt;T&amp;gt; manualTypeLiteral = new ManualTypeLiteral&amp;lt;T&amp;gt;(c);
                if (registry.containsKey(manualTypeLiteral)) {
                    return (T) registry.get(manualTypeLiteral).get(type);
                }
                c = c.getClass().getSuperclass();
            }
            throw new RuntimeException("Not found");
        }
    }
    private static class ManualTypeLiteral&amp;lt;T&amp;gt; extends TypeLiteral&amp;lt;T&amp;gt; {
        private ManualTypeLiteral(Type type) {
            super(type);
        }
    }
    private static class ConcreteProvider&amp;lt;T&amp;gt; implements Provider {
        private final Class&amp;lt;? extends T&amp;gt; impl;
        public ConcreteProvider(Class&amp;lt;? extends T&amp;gt; impl) {
            this.impl = impl;
        }
        public T get(TypeLiteral type) {
            try {
                return impl.getConstructor().newInstance();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The implementation of the container has been simplified to make the example more clear, and is by no means a real container ready for production use. However, I think it should be fairly easy to add this kind of behavior to Guice, and I also believe that it should be well worth while because this kind of flexiblity opens the doors for a whole lot of usage patterns that we are just starting to understand the power of within the .NET community.&lt;/p&gt;&lt;img src="http://andersnoras.com/aggbug.aspx?PostID=539" width="1" height="1"&gt;</description><category domain="http://andersnoras.com/blogs/anoras/archive/tags/DDD/default.aspx">DDD</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/Java/default.aspx">Java</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/.NET/default.aspx">.NET</category></item><item><title>Generics, Inversion of Control and Repository&lt;T&gt;</title><link>http://andersnoras.com/blogs/anoras/archive/2008/04/03/generics-inversion-of-control-and-repository-t.aspx</link><pubDate>Thu, 03 Apr 2008 23:32:00 GMT</pubDate><guid isPermaLink="false">719912c1-f1f1-4ca9-83e8-cfd07bb165d8:533</guid><dc:creator>andersnoras</dc:creator><slash:comments>4</slash:comments><description>&lt;p&gt;Whenever I stray off the beaten path of Java generics, I instantly miss C#’s generics implementation. Earlier today, Java’s type erasure erased a few good hours of productivity whilst I was doing a spike on bringing the &lt;a href="http://www.ayende.com/Blog/archive/9431.aspx"&gt;IRepository&amp;lt;T&amp;gt;&lt;/a&gt; experience to Java. In C# you can get the class of any generic type argument in a straight forward manner.&lt;/p&gt;&lt;pre&gt;&lt;code&gt;public void DoStuff(T thing) &lt;br&gt;{    &lt;br&gt;    Type thingsType = typeof(T);&lt;br&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Because of Java’s type erasure, things aren’t as simple. The Java equivalent of this C# example won’t compile.&lt;/p&gt;&lt;pre&gt;&lt;code&gt;public &amp;lt;T&amp;gt; void doStuff(T thing) {&lt;br&gt;    Class thingsType = T.class;&lt;br&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Still, all is not lost. Even if you’ve been told otherwise, some information about generic type arguments is available at runtime. While the JVM doesn’t track the type arguments for an instance of a generic class, it actually does this for subclasses of that generic class. To work around this limitation you can add the required behavior to infer a class’ type arguments to an abstract base class. &lt;a href="http://www.artima.com/weblogs/index.jsp?blogger=ianr"&gt;Ian Robertson&lt;/a&gt; has &lt;a href="http://www.artima.com/weblogs/viewpost.jsp?thread=208860"&gt;a good write up about this&lt;/a&gt; at &lt;a href="http://www,artima.com"&gt;Artima&lt;/a&gt;.Since many of the features of any repository are common, regardless of its final implementation, my initial design already had an abstract repository class and a repository interface, so using the “extend and infer” technique described in Ian’s post was OK. Basically, this allows you to do this:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;public abstract class AbstractRepository&amp;lt;T&amp;gt; implements Repository&amp;lt;T&amp;gt; {&lt;br&gt;    private Class entityClass;&lt;br&gt;    public final Class getEntityClass() {&lt;br&gt;        if (entityClass == null) {&lt;br&gt;            ReflectionHelper reflectionHelper = new ReflectionHelper();&lt;br&gt;            entityClass = reflectionHelper.getTypeArguments(&lt;br&gt;                            AbstractRepository.class,getClass()&lt;br&gt;                          ).get(0);&lt;br&gt;        }&lt;br&gt;        return entityClass;&lt;br&gt;    }&lt;br&gt;    void setEntityClass(Class entityClass) {&lt;br&gt;        this.entityClass = entityClass;&lt;br&gt;    }&lt;br&gt;    // Implementations of common repository features like&lt;br&gt;    // load, save, delete and so on go here...&lt;br&gt;}&lt;br&gt;&lt;br&gt;public class ProductRepository extends AbstractRepository&amp;lt;Product&amp;gt; {}&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Since ProductRepository specifically extends the AbstractRepository, the type information will be available at runtime and the following test will pass.&lt;/p&gt;&lt;pre&gt;&lt;code&gt;Repository&amp;lt;Product&amp;gt; repository = new ProductRepository();&lt;br&gt;Class inferredEntityClass = repository.getEntityClass();&lt;br&gt;Assert.assertSame(Product.class,inferredEntityClass);&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;But apart form implementing an abstract class, the ProductRepository serves no real purpose. In a real-life scenario, you would probably add some operations specific to Product entities to the repository, but there is no need to do this. So, I’d really like to have a way to create instances of a repository for any entity without creating a separate implementation of the repository for each entity class.Because of the trick we’re using to infer type arguments, we cannot turn the AbstractRepository into a concrete class, but we can extend it with a concrete generic class.&lt;/p&gt;&lt;pre&gt;&lt;code&gt;public class ConcreteRepository&amp;lt;T&amp;gt; extends AbstractRepository&amp;lt;T&amp;gt; {  }&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;a href="http://andersnoras.com/controlpanel/blogs/http;/www.ayende.com/blog"&gt;Ayende&lt;/a&gt; uses this approach to support different object relational mappers in &lt;a href="http://sourceforge.net/projects/rhino-tools/"&gt;his implementation of this pattern for .NET.&lt;/a&gt; However, if we try to use this approach with Java, type erasure comes in and screw things up again.&lt;/p&gt;&lt;pre&gt;&lt;code&gt;Repository&amp;lt;Product&amp;gt; repository = new ConcreteRepository&amp;lt;Product&amp;gt;();&lt;br&gt;Class inferredEntityClass = repository.getEntityClass();&lt;br&gt;// This assertion fails because the type argument (Product) has been&lt;br&gt;// erased and replaced with java.lang.Object...&lt;br&gt;Assert.assertSame(Product.class,inferredEntityClass);&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To work around this, we can stick with our abstract repository and employ &lt;a href="http://gafter.blogspot.com/2006/12/super-type-tokens.html"&gt;Neil Gafter’s “gadget” aka Super Type Tokens&lt;/a&gt;.&lt;/p&gt;&lt;pre&gt;&lt;code&gt;Repository&amp;lt;Product&amp;gt; repository = new AbstractRepository&amp;lt;Product&amp;gt;() {};&lt;br&gt;// Did you notice this method in the AbstractRepository&amp;lt;T&amp;gt; class?&lt;br&gt;repository.setEntityClass(Product.class);&lt;br&gt;Class inferredEntityClass = repository.getEntityClass();&lt;br&gt;Assert.assertSame(Product.class,inferredEntityClass);&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This works, but it makes the client code ugly. So you probably should cover the ugliness with some factory “makeup”.&lt;/p&gt;&lt;pre&gt;&lt;code&gt;public static &amp;lt;T&amp;gt; Repository&amp;lt;T&amp;gt; create(Class&amp;lt;? extends T&amp;gt; entityClass) {&lt;br&gt;    AbstractRepository&amp;lt;T&amp;gt; repository = new AbstractRepository&amp;lt;T&amp;gt;() {};&lt;br&gt;    repository.setEntityClass(entityClass);&lt;br&gt;    return repository;&lt;br&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Now we can instantiate generic repositories this way…&lt;/p&gt;&lt;pre&gt;&lt;code&gt;Repository&amp;lt;Product&amp;gt; repository = RepositoryFactory.create(Product.class);&lt;br&gt;Class inferredEntityClass = repository.getEntityClass();&lt;br&gt;Assert.assertSame(Product.class,inferredEntityClass);&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;…and IMHO, that looks quite alright.&lt;/p&gt;&lt;p&gt;Having a good implementation of a generic repository in place opens the doors to creating adaptive domain models using the patterns and design techniques &lt;a href="http://www.ayende.com/blog"&gt;Ayende&lt;/a&gt; and &lt;a href="http://udidahan.weblogs.us/"&gt;Udi&lt;/a&gt; have &lt;a href="http://udidahan.weblogs.us/2007/09/16/fetching-strategy-nhibernate-implementation-available/"&gt;been&lt;/a&gt; &lt;a href="http://www.ayende.com/Blog/archive/2008/03/27/Adaptive-Domain-Models-with-Rhino-Commons.aspx"&gt;writing&lt;/a&gt; &lt;a href="http://udidahan.weblogs.us/2008/03/20/qcon-london-2008-recap/"&gt;quite&lt;/a&gt; &lt;a href="http://www.ayende.com/Blog/archive/9042.aspx"&gt;a lot&lt;/a&gt; &lt;a href="http://udidahan.weblogs.us/2007/03/06/better-domain-driven-design-implementation/"&gt;about&lt;/a&gt; &lt;a href="http://www.ayende.com/Blog/archive/2008/03/25/Non-Invasive-API-take-2.aspx"&gt;lately&lt;/a&gt;. The missing piece to the puzzle is better generics support from the dependency injection containers available for Java. I’m a bit surprised that there aren’t (AFIK) any containers available that support generics in a similar fashion to what &lt;a href="http://www.springframework.net"&gt;Spring.NET &lt;/a&gt; or &lt;a href="http://www.castleproject.org"&gt;Windsor&lt;/a&gt; do. To get this piece in place, I actually started something I promised myself that I’d never do again - I started to build my own inversion of control framework. Nothing is ready to be made public yet, but I’ll provide you with some examples of its &lt;i&gt;very&lt;/i&gt; limited features.You can register components by specifying its interface and implementation like this (No XML configuration for me, baby!)…&lt;/p&gt;&lt;pre&gt;&lt;code&gt;IoC.register(Repository.class, ProductRepository.class);&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;…and you can resolve a dependency at a later stage by specifying the interface and its generic type argument(s).&lt;/p&gt;&lt;pre&gt;&lt;code&gt;Repository&amp;lt;Product&amp;gt; repository = IoC.resolve(Repository.class,Product.class);&lt;br&gt;Assert.assertTrue(repository instanceof ProductRepository);&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Before you start screaming about the static methods, I’ll inform you that the IoC class is just an accessor that makes the IoC framework readily available. This is an approach I’ve been using for quite some time, and I recommend trying it for yourself. Its &lt;i&gt;very&lt;/i&gt; convenient.&lt;/p&gt;&lt;p&gt;So what do you guys think? Do we need another dependency injection framework? (No worries, I’m just doing this to support some demo code I’m writing and I have no intentions making it a fully fledged framework at the time being.)&lt;/p&gt;&lt;img src="http://andersnoras.com/aggbug.aspx?PostID=533" width="1" height="1"&gt;</description><category domain="http://andersnoras.com/blogs/anoras/archive/tags/DDD/default.aspx">DDD</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/Java/default.aspx">Java</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/.NET/default.aspx">.NET</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/Reinventing+the+wheel/default.aspx">Reinventing the wheel</category></item><item><title>A framework for cross platform DSL development</title><link>http://andersnoras.com/blogs/anoras/archive/2008/03/31/a-framework-for-cross-platform-dsl-development.aspx</link><pubDate>Tue, 01 Apr 2008 10:42:00 GMT</pubDate><guid isPermaLink="false">719912c1-f1f1-4ca9-83e8-cfd07bb165d8:526</guid><dc:creator>andersnoras</dc:creator><slash:comments>6</slash:comments><description>

&lt;p class="MsoNormal"&gt;&lt;span&gt;One of the
challenges I have experienced when giving talks or blogging about domain
specific languages is that developers are a little reluctant to writing code in
languages they are unfamiliar with. This holds true even if the DSL in question
is an external DSL based on commonly available languages such as Boo, Ruby,
Groovy or Scala.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span&gt;Since I
also develop using both .NET and Java, another common challenge is that these
languages aren’t generally available on all platforms. This is a concern
because you can easily lock your self to a platform based on how you choose to
implement your DSLs. After having many discussions around this topic with
luminaries in both the Java and .NET communities, I have concluded that unless
we can address the challenges with making our DSLs true cross platform tools,
we are introducing more complexity than we’re doing good.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span&gt;One of the
reasons I’ve been a bit quite for the last few weeks is that I’ve started a new
project which will be available under the Apache 2.0 license to address these
issues and I’m very glad to introduce the Adaptive Platform Runtime for Interoperable
DSLs – April!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span&gt;To enable
true interoperability and at the same time make it easy to understand for all
developers April is based on familiar XML concepts. Below is an example of one
of the business rule example from my recent talks on external DSLs expressed
with April.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;code&gt;
&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt;&lt;br&gt;&amp;lt;script&amp;gt;&lt;br&gt;&amp;nbsp; &amp;lt;statement&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;when&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;expression&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;lhs&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;reference&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;to&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;instance&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;of_type&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xmlns&amp;gt;http://andersnoras.com/customtypes/customer&amp;lt;/xmlns&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/of_type&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/instance&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;named&amp;gt;customer&amp;lt;/named&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;reference&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;to&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;of_type&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xmlns&amp;gt;http://andersnoras.com/primitivetypes/number&amp;lt;/xmlns&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/of_type&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/property&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;named&amp;gt;age&amp;lt;/named&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/to&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/reference&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/to&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/reference&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/lhs&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;op&amp;gt;&amp;amp;lt;&amp;lt;/op&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;rhs&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;constant&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;value&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;of_type&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xmlns&amp;gt;http://andersnoras.com/primitivetypes/number&amp;lt;/xmlns&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/of_type&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;with_value&amp;gt;25&amp;lt;/with_value&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/value&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/constant&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/rhs&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/expression&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/when&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;then&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;statement&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;increase&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;reference&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;to&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;instance&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;of_type&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xmlns&amp;gt;http://andersnoras.com/customtypes/policy&amp;lt;/xmlns&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/of_type&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/instance&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;named&amp;gt;policy&amp;lt;/named&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;reference&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;to&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;of_type&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xmlns&amp;gt;http://andersnoras.com/primitivetypes/number&amp;lt;/xmlns&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/of_type&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/property&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;named&amp;gt;premium&amp;lt;/named&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/to&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/reference&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/to&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/reference&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;by&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;statement&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;eval&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;expression&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;lhs&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;reference&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;to&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;instance&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;of_type&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xmlns&amp;gt;http://andersnoras.com/customtypes/policy&amp;lt;/xmlns&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/of_type&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/instance&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;named&amp;gt;policy&amp;lt;/named&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;reference&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;to&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;of_type&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xmlns&amp;gt;http://andersnoras.com/primitivetypes/number&amp;lt;/xmlns&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/of_type&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/property&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;named&amp;gt;premium&amp;lt;/named&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/to&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/reference&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/to&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/reference&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/lhs&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;op&amp;gt;%&amp;lt;/op&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;rhs&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;constant&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;value&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;of_type&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xmlns&amp;gt;http://andersnoras.com/primitivetypes/number&amp;lt;/xmlns&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/of_type&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;with_value&amp;gt;25&amp;lt;/with_value&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/value&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/constant&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/rhs&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/expression&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/eval&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/statement&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/by&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/increase&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/statement&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/then&amp;gt;&lt;br&gt;&amp;nbsp; &amp;lt;/statement&amp;gt;&lt;br&gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;
&lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span&gt;One key
thing to notice is that April uses its own XSD based type system. This allows
us to achieve platform portability and interoperability by abstracting away the
individual languages own type systems. To allow customized DSLs, April also
lets you redefine and extend the language using common XML representations.
This is how the “When” keyword has been introduced into the language used
above:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;o:p&gt;&lt;code&gt;&amp;nbsp;&amp;lt;keyword&amp;gt;&lt;br&gt;&amp;nbsp; &amp;lt;name&amp;gt;when&amp;lt;/name&amp;gt;&lt;br&gt;&amp;nbsp; &amp;lt;is_alias_for&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;keyword&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xmlns&amp;gt;urn:apl/core/language/keywords/conditional/if&amp;lt;/xmlns&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/keyword&amp;gt;&lt;br&gt;&amp;nbsp; &amp;lt;/is_alias_for&amp;gt;&lt;br&gt;&amp;nbsp; &amp;lt;semantics&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ast&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;keyword&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;name&amp;gt;when&amp;lt;/name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;expression&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;consisting_of&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;parts&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;part&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;order&amp;gt;0&amp;lt;/order&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;expression&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;allow_any&amp;gt;true&amp;lt;/allow_any&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/expression&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/part&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;part&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;order&amp;gt;1&amp;lt;/order&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;operators&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;operator&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xmlns&amp;gt;urn:apl/core/language/operator/equals&amp;lt;/xmlns&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/operator&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;operator&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xmlns&amp;gt;urn:apl/core/language/operator/greater_than&amp;lt;/xmlns&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/operator&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;operator&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xmlns&amp;gt;urn:apl/core/language/operator/less_than&amp;lt;/xmlns&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/operator&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/operators&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/part&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;part&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;order&amp;gt;2&amp;lt;/order&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;expression&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;allow_any&amp;gt;true&amp;lt;/allow_any&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/expression&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/part&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/parts&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/consisting_of&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/expression&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/keyword&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;keyword&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;name&amp;gt;then&amp;lt;/name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;!-- Eluded for brevety --&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/keyword&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/ast&amp;gt;&lt;br&gt;&amp;nbsp; &amp;lt;/semantics&amp;gt;&lt;br&gt;&amp;lt;/keyword&amp;gt; &lt;br&gt;&lt;/code&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span&gt;Since
everything is XML based you can use your experiences from writing everything
form web.config files to Spring configurations to extend, customize and develop
using April.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span&gt;April’s
core audience is the domain experts who’ll use the DSLs you develop to
customize the business rules of any April enabled application. To reduce the probability
of bugs occurring within these DSLs, you can easily turn of language features
in the DSL context configuration.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;code&gt;&lt;/code&gt;&lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;o:p&gt;&amp;nbsp;&amp;lt;dsl_context&amp;gt;&lt;br&gt;&amp;nbsp; &amp;lt;language_features&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;keyword&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;name&amp;gt;new&amp;lt;/name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;enabled&amp;gt;false&amp;lt;/enabled&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/keyword&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;keyword&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;name&amp;gt;print&amp;lt;/name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;enabled&amp;gt;true&amp;lt;/enabled&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/keyword&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;keyword&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;name&amp;gt;for&amp;lt;/name&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;enabled&amp;gt;false&amp;lt;/enabled&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/keyword&amp;gt;&lt;br&gt;&amp;nbsp; &amp;lt;/language_features&amp;gt;&lt;br&gt;&amp;lt;/dsl_context&amp;gt;&lt;br&gt;&lt;br&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span&gt;Because of
its simplicity and the use of common XML knowledge, my vision is that April
will be the killer app that will enable developers to DSL enabling their
applications today.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span&gt;The source
code will be made available at The Codehaus later today. I encourage everyone
interested in DSLs to start playing around with it, provide feedback or join
the project. Let the DSL revolution begin!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;img src="http://andersnoras.com/aggbug.aspx?PostID=526" width="1" height="1"&gt;</description><category domain="http://andersnoras.com/blogs/anoras/archive/tags/Java/default.aspx">Java</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/.NET/default.aspx">.NET</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/DSL/default.aspx">DSL</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/Open+Source/default.aspx">Open Source</category></item><item><title>Vibrant Ink for IDEA</title><link>http://andersnoras.com/blogs/anoras/archive/2008/03/25/vibrant-ink-for-idea.aspx</link><pubDate>Tue, 25 Mar 2008 20:50:24 GMT</pubDate><guid isPermaLink="false">719912c1-f1f1-4ca9-83e8-cfd07bb165d8:517</guid><dc:creator>andersnoras</dc:creator><slash:comments>6</slash:comments><description>&lt;p&gt;I&amp;#8217;m not sure if its because Java developers have a flurry of good IDEs to choose from, but IDE pimping is a rare hobby among Java developers. However, since I&amp;#8217;m a polyglot developing stuff in a range of languages I enjoy having a familiar, nice look and feel across all the tools I use. When I swapped my Windows for a Mac, I instantly fell in love with TextMate&amp;#8217;s celebrated &lt;a href="http://alternateidea.com/blog/articles/2006/1/3/textmate-vibrant-ink-theme-and-prototype-bundle"&gt;Vibrant Ink theme&lt;/a&gt;. (Fun fact: This blog post is written in TextMate, using Vibrant Ink). I use &lt;a href="http://www.iunknown.com/"&gt;John Lam&lt;/a&gt;&amp;#8217;s &lt;a href="http://www.iunknown.com/2007/06/vibrant_ink_vis.html"&gt;port of the theme&lt;/a&gt; with Visual Studio, but whenever I wrote Java code I was left out in the cold with IntelliJ IDEAs plain old black, blue, red and green on white theme. As you can imagine, this was unbearable for someone used to using tricked out OSes and development tools, so I had to create a port myself.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://andersnoras.com/blogs/anoras/2008-03-25_virbant_1.png" alt="Virbant 1" title=""&gt;&lt;/p&gt;

&lt;p&gt;Volia! Here is the Vibrant Ink theme for IDEA in glorious technicolor. The above screenshot showcases the various features, and (luckily) regular code seldom gets this colorful. &lt;/p&gt;

&lt;p&gt;&lt;img src="http://andersnoras.com/blogs/anoras/2008-03-25_vibrant_2.png" alt="Vibrant 2" title=""&gt;&lt;/p&gt;

&lt;p&gt;If you fancy pimping your IDEA with a touch of cool, you can grab a jar file with my color scheme from &lt;a href="http://idehotornot.ning.com/index.php/index/show?id=37587491"&gt;&amp;#8220;Is your IDE Hot or Not?&amp;#8221;&lt;/a&gt; or directly from &lt;a href="http://andersnoras.com/files/folders/code/entry514.aspx"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Gansta! Yo&amp;#8217;ve gots ta git this themizzle, it tha real shiznits.&lt;br /&gt;
  Snoop Doggy Dog&lt;/p&gt;
&lt;/blockquote&gt;&lt;img src="http://andersnoras.com/aggbug.aspx?PostID=517" width="1" height="1"&gt;</description><category domain="http://andersnoras.com/blogs/anoras/archive/tags/Java/default.aspx">Java</category></item><item><title>English as a DSL</title><link>http://andersnoras.com/blogs/anoras/archive/2008/03/13/english-as-a-dsl.aspx</link><pubDate>Thu, 13 Mar 2008 22:25:10 GMT</pubDate><guid isPermaLink="false">719912c1-f1f1-4ca9-83e8-cfd07bb165d8:496</guid><dc:creator>andersnoras</dc:creator><slash:comments>5</slash:comments><description>&lt;blockquote&gt;
  &lt;p&gt;&amp;#8220;Programming is best regarded as the process of creating works of literature, which are meant to be read&amp;#8230; so we ought to address them to people, not to machines.&amp;#8221;  &lt;/p&gt;
&lt;/blockquote&gt;&lt;br /&gt;
-Donald Knuth, Literate Programming


&lt;p&gt;The last few days there has been a vibrant discussion on which computer science books that deserve its place on the top 10 bookshelf over &lt;a href="http://www.java.no"&gt;at The Norwegian JUG&lt;/a&gt;. A title that quickly sprung to mind was &lt;a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&amp;amp;location=http%3A%2F%2Fwww.amazon.com%2FPragmatic-Programmer-Journeyman-Master%2Fdp%2F020161622X%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1205445996%26sr%3D8-1&amp;amp;tag=andersnorasbl-20&amp;amp;linkCode=ur2&amp;amp;camp=1789&amp;amp;creative=9325"&gt;Pragmatic Programmer: From Journeyman to Master&lt;/a&gt; by &lt;a href="http://pragdave.blogs.pragprog.com/"&gt;Dave Thomas&lt;/a&gt; and Andy Hunt. This is one of the few books that you can read from cover to cover, over and over again and pick up new things every time. Because I love this book, it feels a little scary to pick a discussion with one of the authors, but Dave&amp;#8217;s latest blog &lt;a href="http://pragdave.blogs.pragprog.com/pragdave/2008/03/the-language-in.html"&gt;post on domains specific languages&lt;/a&gt; provoked me to do this.&lt;/p&gt;

&lt;p&gt;In his blog post, Dave makes the point that something isn&amp;#8217;t necessarily a DSL just because it reads like English. I agree with him on this, but this does not imply that English can&amp;#8217;t be used to describe business rules. In my talk on developing domain specific languages with .NET, I used an example from the insurance industry as a foundation for the alternative approaches for implementing a DSL. Insurance is a business I know well since I work for one of the largest insurance companies in the Nordic region. Just like Dave points out, our domain specialists have a common understanding of the meaning of the different terms in their jargon. In &lt;a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&amp;amp;location=http%3A%2F%2Fwww.amazon.com%2FDomain-Driven-Design-Tackling-Complexity-Software%2Fdp%2F0321125215%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1205446065%26sr%3D1-1&amp;amp;tag=andersnorasbl-20&amp;amp;linkCode=ur2&amp;amp;camp=1789&amp;amp;creative=9325"&gt;Domain Driven Design&lt;/a&gt;, Eric Evans describes this as the &lt;a href="http://domaindrivendesign.org/discussion/messageboardarchive/UbiquitousLanguage.html"&gt;ubiquitous language&lt;/a&gt;. In my experience, having a shared understanding of the jargon between business and technical team members and using this jargon to model the software is crucial before on can introduce domain specific languages into the development process.&lt;/p&gt;

&lt;p&gt;My example is a very narrow slice of the business rules for adjusting the risk of a car insurance quote. Still it is very representative for this kind of application. We begin our tale with a simple user story;&lt;/p&gt;

&lt;p&gt;&lt;img src="http://andersnoras.com/blogs/anoras/2008-03-13_userstory019.png" alt="Userstory.019" title=""&gt;&lt;/p&gt;

&lt;p&gt;If we write our requirements in this manner, a natural progression is to write our functional tests in a behavior driven style. &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Scenario(“Customer is an inexperienced driver”);
    Given(“The policy’s premium is”, 1000, delegate(double premium)
    {
        policy = new Policy();
        policy.Premium = premium; 
    });
    Given(“The customer’s age is”, 24, delegate(int age)
    {
        policy.Holder = new Customer();
        policy.Holder.Age = age; 
    });
    When(“A quote for an insurance is issued”, delegate()
    {
        quote = policy.IssueQuote();
    });
    Then(“The policy’s premium should be increased by percentage”, 5, delegate(double percentage)
    {
        Assert.AreEqual(policy.Premium *= 1 + (5 / 100), quote.Premium);
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This code is written using &lt;a href="http://agilejoe.com/"&gt;Joe Oscampo&lt;/a&gt;&amp;#8217;s &lt;a href="http://code.google.com/p/nunitbehave/"&gt;NUnit.Behave&lt;/a&gt; which I claim is an internal DSL, written in C#, for functional testing. Spec frameworks like NUnit.Behave is one of the things Dave &amp;#8220;picks on&amp;#8221; in his post with a valid argument that the domain experts using this DSL are programmers and that writing a specification using the such a framework is programming. This is true, but I think Dave misses a key value of using this approach; even if the specification is littered with C# enforced dots, brackets and parenthesis it is very similar to the free-form user story the spec is derived from. This helps us follow a thread through from the user story through to the specification. If the framework didn&amp;#8217;t enforce a grammatical structure, this would be much harder to achieve. 
Another thing with Dave&amp;#8217;s problem with the host language shining through and hindering him in writing straight forward sentences can be turned into a benefit for fluent interfaces. &lt;a href="http://obiefernandez.com/"&gt;Obie Fernadez&lt;/a&gt; once used the Starbucks jargon to show how to write an internal DSL with Ruby. I&amp;#8217;ve used his example to show how one can implement a fluent interface with C#. This example is a variety of the &lt;a href="http://en.wikipedia.org/wiki/Specification_pattern"&gt;specification pattern&lt;/a&gt;, and it is very helpful for object creation.
Imagine that you have a number of different coffee drinks such as espresso, latte and capuchino which all extend a common base class. There are different ways to prepare each of these drinks and hence you need to know what to put into them when you make them. Using traditional object oriented programming, you would first have to figure out which drinks are available by looking up the classes extending the Drink base class, and then you would need to identify the specific options for each drink by looking at its constructor overloads.
When using an internal DSL to create Drink instance, we can use the language to show the developer which options are available and since almost every IDE has some form of IntelliSense, these options will be very visible to the developer.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://andersnoras.com/blogs/anoras/2008-03-13_fluentinterface.png" alt="Fluentinterface" title=""&gt;&lt;/p&gt;

&lt;p&gt;The value of using this approach is that it is much more readable than regular code and it gives the users (who are developers) an expressive API. Another thing Dave complains about is the use of noise words, like articles, in such DSLs. In this one I&amp;#8217;m using the indefinite article &amp;#8220;a&amp;#8221;. The only reason this is there is that it serves as a starting point for out sentence, and I agree with Dave that there is no real reason to allow users to insert words like &amp;#8220;a&amp;#8221; or &amp;#8220;the&amp;#8221; in the middle of a &amp;#8220;sentence&amp;#8221; to make it feel more like proper English. Still I&amp;#8217;m obsessed with aesthetics and if an definite article was the only thing missing before an API look perfect, I&amp;#8217;d probably add it just to make it look better. &lt;/p&gt;

&lt;p&gt;Allowing noise words in the language brings us to the extreme variety the DSL implementations I show during the talk - the plain English business rule. When use use user stories for our requirements and behavior driven development for testing, why can&amp;#8217;t we just state our business rules like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;When the policy holder's age is less than 25, increase the policy's premium by 5%.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This is code and it is compiled using Microsoft&amp;#8217;s Dynamic Language Runtime and runs on the CLR. On thing to note is that this language is very specific, and has a limited set of operations. There is no way you can write &amp;#8220;Hello World&amp;#8221; with this language. Mandating a strict, limited grammar is a way to work around the ambiguities of natural language. Of course we can&amp;#8217;t be too strict, so we&amp;#8217;ll also have to allow things like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;When the policy's exposure has a burglar alarm, decrease the policy's selfrisk by 200.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If we translate this to plain old C#, we&amp;#8217;ll end up with this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;// First example...
if (policy.holder.age &amp;lt; 25)
{
    policy.premium *= 1.05;
}

// Second...
if (policy.exposure.has("a burglar alarm"))
{
    policy.selfrisk -= 200;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#8220;When&amp;#8221; is a keyword, &amp;#8220;the policy holder&amp;#8217;s age&amp;#8221; is a reference, &amp;#8220;is less than&amp;#8221; is an operator, &amp;#8220;25&amp;#8221; is a constant and so forth. All that is required is to parse it, emit and AST for the DLR and run it. Nothing is different from how general purpose languages work, which isn&amp;#8217;t strange because even if these are true English sentences, writing them is programming.&lt;/p&gt;

&lt;p&gt;The great thing about having things that are as readable as these code snippets is that it makes it easier to sit down with domain experts and use actual, running code as the basis for discussion. That said, I&amp;#8217;m fully agree that the use of English doesn&amp;#8217;t make things a DSL. Focusing on the domain model and developing a language that only takes into account the problems within that domain however does. If it makes sense to model your language around English language constructs, do it! This will make it easier for both developers and business people to understand business related code.
It takes a lot of effort to roll your own language as shown above, so from an economical perspective, you are better of piggybacking on another language. The Boo based variety of the same example looks like this.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;when policy.holder.age &amp;lt; 25:
    increasePremiumByPercentage 5
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It might be broken English, but it serves its purpose and it is most definitely a DSL.&lt;/p&gt;&lt;img src="http://andersnoras.com/aggbug.aspx?PostID=496" width="1" height="1"&gt;</description></item><item><title>Videos from Heroes happen {here}</title><link>http://andersnoras.com/blogs/anoras/archive/2008/03/12/videos-from-heroes-happen-here.aspx</link><pubDate>Wed, 12 Mar 2008 19:57:00 GMT</pubDate><guid isPermaLink="false">719912c1-f1f1-4ca9-83e8-cfd07bb165d8:491</guid><dc:creator>andersnoras</dc:creator><slash:comments>4</slash:comments><description>&lt;p&gt;Last week &lt;a href="http://andersnoras.com/blogs/anoras/archive/2008/03/09/hero-happend-there.aspx"&gt;I was awarded the MSDN Guru&lt;/a&gt; award at the&lt;a href="http://www.microsoft.com/norge/campaigns/heroeshappenhere/"&gt; Heroes happen {here}&lt;/a&gt; event in Oslo. The &lt;a href="http://andersnoras.com/controlpanel/blogs/null"&gt;videos&lt;/a&gt; from the show have been posted and you can watch me accepting the award, giving the obligatory thank you speech and getting interview below. If you can’t understand what’s being said, it’s because its in Norwegian…&lt;/p&gt;&lt;p&gt;&lt;embed width="432" height="364" type="application/x-shockwave-flash" src="http://www.videout.no/videoplayer.swf?ooid=0f0cff3bf22b67410cfb505476fc4b85"&gt; &lt;/p&gt;&lt;p&gt;Expect for the interview, which is a little embarrassing to watch, it turned out quite alright IMHO.&lt;/p&gt;&lt;img src="http://andersnoras.com/aggbug.aspx?PostID=491" width="1" height="1"&gt;</description><category domain="http://andersnoras.com/blogs/anoras/archive/tags/.NET/default.aspx">.NET</category></item><item><title>Notebook Fetish</title><link>http://andersnoras.com/blogs/anoras/archive/2008/03/10/notebook-fetish.aspx</link><pubDate>Mon, 10 Mar 2008 22:22:00 GMT</pubDate><guid isPermaLink="false">719912c1-f1f1-4ca9-83e8-cfd07bb165d8:483</guid><dc:creator>andersnoras</dc:creator><slash:comments>6</slash:comments><description>&lt;p&gt;After giving &lt;a href="http://andersnoras.com/blogs/anoras/archive/2008/02/22/next-week-s-speaking-schedule.aspx"&gt;my talk on language oriented development with .NET&lt;/a&gt; for the Oslo chapter of the &lt;a href="http://www.nnug.no"&gt;Norwegian .NET User Group&lt;/a&gt; I was approached by one of the attendants who pointed out that I had excellent taste in notebooks. Most people though he was referring to my shiny MacBook Pro, but he had this slide in mind…&lt;/p&gt;&lt;p&gt;&lt;img alt="Moleskine" title="" src="http://andersnoras.com/blogs/anoras/2008-03-10_moleskine.png"&gt;&lt;/p&gt;&lt;p&gt;The notebook is an &lt;a href="http://www.moleskine.com/index_eng.php"&gt;Moleskine&lt;/a&gt; notebook, the kind used by great artists like Ernest Hemmingway, Pablo Picasso and computer programmer Anders Norås. I always carry one of these in my pocket and I constantly jot down various thoughts, ideas and similar. Some pearls from the last few days;&lt;/p&gt;&lt;blockquote&gt;  &lt;p&gt;I ride the bus to work every day, but I’m not reusing the bus - I’m &lt;i&gt;using&lt;/i&gt; it!  However, whenever I tip the bus over and set fire to it to build a barricade to keep the IBM sales force at bay, I’m reusing the bus.  -&lt;a href="http://www.brodwall.com/johannes/blog/"&gt;Johannes Brodwall&lt;/a&gt; during a discussion we had on the myths of “reuse”.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;I’ve also got a magic quadrant with the axes Good &amp;lt;-&amp;gt; Evil &amp;amp; Pretty &amp;lt;-&amp;gt; Ugly which I drew while discussing folklore with a friend who works in marketing on the way to work. This one will find its way into one of my talks, because it fits so nicely with the whole behavior driven development story. Wait and see…&lt;/p&gt;&lt;p&gt;The thing is that an old fashioned, analogue notebook is one of the best tools you can carry around. I’ve chosen this make because the quality is unprecedented. There are lots of people with strong feelings for Moleskines. There are &lt;a href="http://wiki.43folders.com/index.php/Moleskine_Hacks"&gt;numerous&lt;/a&gt; &lt;a href="http://www.bbc.co.uk/dna/h2g2/alabaster/A1113346"&gt;hacks&lt;/a&gt; &lt;a href="http://www.43folders.com/2004/11/18/more-moleskine-hacks"&gt;for&lt;/a&gt; &lt;a href="http://loosewire.typepad.com/blog/2005/01/the_moleskine_m.html"&gt;them&lt;/a&gt; &lt;a href="http://www.jerrybrito.com/2004/11/22/moleskine-gtd-tabs-hack/"&gt;on&lt;/a&gt; &lt;a href="http://pigpog.com/node/1303"&gt;the&lt;/a&gt; &lt;a href="http://www.organizeit.co.uk/2007/05/14/collection-of-moleskine-hacks/"&gt;web&lt;/a&gt;, the books have their &lt;a href="http://detour.moleskinecity.com/index.php/2008/01/15/the-first-annual-moleskinerie-exhibit/"&gt;own annual exhibition&lt;/a&gt; and there are even &lt;a href="http://www.moleskinerie.com/"&gt;blogs dedicated to them&lt;/a&gt;.The thing is that there is nothing that can compare with the expressive power of a good notebook. Look at these beautiful notes about agile methodologies by ThoughtWorker &lt;a href="http://josh.ev9.org/weblog/"&gt;Josh Evnin&lt;/a&gt;:&lt;/p&gt;&lt;p&gt;&lt;img alt="2273254160 e 82996a 385" title="" src="http://andersnoras.com/blogs/anoras/2008-03-10_2273254160_e_82996a_385.jpg"&gt;&lt;/p&gt;&lt;p&gt;&lt;img alt="2272460781 8c 5b 436487" title="" src="http://andersnoras.com/blogs/anoras/2008-03-10_2272460781_8c_5b_436487.jpg"&gt;&lt;/p&gt;&lt;p&gt;For more &lt;a href="http://josh.ev9.org/weblog/archives/565"&gt;visit his blog.&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Tag you’re it! How do you make notes?&lt;/p&gt;&lt;p&gt;&lt;a href="http://kjellsj.blogspot.com/"&gt;Kjell-Sverre Jerijærvi&lt;/a&gt;&lt;a href="http://stephan.reposita.org/"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://stephan.reposita.org/"&gt;Jermemy Miller&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.brodwall.com/johannes/blog/"&gt;Johannes Brodwall&lt;/a&gt; &lt;/p&gt;&lt;p&gt;&lt;a href="http://stephan.reposita.org/"&gt;Stephan Scmidt&lt;/a&gt;&lt;/p&gt;&lt;img src="http://andersnoras.com/aggbug.aspx?PostID=483" width="1" height="1"&gt;</description><category domain="http://andersnoras.com/blogs/anoras/archive/tags/Musings/default.aspx">Musings</category></item><item><title>Babysteps in Scala</title><link>http://andersnoras.com/blogs/anoras/archive/2008/03/10/babysteps-in-scala.aspx</link><pubDate>Mon, 10 Mar 2008 21:11:09 GMT</pubDate><guid isPermaLink="false">719912c1-f1f1-4ca9-83e8-cfd07bb165d8:480</guid><dc:creator>andersnoras</dc:creator><slash:comments>4</slash:comments><description>&lt;p&gt;There are always some Java developers who attend whenever I give my .NET DSL talk. This is super cool, and at it makes for some new challenges. The most common one is &amp;#8220;How can we do these things with Java&amp;#8221;. Since the JavaZone guys have introduced an emerging languages track and extended their call for papers deadline to next month, I figured &amp;#8220;porting&amp;#8221; the talk to the Java platform would be cool. The downside* is that, until somebody writes &amp;#8220;Boo4J&amp;#8221;, I have to learn some more &amp;#8220;Java&amp;#8221; languages to explore the possibilities. I&amp;#8217;ve spent a couple of evenings with Scala, and I&amp;#8217;m really pleased with what I&amp;#8217;ve got so far&amp;#8230;&lt;/p&gt;

&lt;p&gt;&lt;img src="http://andersnoras.com/blogs/anoras/2008-03-10_scala_dsl.png" alt="Scala dsl" title=""&gt;&lt;/p&gt;

&lt;p&gt;Being used to mainly using imperative languages, I had to learn a couple of new tricks to get this thing running. The first was how one can pass a first-class function as a by-name parameter. This is used for the predicates. The other was how to use currying to make the &lt;em&gt;when&lt;/em&gt; function look like a keyword. The cool thing was that this was super duper simple. All in all, less than 20 (!) lines of code was required. Looks like I&amp;#8217;m catching the Scala bug too&amp;#8230;&lt;/p&gt;

&lt;p&gt;*Well, learning new languages isn&amp;#8217;t really a downside&amp;#8230; &lt;/p&gt;&lt;img src="http://andersnoras.com/aggbug.aspx?PostID=480" width="1" height="1"&gt;</description><category domain="http://andersnoras.com/blogs/anoras/archive/tags/Java/default.aspx">Java</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/DSL/default.aspx">DSL</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/Scala/default.aspx">Scala</category></item><item><title>Hero happend {there}</title><link>http://andersnoras.com/blogs/anoras/archive/2008/03/09/hero-happend-there.aspx</link><pubDate>Sun, 09 Mar 2008 22:26:49 GMT</pubDate><guid isPermaLink="false">719912c1-f1f1-4ca9-83e8-cfd07bb165d8:479</guid><dc:creator>andersnoras</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;&lt;img src="http://andersnoras.com/blogs/anoras/2008-03-09_herobeer.jpg" height="150" alt="HeroBeer" align="left" title=""&gt; On Thursday I was award the &amp;#8220;MSDN Guru&amp;#8221; award during the Norwegian Heroes Happen {here} launch event. This was fun, and I just want to thank the people who nominated me for the award. I feel very humble to be the winner among the other nominees, they where all great candidates.
By the way, the picture shows a bottle of the specially brewed Heros happen {here} beer. Just too bad Microsoft run out of it early. Still it was a good party! Thanks!&lt;/p&gt;&lt;img src="http://andersnoras.com/aggbug.aspx?PostID=479" width="1" height="1"&gt;</description><category domain="http://andersnoras.com/blogs/anoras/archive/tags/.NET/default.aspx">.NET</category></item><item><title>Thank you Google!</title><link>http://andersnoras.com/blogs/anoras/archive/2008/02/28/thank-you-google.aspx</link><pubDate>Fri, 29 Feb 2008 07:39:03 GMT</pubDate><guid isPermaLink="false">719912c1-f1f1-4ca9-83e8-cfd07bb165d8:473</guid><dc:creator>andersnoras</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;I got these blog recommendations in Google Reader this morning&amp;#8230;
&lt;img src="http://andersnoras.com/blogs/anoras/2008-02-29_greader_suggestions.png" alt="GReader Suggestions" title=""&gt;&lt;/p&gt;

&lt;p&gt;&amp;#8230;if you recommend this blog to someone who isn&amp;#8217;t writing it, that would be even better!&lt;/p&gt;&lt;img src="http://andersnoras.com/aggbug.aspx?PostID=473" width="1" height="1"&gt;</description></item><item><title>Next Week's Speaking Schedule</title><link>http://andersnoras.com/blogs/anoras/archive/2008/02/22/next-week-s-speaking-schedule.aspx</link><pubDate>Fri, 22 Feb 2008 21:24:59 GMT</pubDate><guid isPermaLink="false">719912c1-f1f1-4ca9-83e8-cfd07bb165d8:468</guid><dc:creator>andersnoras</dc:creator><slash:comments>3</slash:comments><description>&lt;p&gt;&lt;a href="http://www.iridescence.no/"&gt;Fredrik Kalseth&lt;/a&gt; posted &lt;a href="http://www.iridescence.no/Posts/NNUG-Vestfold-Meeting-Next-Thursday-Unit-Testing.aspx"&gt;a notice about his talk&lt;/a&gt; for the &lt;a href="http://www.nnug.no"&gt;Norwegian .NET User Group&amp;#8217;s (NNUG)&lt;/a&gt; Vestfold&amp;#8217;s chapter, so I thought I&amp;#8217;d follow in his footsteps to inform the world about my speaking engagements next week.
On Tuesday February 26th I&amp;#8217;m giving a talk on language oriented programming with .NET for the Oslo chapter of NNUG. Topics to watch out for include fluent interfaces, internal and external DSLs, scripting and Microsoft&amp;#8217;s Dynamic Language Runtime. If you show up, be prepared for examples in a variety of languages. Admission is free and we&amp;#8217;re serving pizza, beer and non-alcoholic beverages. For more information visit: &lt;a href="http://www.nnug.no/Avdelinger/Oslo/Moter/Brukergruppemote-februar-2008/"&gt;http://www.nnug.no/Avdelinger/Oslo/Moter/Brukergruppemote-februar-2008/&lt;/a&gt; (in Norwegian).
The user group meeting starts at 18:00 and will be held at &lt;a href="http://www.nith.no"&gt;The Norwegian School of Information Technology (NITH)&lt;/a&gt;, Schweigaardsgate 14 (At the Oslo central bus station).&lt;/p&gt;

&lt;p&gt;On Wednesday 27th I&amp;#8217;ll give the same talk in Bergen, but this time around it won&amp;#8217;t have the strict .NET focus as I&amp;#8217;m speaking for NNUG Bergen and the &lt;a href="http://www.java.no"&gt;Norwegian Java User Group&lt;/a&gt;&amp;#8217;s Bergen chapter. I&amp;#8217;ll also give a talk on building internal DSLs with Java, with particular attention on who we&amp;#8217;ve built &lt;a href="http://quaere.codehaus.org"&gt;Quaere&lt;/a&gt;. This one is free as well, and pizza and beverages will be served. I&amp;#8217;ll be having some spare time before catching the night train home, so we&amp;#8217;re planning a trip to a local pub for some geek talk afterwards. The meeting will be held at &lt;a href="http://www.bi.no"&gt;The Norwegian School of Management (BI)&lt;/a&gt; in Lars Hilles gt. 15. &lt;/p&gt;

&lt;p&gt;Hope to see you either in Oslo or Bergen!&lt;/p&gt;&lt;img src="http://andersnoras.com/aggbug.aspx?PostID=468" width="1" height="1"&gt;</description><category domain="http://andersnoras.com/blogs/anoras/archive/tags/Java/default.aspx">Java</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/.NET/default.aspx">.NET</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/DSL/default.aspx">DSL</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/Talks/default.aspx">Talks</category></item><item><title>Save Java, Dead or Alive!</title><link>http://andersnoras.com/blogs/anoras/archive/2008/02/18/save-java-dead-or-alive.aspx</link><pubDate>Mon, 18 Feb 2008 20:11:59 GMT</pubDate><guid isPermaLink="false">719912c1-f1f1-4ca9-83e8-cfd07bb165d8:458</guid><dc:creator>andersnoras</dc:creator><slash:comments>2</slash:comments><description>&lt;blockquote&gt;
  &lt;p&gt;Whatever language you write in, your task as a programmer is to do the best you can with the tools at hand. A good programmer can overcome a poor language or a clumsy operating system, but even a great programming environment will not rescue a bad programmer. &lt;/p&gt;
  
  &lt;p&gt;&lt;em&gt;Kernighan and Pike&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When I attended &lt;a href="http://www.jroller.com/rickard/"&gt;Richard Öberg&amp;#8217;s&lt;/a&gt; &lt;a href="http://www.jroller.com/rickard/entry/javabin_oslo_rules"&gt;talk on Qi4J&lt;/a&gt; at the Oslo JUG last week, I started thinking about &amp;#8220;Rädda Joppe&amp;#8221;, a Swedish children&amp;#8217;s show that aired in the eighties. The plot was simple, the young Ola manages to lose his favorite teddy bear, Joppe, and has to learn one or two things about the world he lives in to get him back. Whenever Ola loses his precious bear, saving it is the only thing on his mind and he regularly screams &amp;#8220;rädda Joppe, död eller levanda&amp;#8221; which translates to &amp;#8220;save Joppe, dead or alive&amp;#8221;.&lt;br&gt;
&lt;object width="425" height="355"&gt;&lt;param name="movie" value="http://www.youtube.com/v/wxg3oIxHp1I&amp;rel=1"&gt;&lt;/param&gt;&lt;param name="wmode" value="transparent"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/wxg3oIxHp1I&amp;rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br&gt;
The ideas behind &lt;a href="http://www.qi4j.org/"&gt;Qi4J&lt;/a&gt; are quite mind boggling, and I strongly believe that composite oriented programming has a bright future amongst domain driven design practitioners. However, I feel that we&amp;#8217;re jumping through too many hoops to achieve paradigm shifts with Java. Richard employs a truckload of black belt dynamic proxy and AOP tricks to achieve a sense of dynamically composable objects in Qi4J, &lt;a href="http://www.jmock.org/"&gt;JMock&lt;/a&gt; achieves elegance through a programming model that is quite different from your textbook Java and my own &lt;a href="http://quaere.codehaus.org"&gt;Quaere&lt;/a&gt; project &amp;#8220;misuses&amp;#8221; static imports and other language features to achieve its goals. Its fun to push a programming language to its limits, but at the same time we could probably achieve the same more elegantly with other languages running atop the JVM - so I got thinking are we trying to save our favorite programming language the same way Ola tries to save Joppe - without any regard to the world outside?&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ve always been the kind of guy who explores different programming languages, and during the last couple of years I&amp;#8217;ve found my self using different languages from my default choice (which is C# if anyone should wonder) more often. Even if &lt;a href="http://www.acmqueue.com/modules.php?name=Content&amp;amp;pa=showpage&amp;amp;pid=271"&gt;you can write FORTRAN in any language&lt;/a&gt;, I find that I get the most out of these programming languages when I take the time to learn the ways of the language. Often I find myself using tricks I&amp;#8217;ve learned from Ruby in C#, I was unaware that Visual Basic .NET had static imports until I had learned how to exploit it Java and similar. This is my way to avoid stumbling into &amp;#8220;the trap of the &lt;a href="http://en.wikipedia.org/wiki/Sapir–Whorf_hypothesis"&gt;Sapir-Whorf thesis&lt;/a&gt;&amp;#8221;. &lt;a href="http://en.wikipedia.org/wiki/Sapir-Whorf_and_programming_languages"&gt;Applied to programming&lt;/a&gt;, the Sapir-Whorf thesis postulates that programmers who are skilled in a particular language or paradigm may not have the same skills with another language or paradigm. One trick ponies still only do one trick.&lt;/p&gt;

&lt;p&gt;While pushing a language to its limits paves way for refreshing ideas like composite oriented programming, other attempts to &amp;#8220;save Java&amp;#8221; fall short in my humble opinion. &lt;a href="http://bill.burkecentral.com/"&gt;&amp;#8220;Angry&amp;#8221; Bill Burke&amp;#8217;s&lt;/a&gt; &lt;a href="http://bill.burkecentral.com/2008/02/04/dynamic-languages-rationalizations-and-myths/"&gt;rant on dynamic languages was a sad read&lt;/a&gt;. Most of the arguments aren&amp;#8217;t generally applicable, because there is no such thing as &amp;#8220;the dynamic language&amp;#8221;. Even for those who believe that Ruby might be a good candidate there are lots of different varieties. Speaking of Ruby, it was &lt;a href="http://beust.com/weblog/"&gt;Cedric Beust&lt;/a&gt;&amp;#8217;s &lt;a href="http://www.theserverside.com/news/thread.tss?thread_id=48180#245709"&gt;little Ruby refactoring challenge&lt;/a&gt;, which Bill refers to in his rant, that led me to write this post. Cedric is a clever guy, but I wonder if he&amp;#8217;s fallen into the Sapir-Whorf trap with this one. Cedric&amp;#8217;s question was what to do with f1(o) and f2(o) while renaming C.init! in this Ruby snippet:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def f1(o)
  o.init!
end

def f2(o)
  o.init!
end

class C
  def init!
    puts "Init C"
  end
end

class D
  def init!
    puts "Init D"
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Cedric is right that there is no way for an automated refactoring tool to determine whether these still should be o.init! or o.init2!, but this isn&amp;#8217;t a problem caused by Ruby - it is caused by applying the exact same solution to Ruby as one would do with Java - the core of the Sapir-Whorf thesis. Ruby code can be ambiguous, but this is one of the things that makes the language so powerful. Still we need to take this into account when refactoring Ruby code. A simple solution for Cedric&amp;#8217;s problem could be to extract a method for the o.init! call, and let this method make the decision on whether init! or init2! should be invoked.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def f1(o)
  invoke_init(o)
end

def f2(o)
  invoke_init(o)
end

def invoke_init(o)
  if o.is_a? C
    o.init2!
  else
    o.init!
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This refactoring could actually be done confidently by an IDE and it is only one of many possible solutions to Cedric&amp;#8217;s problem.&lt;/p&gt;

&lt;p&gt;Java is a great language, and it runs on an even better JVM. In my opinion, this JVM and the broad selection of top notch frameworks is the Java community&amp;#8217;s most valuable assets. But the Java language is falling short of some of it&amp;#8217;s peers - just compare the development from C# 1.0 to C# 3.0 to Java 1.4 to Java 1.6. Repairing generics, adding closures and so forth will improve Java, but it isn&amp;#8217;t the answer to everything. For instance, it won&amp;#8217;t make Java a better option for language oriented programming like Bill claims. C# has got almost everything Bill wants to see added to make Java the ultimate language and C# still is too rigid to be a good foundation to build a DSL atop. Ruby or Python are better choices, not to mention Python&amp;#8217;s cousin, &lt;a href="http://boo.codehaus.org"&gt;Boo&lt;/a&gt;,  which is statically typed and still behaves like a dynamic language. But do remember; &lt;em&gt;When in Rome, do as the romans.&lt;/em&gt; These languages aren&amp;#8217;t exactly like Java - the have their own cultures, conventions and style.&lt;/p&gt;

&lt;p&gt;When Java saw the light of day, talented developers flocked around because it was refreshing and new. The same thing happened with C#, greatly improving the overall quality of applications developed on Microsoft&amp;#8217;s platform. Today you&amp;#8217;ll find tons of mediocre code written in both Java and C#. The same thing is happening with Ruby, Python and any other dynamic plate de jour. In the end, talented programmers will have come up with new, refreshing ways to design software and I believe that lessons learned through by getting new impulses from other languages and &amp;#8220;programming cultures&amp;#8221; is a great way to do so.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Le ${favoriteProgrammingLanguage} est mort. Vive le ${favoriteProgrammingLanguage}!&lt;/p&gt;
&lt;/blockquote&gt;&lt;img src="http://andersnoras.com/aggbug.aspx?PostID=458" width="1" height="1"&gt;</description><category domain="http://andersnoras.com/blogs/anoras/archive/tags/Musings/default.aspx">Musings</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/Java/default.aspx">Java</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/.NET/default.aspx">.NET</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/Boo/default.aspx">Boo</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/Ruby/default.aspx">Ruby</category></item><item><title>A Jerk in the Land of a Hundred Languages</title><link>http://andersnoras.com/blogs/anoras/archive/2008/02/03/a-jerk-in-the-land-of-a-hundred-languages.aspx</link><pubDate>Mon, 04 Feb 2008 00:00:25 GMT</pubDate><guid isPermaLink="false">719912c1-f1f1-4ca9-83e8-cfd07bb165d8:448</guid><dc:creator>andersnoras</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;&lt;img src="http://andersnoras.com/blogs/anoras/2008-02-03_babylon.jpg" align="left" alt="Babylon" title=""&gt; There is &lt;a href="http://www.economist.com/science/displaystory.cfm?story_id=10601444"&gt;an article&lt;/a&gt; in this week&amp;#8217;s &lt;a href="http://www.economist.com/"&gt;Economist&lt;/a&gt; referring to &lt;a href="http://www.sciencemag.org/cgi/content/abstract/319/5863/588"&gt;a paper&lt;/a&gt; by Dr. Mark Pagel &lt;em&gt;et al&lt;/em&gt; published in the latest edition of &lt;a&gt;Science&lt;/a&gt; on (spoken) languages evolving in punctuational bursts. The key point in Dr. Pagel&amp;#8217;s research is that evolutionary change happens in sudden jumps separated by long periods of creeping evolution. The article uses the huge differences in the written language of the English writers &lt;a href="http://en.wikipedia.org/wiki/Geoffrey_Chaucer"&gt;Geoffery Chaucer&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/William_Shakespeare"&gt;William Shakespeare&lt;/a&gt; who lived two centuries apart. You&amp;#8217;ve probably read, and understood, Mr. Shakespeare&amp;#8217;s writing, but how about Mr. Chaucer?&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;This frere bosteth that he knoweth helle,
  And God it woot, that it is litel wonder;
  Freres and feendes been but lyte asonder.
  For, pardee, ye han ofte tyme herd telle
  How that a frere ravyshed was to helle
  In spirit ones by a visioun&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The article got me thinking about DSLs and our &lt;a href="http://codebetter.com/blogs/david_laribee/archive/2007/11/07/our-100-language-future.aspx"&gt;hundred language future&lt;/a&gt;. Grady Booch once said that &lt;em&gt;&amp;#8220;They [programming languages] tell us about the state of software practice, the minds of their inventors and the technical, social, and economic forces that shaped history at the time. They&amp;#8217;ll provide the raw material for software archaeologists, historians, and developers to learn what worked, what was brilliant, and what was utter failure.&amp;#8221;&lt;/em&gt;
Through-out my entire career as a software professional C/C++, Java, Visual Basic and C# have been dominant within the industry. Some undercurrents, such as Python, have always been there, and recently these undercurrents have become many and grown stronger. One of the driving forces behind this is the growing interest in domain specific languages, not only custom languages built by developers to tackle narrow business problems, but also more general purpose languages that are suited to address different programming problems. Today&amp;#8217;s, and not to mention tomorrow&amp;#8217;s, programming profession some what seems to resemble the scene in the 1980s. At this time I was programming BASIC, Pascal and assembly language. Other people I knew where into C or ADA, while most professional programmers did COBOL or Fortran.
Anyone working with legacy applications know that it can be rather cumbersome to integrate and evolve applications written in this plethora of languages, so why do I welcome a future of &amp;#8220;a hundred languages&amp;#8221;? First, todays flurry of languages build on a different fundament than in the eighties. At that time different languages where different platforms, while today most of the languages are available in some form for both Microsoft&amp;#8217;s CLR and the Java VM so we won&amp;#8217;t be experiencing the same challenges with getting something written in Python to play nice with something written in C#. In fact, I believe that this is a key reason for more and more developers becoming polyglots, having a common platform allows you to use your knowledge of that platform and its frameworks and at the same time choosing the language that is best suited for the task at hand.&lt;/p&gt;

&lt;p&gt;So what about the sudden jerks in language evolution? If you look at the two dominant programming languages for the last decade, they are really just different dialects of the C language which has had a strong presence since the mid 70&amp;#8217;s. Using Dr. Pagel&amp;#8217;s terms, this has been a creeping evolution. If we look at the new kids on the block; languages such as Boo, Groovy or Scala we see languages that absorb the abilities of quite different languages. Both Boo and Groovy have similarities to Python, but at the same time they also have elements of C# or Java in them. Scala builds on Java, but at the same time it brings a little Objective Caml into the mix. Even if it&amp;#8217;s not a particularly &amp;#8220;new&amp;#8221; language, Ruby needs to be mentioned as well. This language has similarities to Python, Perl, Smalltalk and quite a few other languages.
These languages abilities to absorb the good from other, well established languages is what makes them interesting choices when the CLR or VM allows us to do so. A common theme for all of these &amp;#8220;new&amp;#8221; languages is that they are more flexible than their predecessors and this appeals to many programmers. The features that make them so flexible feed back into their ancestors and is fueling change in these as well. Just look at the huge leap C# made in its latest incarnation and the number of proposals for new features in the next version of Java. I think this can very well be a jerk in language evolution.&lt;/p&gt;

&lt;p&gt;Will future programs be as hard to read using todays skills as the excerpt from Chaucer&amp;#8217;s &lt;a href="http://en.wikipedia.org/wiki/The_Summoner%27s_Prologue_and_Tale"&gt;Summoner&amp;#8217;s Tale&lt;/a&gt;? I think it depends on what you&amp;#8217;ve experienced before. As &lt;a href="http://steve.yegge.googlepages.com/"&gt;Steve Yegge&lt;/a&gt; put it, &lt;a href="http://steve.yegge.googlepages.com/five-essential-phone-screen-questions"&gt;one-trick ponies only know one trick&lt;/a&gt;. If you&amp;#8217;ve only written Java or C# code, you would be searching desperately for &lt;em&gt;if&lt;/em&gt;, &lt;em&gt;switch&lt;/em&gt;, &lt;em&gt;for&lt;/em&gt; and &lt;em&gt;while&lt;/em&gt; statements in Erlang.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;% This could be a for(int i = 1; i &amp;lt;= 10; i++)
% in Erlang...
f(m,m,F) -&amp;gt; [F(m)]
f(I,m,F) -&amp;gt; [F(I)|f(I+1,m,F)]
f(1,10,F)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;On the other hand, you could find developers choosing to use Simula to write a fitting room simulator it might be easier to grasp than the same thing in C#.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Simulation Begin
   Class FittingRoom; Begin
      Ref (Head) door;
      Boolean inUse;
      Procedure request; Begin
         If inUse Then Begin
             Wait (door);
             door.First.Out;
         End;
         inUse:= True;
      End;
      Procedure leave; Begin
         inUse:= False;
         Activate door.First;
      End;
      door:- New Head;
   End;

   Procedure report (message); Text message; Begin
      OutFix (Time, 2, 0); OutText (": " &amp;amp; message); OutImage;
   End;

   Process Class Person (pname); Text pname; Begin
      While True Do Begin
         Hold (Normal (12, 4, u));
         report  (pname &amp;amp; " is requesting the fitting room");
         fittingroom1.request;
         report (pname &amp;amp; " has entered the fitting room");
         Hold (Normal (3, 1, u));
         fittingroom1.leave;
         report (pname &amp;amp; " has left the fitting room");
      End;
   End;

   Integer u;
   Ref (FittingRoom) fittingRoom1;

   fittingRoom1:- New FittingRoom;
   Activate New Person ("Sam");
   Activate New Person ("Sally");
   Activate New Person ("Andy");
   Hold (100);
End;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Even if this is just plain old Simula, it resembles many of the examples you find of domain specific languages - but then again, Kristen Nygaard wrote Simula to make it easier to simulate the operations of systems, so in a sense it was a DSL.
DSLs written by developers to tackle narrow business problems are likely to be built on top of general purpose languages such as Ruby or Boo who lend themselves easily to this, or using a common language workbench infrastructure such as Microsoft&amp;#8217;s Dynamic Language Runtime. If you&amp;#8217;re proficient with these, you&amp;#8217;ll probably be able to maintain our futures polyglot applications - it won&amp;#8217;t be much different from maintaining an application that uses a variety of frameworks written in a single language. The most noticeable difference might be that you won&amp;#8217;t feel like your forcing the square peg trough the star shaped hole as often as you do today, at least if you&amp;#8217;ve chosen the right language for the job.&lt;/p&gt;

&lt;p&gt;Now Playing: &lt;em&gt;Chris Kenner - Land of a Thousand Dances&lt;/em&gt; &lt;/p&gt;&lt;img src="http://andersnoras.com/aggbug.aspx?PostID=448" width="1" height="1"&gt;</description><category domain="http://andersnoras.com/blogs/anoras/archive/tags/Java/default.aspx">Java</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/.NET/default.aspx">.NET</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/DSL/default.aspx">DSL</category></item><item><title>Happy Birthday, Blog</title><link>http://andersnoras.com/blogs/anoras/archive/2008/01/30/happy-birthday-blog.aspx</link><pubDate>Wed, 30 Jan 2008 20:51:00 GMT</pubDate><guid isPermaLink="false">719912c1-f1f1-4ca9-83e8-cfd07bb165d8:428</guid><dc:creator>andersnoras</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;Today it is exactly one year since I pick up on blogging after a long break. To celebrate, I’ll go grab a brew and share some of my highs and lows from my year as a resurrected blogger.First of all, I’d like to give a big thank to &lt;i&gt;you&lt;/i&gt;. Without you reading, it wouldn’t make much sense to maintain this blog - except for the (rather frequent) occasions I Google for something I vaguely recall having written.&lt;/p&gt;&lt;h3 id="the_year_in_numbers"&gt;The year in numbers&lt;/h3&gt;&lt;p&gt;&lt;a href="http://www.economist.com/printedition/"&gt;The Economist&lt;/a&gt;, which is my favorite weekly news magazine, releases a paperback “the world in numbers” book every year. My new blog turning one is a great opportunity for me to share some facts and stats about this blog.If you’re reading this in an RSS reader, you are one of my 691 subscribers - thank you! If you’re not, chances are that you’re one of the 75,778 unique visitors to andersnoras.com during the last 12 months - thank you for stopping by!&lt;/p&gt;&lt;p&gt;The top ten most popular posts were:1. &lt;a href="http://andersnoras.com/blogs/anoras/archive/2007/09/11/introducing-quaere-language-integrated-queryies-for-java.aspx"&gt;Introducing Quaere - Language integrated queryies for Java&lt;/a&gt; - The announcement for my &lt;a href="http://quaere.codehaus.org"&gt;Quaere&lt;/a&gt; project, which has gotten much attention since I unveiled it at &lt;a href="http://www.javazone.no"&gt;JavaZone&lt;/a&gt; in September2. &lt;a href="http://andersnoras.com/blogs/anoras/archive/2007/07/09/behind-the-scenes-of-the-planning-dsl.aspx"&gt;Behind the scenes of the planning DSL&lt;/a&gt; - A deepdive into the code that made the examples in the third most popular post possible.3. &lt;a href="http://andersnoras.com/blogs/anoras/archive/2007/07/04/i-m-coming-down-with-a-serious-case-of-the-dsls.aspx"&gt;I’m coming down with a serious case of the DSLs!&lt;/a&gt; - This post showcased a fluent interface based DSL I wrote.4. &lt;a href="http://andersnoras.com/blogs/anoras/archive/2007/02/24/software-factories-another-unlearned-ejb-lesson.aspx"&gt;Software Factories - Another Unlearned EJB Lesson&lt;/a&gt; - I’m glad to see that this post has made it so far up the ranks, even with a somewhat misleading title. This post is about achieving agility through maintainable code. 5. &lt;a href="http://andersnoras.com/blogs/anoras/archive/2007/03/01/nhibernate-mapping-a-class-to-several-tables.aspx"&gt;NHibernate: Mapping a Class to Several Tables&lt;/a&gt; - The name says it all, still people should read about the &lt;a href="http://andersnoras.com/blogs/anoras/archive/2007/04/24/nhibernate-now-supports-the-joined-table-pattern.aspx"&gt;joined table pattern&lt;/a&gt; instead of reading this one.6. &lt;a href="http://andersnoras.com/blogs/anoras/archive/2007/07/15/is-it-a-bird-is-it-a-plane-it-s-a-dsl.aspx"&gt;Is it a bird? Is it a plane? It’s a DSL!&lt;/a&gt; - This post offers my views on the old fluent interface, internal or external DSL discussion.7. &lt;a href="http://andersnoras.com/blogs/anoras/archive/2007/07/16/look-mom-no-checked-exception.aspx"&gt;Look Mom, No Checked Exception&lt;/a&gt; - This post was intentionally ironic, and it stirred up a lengthy discussion around checked exceptions. AFIK, this is the only time I’ve gotten a negative rating at &lt;a href="http://www.dzone.com"&gt;DZone&lt;/a&gt;.8. &lt;a href="http://andersnoras.com/blogs/anoras/archive/2007/10/18/bare-naked-linq.aspx"&gt;Bare naked LINQ&lt;/a&gt; - This post explains some of the mechanics behind LINQ and how they relate to Quaere.9. &lt;a href="http://andersnoras.com/blogs/anoras/archive/2007/07/24/dsl-tools-a-complex-solution-for-a-simple-problem.aspx"&gt;DSL Tools: A Complex Solution for a Simple Problem&lt;/a&gt; - This one is a rant about the applicability of the examples used in the DSL Tools book. It’s not important, and it doesn’t deserve to be on the top ten list. 10. &lt;a href="http://andersnoras.com/blogs/anoras/archive/2007/05/10/mean-fiddler-rest-style-query-service.aspx"&gt;Mean Fiddler: REST-style query service&lt;/a&gt; - This was a follow up to &lt;a href="http://www.ayende.com/"&gt;Ayende’s&lt;/a&gt; &lt;a href="http://www.ayende.com/Blog/archive/2007/05/04/Bumbler-NHibernate-Dynamic--Interactive-Shell.aspx"&gt;Bumbler stunt&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;The tree least popular posts were:90. &lt;a href="http://andersnoras.com/blogs/anoras/archive/2007/02/27/scheduled-maintenance.aspx"&gt;Scheduled Maintenance&lt;/a&gt;89. &lt;a href="http://andersnoras.com/blogs/anoras/archive/2007/06/11/reignite-the-browser-wars.aspx"&gt;Reignite the browser wars&lt;/a&gt;88. &lt;a href="http://andersnoras.com/blogs/anoras/archive/2007/09/17/podcast-of-my-javazone-talk.aspx"&gt;Podcast of my JavaZone talk&lt;/a&gt;&lt;/p&gt;&lt;h3 id="surprise_be_novel_be_nice"&gt;Surprise, Be Novel, Be Nice&lt;/h3&gt;&lt;p&gt;For the readers of my previous blog, the biggest surprise this year was probably that I suddenly stared writing about Java. There were a number of reasons for doing so. First and foremost, I started a working for a new employer in March and Java is the most widely used development platform there. Another reason was that I saw Quaere as a great opportunity to learn the mechanics of LINQ through experimentation while contributing to the Java community. This has been very awarding, and even if there the project has been a little quiet lately, I intend to keep working on this for the year to come.Readers who care more about .NET should also look forward to the next year as I intend to get busy with some ground breaking .NET-experimentation. (We’ll at least, I will write more about .NET stuff…)&lt;/p&gt;&lt;p&gt;With a few exceptions, the top ten list above is close to what I would have guessed. There is a common theme for the posts on that list, they provide information that is not easily found other places, they bring refreshing views on popular topics and similar. The ones on the bottom are dead right boring. I hope to write more novel blog post in the year to come.&lt;/p&gt;&lt;p&gt;Some of my posts this year have been a little edgy, and even if these bring value, I hope to write with a calmer and less aggressive tone next year.&lt;/p&gt;&lt;p&gt;Last but not least, I need to say thank you again. Hope you’ll stay for another year!&lt;/p&gt;&lt;img src="http://andersnoras.com/aggbug.aspx?PostID=428" width="1" height="1"&gt;</description></item><item><title>Got My Keys Sorted for Windows</title><link>http://andersnoras.com/blogs/anoras/archive/2008/01/25/got-my-keys-sorted-for-windows.aspx</link><pubDate>Fri, 25 Jan 2008 20:55:58 GMT</pubDate><guid isPermaLink="false">719912c1-f1f1-4ca9-83e8-cfd07bb165d8:423</guid><dc:creator>andersnoras</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;&lt;img src="http://andersnoras.com/blogs/anoras/2008-01-25_mac_keys.jpg" align="left" alt="Mac Keys" title=""&gt;&lt;/p&gt;&lt;p&gt;One of the biggest annoyances with using a Mac for Visual Studio development is that the Windows keyboard layout is different from the Mac layout. On a Norwegian Mac keyboard, you&amp;#8217;ll find much used characters such as &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt; by pressing &lt;em&gt;&lt;a href="http://en.wikipedia.org/wiki/Option_key"&gt;option&lt;/a&gt;&lt;/em&gt; + &lt;em&gt;shift&lt;/em&gt; + &lt;em&gt;8&lt;/em&gt; or &lt;em&gt;9&lt;/em&gt; respectively. On Windows you&amp;#8217;ll need to hit &lt;em&gt;altgr&lt;/em&gt; and &lt;em&gt;7&lt;/em&gt; or &lt;em&gt;0&lt;/em&gt;. It is the same story with other characters such as &lt;code&gt;&amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt;, &lt;code&gt;@&lt;/code&gt; or &lt;code&gt;\&lt;/code&gt; to name a few. Since the Mac keyboard hasn&amp;#8217;t got an &lt;em&gt;altgr&lt;/em&gt; key, you&amp;#8217;ll need to press both &lt;em&gt;ctrl&lt;/em&gt; and &lt;em&gt;option&lt;/em&gt; to simulate this key with Windows running on a Mac. This isn&amp;#8217;t a big deal, but it is a little annoying. The constant mental context switches you need to do to relocate your keys is a bigger issue. To mitigate these annoyances, I decided to create a custom keyboard layout for Windows which puts every key in the right place.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://andersnoras.com/blogs/anoras/2008-01-25_keyboard.png" alt="Keyboard" title=""&gt;&lt;/p&gt;

&lt;p&gt;I had to make some compromises while remapping the keys with regards to modifier keys. On Windows you cannot remap keys with the &lt;em&gt;alt&lt;/em&gt; modifier, so I had to swap it for &lt;em&gt;ctrl&lt;/em&gt;. This implies that to get to the curly braces on Windows you&amp;#8217;ll need to press &lt;em&gt;ctrl&lt;/em&gt; + &lt;em&gt;shift&lt;/em&gt; + &lt;em&gt;8&lt;/em&gt; or &lt;em&gt;9&lt;/em&gt; rather than the strokes described above. Another minor issue is that most Windows applications use the &lt;em&gt;ctrl&lt;/em&gt; modifier for keyboard shortcuts, so hitting &lt;em&gt;ctrl&lt;/em&gt; + &lt;em&gt;s&lt;/em&gt; will probably bring up the Save dialog rather than printing &lt;em&gt;ß&lt;/em&gt;. I reckon I can work my way around this by remapping Visual Studio&amp;#8217;s keyboard shortcuts, but until this becomes a real problem I won&amp;#8217;t bother.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://andersnoras.com/blogs/anoras/2008-01-25_keyboard_ctrl.png" alt="Keyboard Ctrl" title=""&gt;&lt;/p&gt;

&lt;p&gt;If you&amp;#8217;re interested in trying my Mac-friendly keyboard layout, you&amp;#8217;ll find the installer here: &lt;a href="http://andersnoras.com/files/folders/422/download.aspx"&gt;Mac Keyboard Layout for Windows (Norsk, Bokmål)&lt;/a&gt;&lt;/p&gt;&lt;img src="http://andersnoras.com/aggbug.aspx?PostID=423" width="1" height="1"&gt;</description><category domain="http://andersnoras.com/blogs/anoras/archive/tags/mac/default.aspx">mac</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/windows/default.aspx">windows</category></item><item><title>My ¢2 on Java Extension Methods</title><link>http://andersnoras.com/blogs/anoras/archive/2007/12/05/my-2-on-java-extension-methods.aspx</link><pubDate>Thu, 06 Dec 2007 10:38:00 GMT</pubDate><guid isPermaLink="false">719912c1-f1f1-4ca9-83e8-cfd07bb165d8:414</guid><dc:creator>andersnoras</dc:creator><slash:comments>3</slash:comments><description>&lt;p&gt;A while a go &lt;a href="http://gafter.blogspot.com/"&gt;Neil Gafter&lt;/a&gt; proposed extension methods as a new feature in Java 7. This is an interesting proposal and if it is implemented, it would make &lt;a href="http://quaere.codehaus.org"&gt;Quaere&lt;/a&gt; even better. I'll skip the tired list sorting example from the &lt;a href="http://www.oreillynet.com/onjava/blog/2007/12/extension_methods_proposals.html"&gt;discussions&lt;/a&gt; and think out loud about how Quaere would benefit from extension methods.&lt;/p&gt; &lt;p&gt;First lets look at some simple features. Today, you can union two sequences using the &lt;i&gt;union &lt;/i&gt;static import:&lt;/p&gt;&lt;pre&gt;    List&amp;lt;Integer&amp;gt; numbersA = Arrays.&lt;i&gt;asList&lt;/i&gt;(0, 2, 4, 5, 6, 8, 9);&lt;br&gt;    List&amp;lt;Integer&amp;gt; numbersB = Arrays.&lt;i&gt;asList&lt;/i&gt;(1, 3, 5, 7, 8);&lt;br&gt;    Iterable&amp;lt;Integer&amp;gt; uniqueNumbers = &lt;i&gt;union&lt;/i&gt;(numbersA, numbersB);&lt;/pre&gt;
&lt;p&gt;If we can introduce the &lt;i&gt;union&lt;/i&gt; method as an extension method on the List interface, the example could be written like this:&lt;/p&gt;&lt;pre&gt;    List&amp;lt;Integer&amp;gt; numbersA = Arrays.&lt;i&gt;asList&lt;/i&gt;(0, 2, 4, 5, 6, 8, 9); &lt;br&gt;    List&amp;lt;Integer&amp;gt; numbersB = Arrays.&lt;i&gt;asList&lt;/i&gt;(1, 3, 5, 7, 8);     &lt;br&gt;    Iterable&amp;lt;Integer&amp;gt; uniqueNumbers = numbersA.union(numbersB);&lt;br&gt;&lt;/pre&gt;
&lt;p&gt;It's not a huge thing, but it makes the queries a little nicer because it now read entirely from left to right. We could also use extensions to make queries a little more compact. Instead of writing:&lt;/p&gt;&lt;pre&gt;    List&amp;lt;Integer&amp;gt; numbers = &lt;br&gt;        Arrays.asList(5, 4, 1, 3, 9, 8, 6, 7, 2, 0); &lt;br&gt;    Iterable&amp;lt;Integer&amp;gt; lowNums =&lt;br&gt;            from("&lt;span&gt;n&lt;/span&gt;").in(numbers).&lt;br&gt;            where(lt("&lt;span&gt;n&lt;/span&gt;", 5)).&lt;br&gt;            select("&lt;span&gt;n&lt;/span&gt;");&lt;/pre&gt;
&lt;p&gt;...we could do something like this...&lt;/p&gt;&lt;pre&gt;    List&amp;lt;Integer&amp;gt; numbers = &lt;br&gt;        Arrays.asList(5, 4, 1, 3, 9, 8, 6, 7, 2, 0);&lt;br&gt;    Iterable&amp;lt;Integer&amp;gt; lowNums =&lt;br&gt;            numbers.where(lt("&lt;span&gt;n&lt;/span&gt;", 5));&lt;/pre&gt;
&lt;p&gt;However, I think we'd have to keep the more verbose query syntax as it is today, because it is &lt;a href="http://andersnoras.com/blogs/anoras/archive/2007/10/18/bare-naked-linq.aspx"&gt;a little cumbersome to write advanced queries without any language support&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The biggest potential lies in how predicates are expressed. Today, we have to write the &lt;i&gt;n &amp;lt; 5&lt;/i&gt; predicate as &lt;i&gt;lt("n",5).&lt;/i&gt; Both Thomas Mueller and Faraz Amhed are working on some interesting alternatives that would enable us to write predicates like this in a more straight forward manner, but none of these have made it into Quaere yet. With extension methods we could improve today's implementation by extending &lt;i&gt;java.lang.String. &lt;/i&gt;If we did, the predicate could look like this &lt;i&gt;n.lt(5). &lt;/i&gt;Extending a common class like String has its issues and .NET developers have experienced this with C# extension methods.&lt;/p&gt;
&lt;p&gt;While we're at C#, I'd like to contribute my own suggestion on how extension methods could be implemented in Java. I really like the C# take on this. Below is an example of how we could extend .NET's IList interface with the &lt;i&gt;union&lt;/i&gt; method from earlier. This is of course for example only as LINQ already does this.&lt;/p&gt;&lt;pre&gt;&lt;span&gt;public&lt;/span&gt; &lt;span&gt;static&lt;/span&gt; IEnumerable&amp;lt;T&amp;gt; union(&lt;span&gt;this&lt;/span&gt; IList&amp;lt;T&amp;gt; sourceA, IList&amp;lt;T&amp;gt; sourceB) {&lt;br&gt;    List&amp;lt;T&amp;gt; result = &lt;span&gt;new&lt;/span&gt; List&amp;lt;T&amp;gt;();&lt;br&gt;    result.add(sourceA);&lt;br&gt;    &lt;span&gt;foreach&lt;/span&gt; (T b &lt;span&gt;in&lt;/span&gt; sourceB) {&lt;br&gt;        &lt;span&gt;if&lt;/span&gt; (!result.Contains(b)) {&lt;br&gt;            result.Add(b); &lt;br&gt;        }&lt;br&gt;    }&lt;br&gt;}&lt;/pre&gt;
&lt;p&gt;Notice the &lt;i&gt;this&lt;/i&gt; keyword on the first argument, this indicates that the C# compiler should treat this method as an extension. Read my &lt;a href="http://andersnoras.com/blogs/anoras/archive/2007/10/18/bare-naked-linq.aspx"&gt;Bare Naked LINQ post&lt;/a&gt; for more on .NET extension methods.&lt;/p&gt;
&lt;p&gt;I'd like to see a similar approach if extensions are added to Java. This preserves a familiar syntax and uses familiar concepts to achieve it. After all, extension methods only need to be compile time magic - there is no need to change the JVM.&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="0767317B-992E-4b12-91E0-4F059A8CECA8:08fd59b9-9f2e-4b17-bc74-18fb04730df8" style="margin:0px;padding:0px;display:inline;"&gt;Technorati tags: &lt;a href="http://technorati.com/tags/Java" rel="tag"&gt;Java&lt;/a&gt;, &lt;a href="http://technorati.com/tags/.NET" rel="tag"&gt;.NET&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Quaere" rel="tag"&gt;Quaere&lt;/a&gt;&lt;/div&gt;&lt;img src="http://andersnoras.com/aggbug.aspx?PostID=414" width="1" height="1"&gt;</description><category domain="http://andersnoras.com/blogs/anoras/archive/tags/Java/default.aspx">Java</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/.NET/default.aspx">.NET</category><category domain="http://andersnoras.com/blogs/anoras/archive/tags/Quaere/default.aspx">Quaere</category></item><item><title>Lexical Closures, Deferred Execution and Kicker Methods</title><link>http://andersnoras.com/blogs/anoras/archive/2007/11/06/lexical-closures-deferred-execution-and-kicker-methods.aspx</link><pubDate>Tue, 06 Nov 2007 22:20:00 GMT</pubDate><gu