Tuesday, May 27, 2008

Grails Tutorials

I have just released first draft version of grails tutorials powered by Grails. You can find it at www.grailstutorials.com.

For me it is only alpha version but I believe it can be useful already. You are able to register, to post link and to search among posted articles. I hope that in the near future there will be much more features like tags, rating, hierarchical search...

As you find interesting article, just paste link to that article here so the all community of Grails and Groovy practicioners can benefit from it. This way our knowledge will be focused and the Grails and Groovy community will be able to grow even faster.

To understand how I see future development of www.grailstutorials.com just visit vision section.

And don't be lazy and post some interesting links :)

Wednesday, May 21, 2008

What to do when Grails does not generate table for your domain class

Situation I hit was that while running on HSQL file based database everything was running perfectly. Then I have decided to change database to MySQL. Well, in grails this is really easy. Just add MySql jdbc driver, change DataSource.groovy file, manually create empty database and start application. You see no errors in console so you access you application through browser and here comes surprise. You get stacktrace claiming that table is missing. You check the database and table is really missing. How is it possible? There is no error reported?

After some googling and reading this post I found solution or better solution how to find solution :)

Go to Config.groovy and log4j hibernate level change to the debug. Start the application and hibernate will display all actions it performs. In the big stacktrace you should be able to find description what happend. In my case it was:

[1704] hbm2ddl.SchemaUpdate Unsuccessful: create table tutorial_link (id bigint ...
[1704] hbm2ddl.SchemaUpdate BLOB/TEXT column 'link' used in key specification ...

So it turned out its not a problem of Grails, nor problem of Hibernate but different handling of columns by different databases.

However it took me some time to find out and understand what is happening so I decided to post it so maybe I will save somebody's time.

Tuesday, May 13, 2008

Why is it so Easy to Work with Grails

Last few days I am working on grailstutorials and this is the first time that I am doing some bigger project than experimenting with Grails. While so far I had that feeling now it is even more clear to me while development with Grails is so easy and fast. I will try to share my understanding how high efficiency is achieved when working with grails. Let us see what more or less common web application requires to be implemented: (This list is not full list and I can add number of points into this list)
  • front end for end users
  • front end for administrators and other special users
  • Easy creation of templates and tag libraries
  • business logic persisted to database
  • security
  • searching
  • (java back end - this can be discussable)

Let see each of these points.

Front End for End Users

Regarding front end for end users different requirements may be important. Maybe you want fancy front end with lot of Ajax. If this is the case you have different plugins available like (GWT, Flex). This means you can easily integrate advance Ajax concepts into front end. If you need only simple Ajax you can achieve this with the core grails functionality. You may want to have a look on one of my previous posts Grails and Simple Ajax. At the final end, as with all frameworks to have really nice user interface you have to work hardly and cannot achieve this in minutes. With Grails it may be faster but need not. But the real velocity comes with further features.

Front End for Administrators

Creation of front end for administrators is mainly out of the box. Just try to think what are administrators responsibilities. They have to create something (usually business objects), they have to approve something - usually on business objects, they need to have overview of the system status - usually on business objects. Mainly they do not need fancy user interface. No fancy user interface means that you can use one of the grails out of the box features - scaffolding. For each domain object grails can for you generate CRUD screens. For administrators to be able to work with these screens minor if any updates are necessary.

Easy Creation of Templates and Tag Libraries

With Grails creation of templates and tags is so easy that very soon you will realize that all gsp files are created from templates and tags. Code that influence readability of gsp files, at least for me, are conditions, loops and similar programmatic constructs. All these constructs are easily replaceable with template or tags. Actually, when I create template, I immediately create tag for that template and after that work only with tag. To see example of template and tag lib you may want to have a look at my post about templates and tag.

Business Logic Persisted to Database

Here comes full power of the Grails. Just create domain object and database tables are generated for you. Even database is automatically updated when you update domain objects. For each domain object or relationship between domain objects you can create basic CRUD screens. Learning how to work with domain objects does not take a long time and if you have experience with Hibernate it can take you less than a day.

Security

Generated front end for administrators and working with domain object on the low level will be useless if there is no security for application. For sure in the most of the cases we cannot allow end users to see domain objects in CRUD screens. It means we have to secure CRUD screens. This is actually not a problem. There are security plugins for grails. I have used acegi security plugin. It will generate all necessary classes and screens for you. All you need to do is to specify what is visible by which role. And this configuration is really very simple. So in matter of minutes you integrate security into application. I am not sure about advance features as I didn't have used them but probably it should not be complex either. How much time it usually takes you to secure web applications developed with other technologies?

Searching

These days searching is popular. And of course it is useful. All data on you web site will be useless if users cannot find them. Grails has solution for this too. You can use Searchable plugin. You add line of the code to the domain class(es) and out of the box you have searching integrated into your application.

Java

I must agree that this is really discussable if we need Java or no. But in the case you want to have backend implemented with Java, important thing is that Java is integrated with Grails applications seamlessly.

I have just made short overview of features that was most useful for me so far while working on grails application. Features mentioned are not full set as grails frameworks contains lot of other important capabilities. Just to mention few of them: easy unit, functional and integration testing, excellent plugin system, work with XML, web services...

What about your experience with Grails?

Thursday, May 8, 2008

Book Review: Peopleware

For those who had no chance to read the book Peopleware: Productive Projects and Teams (second edition) by Tom DeMarco and Timothy Lister I really can only advice them to read it. At the first moment I was not sure if I want to read this book but now when I have finished it I am sure I will advice all who are interested to read it.

Although the book is by publishing date "old" in terms of IT development it is full of good advices. As I am supporter of Scrum I was pleasantly surprised that most of advices mentioned in the book are not "nice to have" but "must to have" features to successfully apply Scrum at your project. Book describes the most important aspect of every company, persons that work on the projects. Even Scrum applied by the book will fail if you don't use some common sense.

The book is divided into 6 parts.

Part I: Managing the Human Resources

This part if focused on how human resources should be or should not be managed in IT field. It describes how different is software development compared to development in factory. It also have a look on Parkinson's Law that time will stretch to fit the work concluding that the this Law is wrong. Very interesting chapter for all who has something with human resources.

Part II: The Office Environment

This part is focused how office environment should be organized to have productive developers. It also presents some statistical data how productivity decrease when environment is too noisy or does not fulfill some basic requirements. Everything mentioned here is true and mainly must be to have productive teams.

Part III: The Right People

For project to succeed it is not enough to have the best experts in corresponding fields. For project to succeed even more than the best experts available are right people. You will learn how to recognize and keep the right people within company.

Part IV: Growing Productive Teams

It is not enough to put n persons together and to expect that they will be productive. Productivity must be grown and only really good managers are capable of doing that. Read the chapter how to increase you chance to grow a productive team

Part V: It's Supposed to be Fun to Work Here

Work should be fun. Especially IT work should be fun. If people are not happy with their work you should look for problems within your company.

Part VI: Son of Peopleware

This is completely new part added to the original book (first edition). As authors mentioned first parts were written by young consultants that worked on project level. This part is written by older consultants that mainly worked on company organization level. Read this part to find out what have changed in their views compared to the previous five parts.