Globalcode’s Casual Class: Spring

March 3, 2010

Quick post: in this last Friday, February 26th, 2010, I attended the first Casual Class of the year, from Globalcode. The topic was the spring platform and, among the main subjects mentioned were Spring itself, Spring Roo, Spring and cloud computing and the launching of the Spring Brasil User Group. If my memory doesn’t fail me, this was the most packed  Casual Class until now. Thank you Globalcode for one more great event!

A few pictures for your pleasure:

Dr. Spock Introcting Spring

Dr. Spock Introducting Spring

Renato Bellia talking about Spring Roo

Renato Bellia talking about Spring Roo

Claudinho playing with our tags

Claudinho playing with our tags

This time, SIX developers from our team decided to attend! And it was a great time for everyone. Thank you guys (and gals)!


Spring Roo: First Impressions

November 21, 2009

Two weeks ago I attended to the event The Developer’s Conference, down here in São Paulo, Brazil. I covered it here and here. One topic I decided to cover separated is Spring Roo. Rod Johnson, from SpringSource presented it in the conference, and really got my attention.

During the last few days I’ve being spending a few minutes per day with the tool. Following are an explanation about what it does, and my impressions in general. Hope you enjoy =)

The statement that describes better what Roo tries to do is “Roo is Rails for Java, but better”. Rod Johnson said something similar to this during his presentation in the TDC event, and I can agree with that. Rails productivity is nice, sure, but it doesn’t have the power of the Java platform. So bringing this productivity “home”, to Java, is an excelent idea.

To achieve this goal, Roo generates code for you. This isn’t, of course, a new idea. But the way Roo does it is what makes it really interesting. The concept is that you should be able to read and edit any code generated by the tool. Also, you should be able to use whatever IDE you prefer during development, without Roo getting in your way – I actually use Netbeans to edit the source code files, and although the IDE they officially support is Eclipse (the base for their Spring Tool Suite), it worked just fine.

The code generated by Roo has also desirable qualities: it follows good programming practices, like separation of concerns, and has good performance – there is no reflection in any of its “magic” to slow things down, for example.

This is how Roo looks like when running:

Roo Shell

Roo Shell

This is the Roo shell. It is where you type commands and execute tasks when using the tool. It features TAB completion, which works very nicely, and a lot of development support – you can type hint anytime to get a help message. Also, you can type help to see full list of commands currently available.

We haven’t created a project yet, so hint shows this:

Hint on an Empty Folder

Hint on an Empty Folder

Lets take a look at Roo in action. In the next screenshot, I’m using the command project to create a new project called JCranky:

Project Creation

Project Creation

Notice the TAB completion working; also, notice how Roo tells you what it did to your files, so that you can keep an eye on his behavior ;)

I’m don’t intend to write a tutorial, so I’ll just show one more code generation example and go back to commenting. Lets install persistence support, and then create an entity. The command to do the former is persistence setup and for the later is entity EntityName. The next two screenshots ilustrates the result of these commands:

Persistence Setup

Persistence Setup

Entity Creation

Entity Creation

Again, notice how TAB completion helps us. We don’t have to remember all those commands. Just hit TAB and Roo tells you what commands are available. Notice on the entity creation that Roo created a few .aj files. This is one of its secrets: it uses Aspects to insert code into your class, making it more simpler during source editing time. So boilerplate code like getters, setters and toString are inserted automatically in your entities to you. To understand a little bit more about this, take a look at the Aspect J site.

I’m not a fan of Spring, which obviously is used a lot in Roo and in the generated sources. But this tool seems to work so nicely that it might make me change my mind. And the same thing goes for maven, which Roo uses in the generated sources. But in this case, Roo also allows you to replace maven if you want to – but in this case you will have to write your own plugin to do that, at least for now.

I’ll stop here, but if anyone asks for more I might feel like writing another post =D. But before closing, lets mention the only one thing I really hated about Roo: it seems to generate code with TABs instead of whitespaces. So, Roo developers, I beg you: please generate whitespaces! I know it is a small thing, but it really freaks me out…

For more information, besides the official site, these three blog posts are very interesting: Jump into Roo for extreme Java Productivity; Getting Started with Spring Roo and Exploring Roo’s Architecture.

bye!

EDIT: After Ben Alex’s comment I looked again into the sources generated for my tests and couldn’t find any TABs. So please ignore this part of the post, until I find them again =D


TDC – The Developers Conference 2009 – day 2

November 12, 2009

In the last post, I talked about the first day of The Developers Conference. Now lets talk about day number 2.

Very different from the previous day, this one started full of coding. And during the day, we kept seeing lighting talks and Vinicius’ toys. The only real problem we had was that the place ran out of eletricity for a while… but at least it didn’t last too long and the event could finish right.

Rod Johnson

The first speech was again from Rod Johnson. But this time, it was not philosophical at all. He presented Spring Roo, a project that aims at bringing to Java the productivity found in Rails. After seeing what he showed, I believe it. And love it.

In summary, the tool generates a lot of boilerplate code that we would otherwise have to write ourselves. And keeps it all out of the way while you develop your project.

