The MetaSieve Blog

March 1, 2010

MagicNumbers: Dynamic Time and Byte Calculations for Grails – Using the Meta Object Protocol to add behaviour to Grails at runtime

Filed under: Uncategorized — Tags: , , — Björn Wilmsmann @ 1:00 pm

The March issue of GroovyMag, an online-only magazine for everything Groovy and Grails has been published today.

I’ve contributed an article about the Grails MagicNumbers plugin you might find interesting. Here’s a teaser:

Grails plugin development and Groovy‘s Meta Object Protocol are powerful tools for adding runtime modifications to standard Java classes. Introducing the new Grails MagicNumbers plugin, I’d like to show how metaprogramming in Groovy can be used to make code both more readable and easier to write. The MagicNumbers plugin allows you to write readable code like 3.days or 6.megabytes instead of having to manually calculate the equivalent number of seconds or bytes.

[ … ]

Code like this obviously has several advantages over manually calculating and writing the actual numbers:

  • It is written much more easily.
  • The code is much more readable. You can even show this code to someone who hasn’t any programming experience at all and she will immediately understand its purpose.
  • The code is less error-prone and thus more maintainable.

So, I wanted to have this kind of magic in Grails as well. Fortunately, due to Groovy’s Meta Object Protocol and the Grails plugin framework, this kind of functionality can be added quickly and elegantly.

[ … ]

Read the rest of this article at GroovyMag.

Related links:

January 8, 2010

Using Grails for creating UML diagrams

Filed under: Uncategorized — Tags: , — Björn Wilmsmann @ 7:59 pm

Back in the old days (like, 5 years ago …) when embarking upon a new software project you would (hopefully, that is …) usually start by sketching the underlying model using ER or UML diagrams.

No matter if you’re on the more enterprisey side of software development that requires more complex upfront documentation or if you’re going down the agile road, there had to be at least some sort of a model.

Problem is, once you’ve drawn that model in your favourite UML design tool or just with good ol’ pen & paper, you have to turn that model into code. Although the more expensive UML design tools allow for code creation and sometimes even feature round-trip abilities (that is code changes are reflected in the diagram), most of them are far from perfect in that they mostly produce fairly generic Java code that has to be heavily customised depending on the framework you’re using.

Even worse, if you use another language like Groovy or Ruby you likely have to start writing code from scratch.

However, fortunately for Grails there are two nifty plugins that offer an elegant way out (see for a Rails solution):

Both automatically create UML diagrams for your app’s domain model. The main difference between those two is that the former draws upon, a very promising web service that allows you to create UML diagrams with a Wiki-like syntax.

So, nowadays I don’t even bother firing up Visual Paradigm – the UML design tool I liked best before – anymore when I have to design a domain model. All I do is run ‘grails create-app’ and start writing actual domain class code! Thanks to GORM, Grails‘ object-relational mapping, writing actual code is easier and faster than drawing diagrams in a design tool.

Once I’m done I can use one of the plugins mentioned above to create a shiny UML diagram for impressing the customer and documenting the current state of the application.

Update: Sven Lange wrote a nice and more detailed blog post about Grails and UML diagrams, too:

January 4, 2010

Software Development on the iPhone? Almost there

Filed under: Uncategorized — Tags: — Björn Wilmsmann @ 10:36 pm

Last week I also touched on the subject of software development on mobile devices.

Well, it seems like we’re almost there. There is this video that sports a hacked iPhone which is operated with a Magic Mouse and a keyboard projected onto a table surface.

Combine that with the Mili Pro Video Projector and basically you’ve got everything you need to get started with writing code on the iPhone.

Sure, this is still not generally available and it’ll take some time until it is but I doubt Apple – being renowned for their revolutionary I/O devices – will miss this opportunity.

So, we can almost certainly expect an iPhone that incorporates these features in the not-so-distant future.

However, as both the iPhone doesn’t yet feature sufficient memory and CPU performance for a full-blown development environment and Apple most likely won’t admit any languages apart from Objective-C any time soon, we would have to find different ways to code on such an iPhone.

The most obvious solution in my opinion is a version control client app that directly commits changes to a Git or SVN server and displays the results in a browser window.

This is going to be very exciting and indeed could change the way we develop software.

January 2, 2010

Grails MagicNumbers Plugin 0.2.2 released

