Thursday, July 23, 2009

Up Next - Spring Certification

I would start preparing for Spring Certification starting this week. I would like to try and get the exam done in next three months.
It is an extensive exam with no proper study notes or mock exams and need 76% to pass. This will be fun.
Go Spring !

Wednesday, July 15, 2009

Liferay book by Jonas Yuan

I got an oppurtunity to review the new book from Packt publishing - Liferay Portal 5.2 Systems Development by Jonas Yuan.
 A few words about this book.
This is a nice begineer to intermediate to semi-expert level book. The book begins with a nice overview of the liferay portal system and WCM and introduction to JSR 286 portlets. The author then gradually raises the bar with more details on how to develop portlets, manage pages, and customizing the portal.

My favorite chapters of the book were the chapters on Social Office, Staging & Publishing and using common api.
Actually the social office chapter was quite a surprise. The author has given good treatment to the topics explaining them in sufficiant detail for a beginner and at the same time making it relevant to the advanced users. The author has also explained the events and hooks very well.

One more thing that I liked about the book was that the author explains how the code works out of the box and then how to customize it. I liked the "Whats happening?" sections of the book

One of the things I do not like is that there are a few sections in the book like "Using SCORM" that do not talk about the topic in detail. This raised the expectations but then quickly brought them down looking at just a few lines of explanation. However there were not a whole lot of such topics.

All in all I would recommend this book to anyone who wants to get started with Liferay and get a good handle on the system.

Thursday, July 2, 2009

Hibernate - Annotations vs XML

Recently I was involved in a healthy discussion at my work on using Annotations for Entities. We have a Java web application with Spring MVC, Hibernate and Entities with hbm.xml files. Entities with XML work well however there is an interest in the team to use annotations. Here are my thoughts - pros and cons of each approach. I have used both approaches, however I like using hbm xml files over annotations for entities. That said I do like the use of annotations in Spring MVC, TestNG, or on service layers to mark transactions.
Why stick to hbm.xml files?
  1. Well, if we think back to days before hibernate, when we used JDBC we had the problem where the SQL code was embedded in Java classes, thus causing many maintainability problems. With Hibernate xml files we got a clean way to keep them seperate - the entity pojo's were free of the sql clutter. With Annotations in Entites we are going back to that same model !!!
  2. Entities are cross cutting code - they are used in all layers, starting from DB all the way to JSP in many cases. Cross cutting logic should not have code that looks more biased to a certain layer.
  3. If you are working in a team that is split into Backend Dev team and frontend dev team then the front end team does not need to see all those annotations. Well what would be the argument if frontend team wants to add their own View specific annotations to entities for ease of use?
  4. If you have a code base that takes long time to compile and build (fortunately for us it takes a few seconds), having an hbm xml file is better. No need to recompile.
  5. If you have to migrate from xml to annotations on an existing ongoing project what is cost justification to use annotations?
Why move to Annotations?
  1. Well, as my collegue at work explains, it improves maintainability by having only one file
  2. As Paul Mazak would say, the mantra is "less code characters", helps in long run.
  3. Annotations are cool ! Learn some new stuff
Well in the end it is a religious debate and fun as well. I will stick to hbm xml so far, playing with Annotations as I get an oppurtunity for new development.