I liked this so much that Spring Roo will be covered in a new post, exclusive to it, soon enough. And look, I don’t like Spring, but this thing can make me change my mind.

Rod Johnson on SpringRoo

Rod Johnson on SpringRoo

Lightning Talks

One of these lightning talks was about Spring best practices, which followed Spring Roo’s presentation. Ricardo Jun presented it, and mentioned things like how people tend to simply want to totally discard xml, instead of using it in moderation; the importance of using tools; the importance of modularization and also that we should always mind concurrency.

Jun and Spring Best Practices

Jun and Spring Best Practices

Another quick demonstration about robotics had an application server installed in a device, which was accessed through http. This device was connected to a lamp, and Vinicius turned it on and off through a web interface. Meaning: I want all the power plugs in my house accessible through the internet!! =D

On the note of excited people, I must talk about Vinicius Senger again. When presenting the balloon robot for the second time now, he breathed Helium, the gas used in the balloon to make it float. The effect was that his voice got very thin for a few seconds, creating a very funny moment.

Balloon Robot

Balloon Robot

Another lightning talk was about what was previously called Web Beans – now Weld: the reference implementation of JSR 299: Contexts and Dependency Injection. Alessandro Lazzarotti, from Red Hat, gave a quick demo on the implementation which is, of course, full of annotations everywhere.

An interesting lightning talk was about performance in JPA. Alberto “Spock” talked about how the Open Session in View filter pattern can be a little bit outdated when it comes to ajax applications – an environment which wasn’t there when the pattern was created.

Alberto "Spock" on Ajax and JPA Performance

Alberto "Spock" on Ajax and JPA Performance

In Globalcode’s blog here, he explains this problem better. During the presentation, he also mentioned the Apache Myfaces Orchestra project, which should also help minimize the problem bringing the conversation scope to your application. The conversation scope was first introduced by JBoss Seam, and brings us a scope bigger than request, and smaller than session, which can really help us manage resources in a lot of situations.

Mike Keith

This time Mike Keith presented about JPA 2.0. The goal of JPA 2.0 is basically to standartise what we currently do with, for example, hibernate, because we can’t with JPA 1. Nothing really new was presented – unless you didn’t know anything about JPA 2 already. But a few topics are worth mentioning.

A new evictall function was added. Useful to completetly clear cache between test cases. Small change but sounds interesting.

Now my pet peeve: the new criteria API. He presented it and showed a few examples and comparisons between the criteria code and the JPQL code. Just made me dislike it more. Just as a reminder, I already said that I don’t like this thing when I wrote about Globalcode’s Casual Class #006. Trying to access a database completely through OO code is just too much purism. At least, Mike is a very funny presenter to watch =)

Mike Keith on JPA 2.0

Mike Keith on JPA 2.0

Francisco Gioelli (Google)

The original plan was to have Chris Schalk talking about Google App Engine. Unfortunatelly, he had problems with the immigration and couldn’t get into the country. So google sent Francisco Gioelli, who did a nice job instead.

Among other languages, Google App Engine allows us to write Java web applications and publish them on the google cloud, leaveraging from the monstruous google scalability. A few features available include possibility of scheduling cron tasks through a xml file and the Big Table, their (non-relational) database. This last feature is the only thing that makes me a little bit worried about using google’s cloud.

Francisco on Google App Engine

Francisco on Google App Engine

This talk had a demo and was complemented by another one from Rafael (from Globalcode) – this last one using JSF 2.0 – nice! Two little extras mentioned by him: each request can take at the very most 30 seconds and the internal server used seems to be Jetty.

Alejandro Guizar (Red Hat Mexico)

This one was about BPEL. This is not a topic I can talk too much, so I won’t. The only thing that took my attention was something called BPEL Unit. I never heard of it and found interesting that such a thing exists. But I couldn’t find any good references…

Alejandro on BPEL

Alejandro on BPEL

Cloud Computing Panel

To close the event, a panel on Cloud Computing, featuring the main speakers that were present. This is a trendy topic nowadays, full of buzz words, but interesting, it was!

Ed Burns started talking that Sun have something (I forgot the name…) since 2000. Makes sense… very tipical of Sun: great products, terrible marketing. He also mentioned Zembly.com. If you are insterested, go to the site now. I just went there and found out that they are closing the service permanently from November 30th. Nice… (no, not really).

From Rod Johnson, we learnt that Springsource have their hand on Cloud Computing in the form of CloudFoundry. Also, he made sure to say how important it is to have multiple players in the market. Agreed.

Some points were easily agreed by the panelists:

  • private clouds will have big importance in the future;
  • a good thing of the cloud is the economy;
  • but a bad thing is the loss of control in a lot of senses, but probably mainly data;
  • we need easy of migration between cloud providers.

Someone asked about cloud computing and peer-to-peer. The panelists didn’t seem to believe too much in this possibility. Well, who knows…

A lot of gurus on Cloud Computing

A lot of gurus on Cloud Computing

Last picture, to change the mood a litle bit:

Relaxing between presentations

Relaxing between presentations

And so it ends this year’s event. I’m already waiting for the one next year! =D