Tuesday, June 16, 2009

New Book by Adam Bien: Real World Java EE Patterns Rethinking Best Practices

Adam Bien has published his new book: Real World Java EE Patterns Rethinking Best Practices.

I am eager to get a copy of this book. Adam is a tireless advocate for pushing Java EE development further.

I hope this book is a big step in proving that Java EE development can be much easier and much more lightweight than we are experiencing it today in the trenches of enterprise IT.

Adams statement is: "Java EE 5 and 6 are a revolution and not just an evolution".
I think this insight has not yet found its way into the mindset of most Java EE architects. 250px-Neo.jpg Old-school heavyweight concepts from the ages of EJB2 still tantalize a lot of the Java enterprise projects.

To break free, radical steps are necessary. Best-practices have to be rethought, antiqued patterns have to be killed...

People are usually afraid of revolutions ... I hope Adam can be our saviour ;-)



BTW: If you are living in or near Switzerland, Adam will hold a workshop at the Workshoptage of ch/open. See you there!

Monday, June 15, 2009

Update for Software Testing Workshop

My semi-annual testing workshop at SWS is approaching. In the theoretical part I want to incorporate some insights I picked up recently:

From Aslak Hellesøys presentation "Executable User Stories with RSpec and BDD" (slides):

Where errors are introduced (according to CHAOS report):

Sample chart