Filed under: Uncategorized — Tags: , — Björn Wilmsmann @ 5:14 pm

I’ve been busy today working on some improvements of the new MagicNumbers plugin.

The new version mainly features new methods for byte calculation, some additional time calculation methods and a bug fix with regards to displaying large numbers. Moreover, the plugin now also adds its methods to the Long class in addition to the Integer class.

Please have a look at the plugin documentation, too:

Grails MagicNumbers Plugin 0.1 released

Filed under: Uncategorized — Tags: , — Björn Wilmsmann @ 4:35 am

Inspired by RailsActiveSupport library, we’ve just released the MagicNumbers plugin that adds several time calculation methods to the Integer class:

With this plugin you now can do cool things like the following with Grails as well:


December 31, 2009

Tired of updating your copyright notices each year?

Filed under: Uncategorized — Tags: , — Björn Wilmsmann @ 7:15 pm

If you have a website chances are you go through the same tedious process each January, 1st: Updating your copyright notice to the current year. If you happen to use Grails for your website you can have it handle that update automatically for you (other frameworks and languages are of course capable of this, too) by adding the following code to the footer of your layout:

&copy; <g:formatDate format="yyyy" date="${new Date()}"/>

Web Development: Past, Present and Future

Filed under: Uncategorized — Tags: , , , , — Björn Wilmsmann @ 7:08 pm

Web development since its inception has gone a long way. From the very first dynamic websites which were done using C or LISP programs to interface with web servers via CGI to something like Facebook, Twitter or Basecamp, it’s a very long way indeed.

The first programming language that saw major adoption as a language / an environment for web development was Perl. Although Perl nowadays is notorious for it’s quirky and (supposedly) ‘write-only’ code, its dynamic nature and language features that made ‘easy things easy and hard things possible’ was a huge improvement over anything that existed before. Perl is still one of the most widely used scripting languages, so there is definitely something to it, although hardly anyone does consider using Perl when starting a new web project nowadays.

Then came PHP, which again was a huge improvement over Perl – or at least the way Perl was used to that point. PHP allowed you to create much more maintainable code for web applications. Wait a minute, PHP and maintainable? Yes, consider the difference between reading and writing something like

print "<img src=\"$some_var\" alt=\"$another_var\" />\n";

in Perl and something like

<img src="<?=$some_var?>" alt="<?=$another_var?>" />

in PHP. The latter is both much easier on the eyes and written more swiftly. The huge advantage of PHP was that you could mix HTML code with PHP commands without having to resort to print (or echo for that matter) calls for rendering HTML tags.
This allowed non-programmers to add simple dynamic content to their website – which somehow of course is both a blessing and a curse 😉 . However, it opened up dynamic Internet content creation for more than just the IT-savvy crowd.

Oh, yes and then since the mid 9ties there was Java. Starting with the now completely obsolete applets Java promised to bring dynamic content to the browser that reacted sort of like applications on your desktop.
While applets were a nice tech gimmick mostly used for displaying menu roll-overs (apart from some rare cases where they performed useful tasks as in early online banking software), Java was a lot more useful as a server side language serving dynamic web content. However, while Java allowed to develop and maintain applications that went beyond the complexity you could usually handle with PHP or Perl, there were shortcomings, too.
Java didn’t feel as dynamic (nowadays you’d say ‘agile’) as scripting languages because you’d have to go through a cumbersome ‘edit – compile – (hopefully) test – edit again’ cycle while with your usual scripting language you would do changes right on the live system and they’d appear right away (which of course is very bad practice but more frequently than not it was done anyway).
Even worse, with things like Java Enterprise Edition many developers – or architects, as they soon began to call themselves – boasted to be able to deliver enterprise-class, highly scalable applications, which more often than not was just a euphemism for ‘So damn complex I hardly understand it myself but it allows me to draw lots of awe-inspiring colourful diagrams and charge much higher rates without doing a single bit of actual coding.’.

Then, back in mid-2004, along came a new web development framework built upon a – at that point – rather esoteric scripting language that was bound to take the web development world by storm: Ruby on Rails.
Rails kind of united the best from both Java and the previous scripting environments. While it took things up a notch by allowing you to develop under a rigorous MVC environment it also did away with the complexity and initial setup effort that was harrowing Java developers.
To me – and I’d venture to say to many others as well – it was like some kind of epiphany like ‘I always knew there was something wrong with how A or B is done and finally someone got it right.’

