Spring Roo: First Impressions

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

Advertisements
This entry was posted in java, web development and tagged , , , , , , , , , , . Bookmark the permalink.

2 Responses to Spring Roo: First Impressions

  1. Ben Alex says:

    Thanks Paulo for the first impressions. Glad you liked it! 🙂

    Re tabs vs spaces, our ITDs use an indenting builder that always uses spaces. So I’m wondering where are you seeing the tabs? If you’d be good enough to log an enhancement request at https://jira.springsource.org/browse/ROO we’d be happy to ensure spaces are used consistently.

    Cheers

    Ben Alex
    Project Lead, Spring Roo

    • Paulo Renato says:

      thanks for the comment Ben!

      Now that you mention it, I don’t remember where I saw TABs. I went to my tests looking for them and couldn’t find. I’m puzzled =(

      I’ll update the post with this information =)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s