Extension Methods in Java, Xtend & Scala

Posted by & filed under Coding.

Extending the functionality of classes is trivial: simply use inheritance and add new methods. There are cases where extending classes by inheritance is not practicable, e.g. given final classes like java.lang.String. Another simple way of extending the functionality of classes is applying methods defined somewhere else. Modern languages like Xtend and Scala provide convenient syntax… Read more »

Inspired by treehugger.js

Posted by & filed under Coding.

A few months ago I saw an impressive presentation of treehugger.js – a handy JavaScript library for representing, analyzing and transforming tree data structures, performing program processing. As a little finger exercise I started to write a similar library for Scala. Here is the first shot:

Url Path Binding w/o Boilerplate

Posted by & filed under Coding.

Update: Just noticed that I forgot to mention, that the following line has to be added to the main method of project/Build.scala: routesImport += “binders._” Regarding the previous post, it makes sense to provide a special Enumeration type which is bindable by the Play framework:

Play with Scala: Url Path Binding

Posted by & filed under Coding.

With Play and Scala, type-safe web development is a breeze. The following example shows how Play parses url paths and derives values of an Scala enumeration. There are two valid url paths: /signup/company and /signup/sales. Other url paths, such as /signup/unknown are properly handled as invalid. Play handles routes with variable parts like /signup/:account. In… Read more »