This should put developer testing in the big picture of software development.
  • Developer testing is traditionally focussing on code, maybe also design.
  • Techniques like BDD, FIT and Acceptance Testing can also help to takle errors in the requirements.
  • Validation (in contrast to verification) can also help to uncover problems in design and requirements. Validation can be accomplished prior to the creation of the software artifacts.


  • From Jay Fields talk "Developer Testing: Welcome to the Beta Test":

    Most important characteristics of good unit tests:
  • Readable
  • Reliable
  • Performant

  • Reasons to write tests:
  • Design
  • Protect against regression
  • Achieve sign-off
  • Increase customer interaction
  • Document the system
  • Refactor confidently
  • Ensure the system works correctly

  • Unit testing suggestions:
  • Setup methods are evil
  • Test one thing at a time
  • Maintainability > DRY
  • Test names are comments
  • Zero or one mock per test
  • Expect literals
  • Create test data builders

  • Wednesday, June 10, 2009

    Join the Groovy & Grails User Group Switzerland

    If you are interested in Groovy and Grails and you are living in Switzerland, you should join the Groovy Grails User Group Switzerland on Xing.

    Thanks Silvio for appointing me co-moderator of this group. I hope I can help the group to grow.

    Tuesday, June 9, 2009

    My pitch for Grails in Action

    http://manning.com/gsmith/gsmith_cover150.jpg Today my copy of Grails in Action arrived.

    I did a review for this book, so Manning was so kind to send me a free copy.
    Unfortunately the publisher decided not to include the quote I provided, so I will print it here:

    This book should be a must read for every Java enterprise developer! Grails shows a pragmatic lightweight approach to the Java EE platform which is eye-opening and will change your perspective on Java enterprise projects.

    I really believe that learning Grails can provide an interesting new perspective on Java EE development.
    But I think there are two common misconceptions about Grails:

  • Grails is not about code generation. Even though grails provides possibilities for generating skeleton artifacts, thats just a minor convenience feature. You can use the power of Grails without even using the code-generators even once (As a proof you can watch Graeme Rochers webinar "Bulding Twitter in 40 minutes").
  • Grails is not reinventing the wheel. Grails builds on top of proven Java frameworks (Spring, Hibernate and SiteMesh being the most prominent ones, but many more integrations are available). Grails is an abstraction layer over those frameworks and aims to provide a seamless integration of those frameworks to form a homogenous web application stack. By default Grails imposes proven best practices for web development. All this is wrapped with the elegance of the Groovy language.
    But Grails is not a one-way street. It is always possible to fall back to plain Java and therefore leverage the rich ecosystem which exists on the Java platform. JMS, REST, Spring Security, JCaptcha, RSS, OpenId, LADAP, jQuery, Axis2, Compass ... you name it, Grails provides it ...

  • Tuesday, May 26, 2009

    Balsamiq Mockups

    http://www.thinklocalsem.com/wp-content/uploads/2008/09/arrow-up.gif People who are involved in user interface development should definitely check out Balsamiq Mockups. I have successfully used the free online version, and would recommend the product for any project where UI design is involved.

    Everybody interested in a Web 2.0 startup success story, should also have look at Balsamiq. Read this interview and this blog post.

    Wednesday, May 20, 2009

    GR8Conf Summary: Groovy, Grails and Griffon in Copenhagen

    Update [2009-06-29]: The slides of the conference are available on slideshare.


    A remarkable group of alpha-geeks have gathered the last two days in Copenhagen to attend the GR8 Conference.

    GR8Conf was a small conference dedicated to Groovy, Grails and Griffon.

    About 90 people were attending, the conference, which is quite a number considering that the main marketing channels were mailing-lists and twitter.

    Twitter was also an amazing phenomena at the conference itself: The conference almost seemed to take place in two parallel universes: Copenhagen and tweety-land... during the sessions a lot of the attendees were constantly tweeting their impressions and reading the tweets of their fellow attendees that were sitting next to them in the same room. The traces of this reality-loop can be found at #gr8conf on twitter.

    The first session was from Jonathan Felch about a project in Real-Time Computational Finance.
    At least some knowhow from the financial trading business would have been a requirement to really understand this sessions. Nevertheless it was interesting to see how Groovy with its dynamic nature was able to provide a real benefit in a highly dynamic business environment.

    In the second session Dierk König presented 7 usage patterns for Groovy in Java projects.
    P1020742_.jpg
    This was an interesting and very cunningly presented session.
    The seven patterns had quite expressive names: Super Glue, Liquid Heart, Keyhole Surgery, Smart Configuration, Unlimited Openness, House-Elf Scripts and Prototype.
    Two more patterns were announced: Lipstick and Ghost Writer.
    When asked about Groovy anti-patterns, his response was: overuse of the each()-method on lists, overuse os mocks and overuse of DSLs.

    In the third session Guillaume Laforge presented the novelties of Groovy 1.6. The content of the session was roughly the same as in the matching InfoQ article.
    In my opinion the AST transformations / compile-time metaprogramming capabilities are the most ground-breaking new feature, which has a huge potential for upcoming innovation.

    In the fourth session Graeme Rocher presented the novelties of Grails 1.1.
    P1020745_.jpg

    The main focus of this release were better integration of Grails into the Java ecosystem (e.g. Maven or Ant) and improvements in the Grails plugin system.

    The fifth session was a presentation of Guillaume Laforge about domain specific languages in general and the specific language features that enable the realization of internal DSLs in Groovy.
    P1020749_.jpg

    After that Andrew Eisenberg gave a short demonstration of the upcoming Groovy plugin for Eclipse that is currently developed at SpringSource.

    The first day then was concluded with a dinner in Copenhagen's Tivoli.

    Day two started with two fast paced sessions by Graeme Rocher. Graeme once said on Twitter "some Java confs are like funerals" ... he proved the contrary in those two sessions. They were jaw-dropping and woke the impression that Grails is really the holy grail of web development ;-)

    The first session was called "Building Twitter with Grails". It was basically the same content as Graeme's Webinar.
    Even after having attended the Webinar, it was still very inspiring to see Graeme live. It's just very impressive to witness the creation of quite a sophisticated web application (including security, full-text search, caching, asynchronous communication over JMS and RSS support) in under one hour.
    A particularly funny episode during the presentation was when Graeme's attachable microphone went dead. As a temporary replacement he was given a handheld microphone, but since this was a real-time coding session, he needed both his hands ... Dierk König jumped in to stand behind him and hold the micro ... this shed a whole new light on pair programming ;-)

    P1020752_.jpg

    The second session was about the Grails plugin system. This session was equally astonishing as the first one. In another live coding session Graeme developed a plugin and demonstrated that Grails plugin development is not only something for infrastructure gurus but a useful way to modularize a Grails application.
    On the same time he used the iwebkit plugin to demonstrate how easy it is to develop an iPhone interface for the twitter-clone from his previous session. This was extremely impressive and provoked the urge to try it out yourself...

    The next session was by Jim Shingler about Griffon. This session had a hard stand after Graeme's incredible performance. Also the Griffon project seems still very much in the beginning, so there were a lot of questions and several discussions in the audience.
    Unfortunately Jim ran out of time, and could not really finish his main goal: A rich client for the twitter-clone built in Graeme's previous session.

    The last session of the conference was by Paul King about "Industrial strength Groovy". This was a very valuable talk, since it was obvious that Paul had a lot of experience from real-world Groovy projects. He talked a lot about best practices for Groovy and the similarities and differences between Groovy and plain Java projects. His slides can be found on slideshare.

    P1020757_.jpg

    Day two was wrapped up with a panel discussion with all the speakers of the conference.
    P1020759_.jpg

    One common undertone in the discussion was, that Grovvy and Grails are currently transcending from the early adoption phase into becoming a mainstream technology. This was underlined by the acquision of G2One by SpringSource and by the statement of Dierk König, that Groovy expertise has lately become a selling argument for Canoo.


    Wednesday, May 13, 2009

    JPA2 - the potential to revolutionize Java development?

    innovation.jpg The proposed final draft of JPA2 (JSR 317) is out for more than a month now.

    Between the public review version and the proposed final draft, a significant detail was added. This detail might well be overlooked, but in my opinion it has the potential to revolutionize Java development.

    I am talking about the JPA Metamodel API.

    With the new Metamodel API, queries can become almost completely typesafe. This is achieved by exposing a typesafe metamodel of the entity model.

    This metamodel is actually nothing fancy, it is represented as simple annotated Java classes (ups... I might just have lost all the heavyweight MDSD guys ;-))

    Now, the usage of Java classes with public static fields to get typesafety is hardly something new. I have been on several project that successfully leverage this.

    Of course it makes sense to generate those classes. Therefore most of the projects using this concept have developed some homegrown generator infrastructure. This is usually where the problems start... this infrastructure is mostly proprietary, can be clumsy or outdated, needs special instructions and intricate knowhow. It can and therefore will fail, it interrupts the build process and prevents a seamless development experience (Of course thats just my point of view :-))

    That's exactly where the revolutionary potential of the proposed implementation of the new JPA Metamodel API kicks in.

    According to spec lead Linda Michiel's Blog:
    We plan to release an annotation processor to be run in conjunction with javac to generate these classes.

    Gavin King (founder of Hibernate and Seam, spec lead of JSR 299) was the originator of the idea for this typesafe Metamodel API. On his blog he presents the idea to realize the code generation process as an APT plugin for javac:
    So I've just spent several days researching the capabilities of javac Processors, and it's very clear that you can generate the necessary types as part of the compilation process. So no tool will be required. (This is a very exciting new language feature of Java 6, by the way).

    Emmanuel Bernard (founder of Hibernate Search, spec lead of JSR 303) comments on Linda Michiel's Blog:
    Note that while the IDE can explicitly generate the metamodel on the fly, it can also delegate to the annotation processor that is triggered by the Java compiler. Even if the IDE has no specific JPA plugin, the metamodel is still generated on the fly. Same for plain old command line compilation.

    As readers of my blog might have noticed, I am not the biggest fan of code generation. But the above quotes sparked my interest, especially since they come from two bright minds that seem to have a sane opinion in the religulous debate of code generation.

    So I guess it would be an appropriate moment to look into the javax.annotation.processing package of JDK 6.

    As others have noted, the typesafe Metamodel API helps Java to catch up to LINQ in .NET.

    revolution.jpg But I think it has more potential!
    If the generation process is really seamlessly integrated into the compilation process, then this could offer the means to overcome a lot of the deficiencies of the Java language.
    Specifically areas where the lack of method and field literals prevents elegant solutions can now be tackled.
    By extending the compilation process, its may even be possible to venture into areas where traditionally dynamically typed languages are especially strong ...

    Update: There is even more Information on Gavins Blog: Java 6 compiler plugins and typesafe criteria queries and Linda blogs the typesafe query API for JPA 2.0

    Related Posts Plugin for WordPress, Blogger...