In 2006 this spirit was ported to the Java platform with the advent of Grails, which as you can tell by its name feels a lot like Rails, with some new concepts of its own. Grails is built upon Groovy, a scripting language for the Java Virtual Machine, that brings all the cool scripting language features like comprehensible, succinct code, closures and dynamic typing to the Java world.
As you can probably tell from previous posts Grails currently is my favourite web development framework as it sports most of the advantages of Rails, combined with some pretty nifty features of its own and the advantages of the JVM, which of course are performance, scalability and a vast variety of robust libraries for all sorts of purposes.

So, the big question is: What will web app development look like in let’s say 5 years from now? This seems like an awful lot of time considering that Rails has already been here for 5 years.

My guess for the not-so-distant future is that in the Java world we will see Groovy being much more widely used even in more traditional frameworks such as Struts, Seam or Wicket. It allows you to be much more productive without having to abandon Java. It also is rather likely to feel more natural to most Java developers than other alternative languages for the JVM like Scala, JRuby or Clojure.

However, that’s for the Java world and that’s actually a rather incremental change. My feeling is that it’s about time for the next big step in web app development. With AJAX and similar technologies having dissolved and melded both the traditional page and desktop app paradigms it seems that classical MVC-oriented frameworks are no longer completely appropriate.
Visual user interface designers like Atlas sure are promising but still have a long way to go. Furthermore, good developers love to write actual code so mere visual development might not be a general approach.
I also like this idea of development on mobile devices, which due to the limits of handheld devices would to some degree also involve visual development processes.
What is quite certain though is that the choice of frameworks and languages will become less important. It’s the APIs and web services that you use and how you combine them that will make all the difference.
Maybe, we’ll see something like a sophisticated (well, even more, that is) version of Yahoo Pipes combined with something like Atlas that will allow you to visually design awesome web user interfaces and combine all sorts of services and APIs to something entirely new while not having to consider the actual design of the underlying model anymore.
Ideally, this development engine would take care of source code management all by itself and would allow you to design tests using a visual interface alongside with an explicit domain-specific language as well.
This would certainly require an even higher level of abstraction and services that provide the building blocks like user / permission management and pre-designed models for the most common use cases.
Considering current plugin systems like the ones sported by Grails or Rails, I envision something like a public plugin system that can be loosely integrated into an application no matter which framework that application is built in.

So, enough with the rant for now, I probably shall elaborate on one or two of them soon. For now I’d like to wish you a happy and exciting new year 2010.

December 28, 2009

Grails SocialBookmarks Plugin 0.2 released

Filed under: Uncategorized — Tags: , — Björn Wilmsmann @ 3:24 am

Based upon the original SocialBookmarks plugin by James Williams we’ve just released a new version of this very useful plugin and the best thing is, it’s available via the public Grails plugin repository:

December 23, 2009

End of the year roundup

Filed under: Uncategorized — Tags: , — Björn Wilmsmann @ 6:33 pm

I really like the final days of a year. Everybody seems to be busy getting things done, accomplishing as much as possible and buttoning everything up so open issues don’t reach on to the next year.

The Internet and software business is no exception. The end of the year being nigh seems to provide most people – customers and developers alike – with that little extra focus.

This applies to our own business as well as open source projects like Groovy and Grails who have been – or in case of the Grails guys – who still are busy getting out their latest and greatest version before the holiday break with its plentiful meals sets in. We also did our fair share by contributing a new version of the Grails Shopping Cart plugin a few days ago.

Anyway, even the Internet world seems to revolve at a slower pace towards the end of the year (even if only slightly so), which is a welcome and pleasant break that allows you to refocus on what’s truly important.

Wishing you all a happy holiday season and all the best for 2010.

Update: While I was writing these lines, the Grails guys have released a new version of the formidable web framework.

December 15, 2009

Grails ShoppingCart plugin 0.8 released

Filed under: Uncategorized — Tags: , — Björn Wilmsmann @ 3:52 am

Grails ShoppingCart plugin version 0.8 has been released. As usual, please have a look at and for an overview of what’s been changed in this version.

« Newer PostsOlder Posts »

Blog at