Search This Blog

Monday, April 20, 2009

J-Spring 2009 part 2

The second keynote was given by Jos Warmer, a Model Driven Architecture evangelist. Jos has a lot of experience with MDA and you can see that from his talk. His talk was about Mod4j. According to the website: “Mod4j (Modelling for Java) is an open source DSL-based environment for developing administrative enterprise applications.”

Mod4j is an environment in which DSL’s are used to generate specific parts of a Java application. At the moment three DSL’s are implemented (and a fourth is on its way) which focuses on specific architectural layers of the application. These DSL’s are:

  • Business Domain DSL
  • Data Contract DSL
  • Service DSL

The business domain DSL implements the concepts to specify the business objects in your application. These are: business objects with properties, associations between business objects and constraints. Consider the following example:

association Order order one -> many OrderLine orderLines ordered;

The above sample DSL generates a one-to-many association from the Order to the OrderLines class including the necessary Hibernate mapping files. A lot of boilerplate code is generated by using the business domain DSL.

The Service DSL is used to specify services for your domain objects. Examples are the CRUD operations of a specific domain object and finder methods. The code generator for this DSL takes care of generating the required Java code. Consider the following code:

from RecordShopDataContract import SimpleCustomerDto;
create createCustomer for SimpleCustomerDto ;
read readCustomer for SimpleCustomerDto ;
update updateCustomer for SimpleCustomerDto ;
delete deleteCustomer for SimpleCustomerDto ;

The preceding code generates the CRUD methods for the SimpleCustomerDto in the service class.

What’s nice about Mod4j is that no visual models are used for code generation. Domain Specific Languages are used instead. The DSL’s can be put in a version control system where you are able to use the version control system’s merge and history abilities; something which is hard to implement when using visual models. There are also a lot of extension points to modify the generated code. But when you find yourself modifying too much of the generated code, you must ask yourself if the code generator should be modified instead. With mod4j this is possible because it is open source. What’s also nice is that there is an Eclipse plug-in to facilitate Mod4j development. With this plug-in you get code completion on the provided DSL’s.

Although I am not a big fan of Model Driven Architecture tools, I like the concept and principles of Mod4j mainly because coding is central. When should you use Mod4j? I find this a difficult question. When working on a large multi-layered application in Java with technologies like Hibernate, Mod4j can make sure that a consistent architecture is used across all layers. New developers can be more easily brought up to speed.

But when looking at the DSL’s used for generating code, I immediately thought of the Grails framework, based on Groovy. Grails uses a lot of DSL’s. Consider the following Grails example which creates an Author business object:

class Author {
static hasMany = [ books : Book ]
String name
static constraints = {
name(size:5..15,blank:false)
}
}

The above code is the Author business object in Grails with a one-to-many association to the Book class. It also implements a constraint on the name property. Because of the dynamic nature of Groovy, you get the CRUD operations, dynamic finders and the relationship handling for free. If you want to customize the mappings you can modify the Hibernate mapping files if you want.

So the DSL Grails uses is what I call an executable DSL whereas the DSL’s that Mod4j uses are used to generate Java code.

Despite this there is still place for a technology like Mod4j. Not everyone is in the position to use Grails (or Rails) to facility high speed web development. When plain Java web development is used, Mod4j provides a viable alternative to speed-up this development. I will definitely keep an eye out for Mod4j!

Service Oriented Architecture

The next session I went to was about Service Oriented Architectures from Tijs Rademakers. His presentation turned out to be a very practical session which included a lot of his own experiences when implementing Service Oriented Architectures. I like this approach very much. He clarified some misunderstandings when using ESB’s. When an ESB is used, often a lot of code has to be written inside the ESB. Think of transformation and routing logic. This code has to be maintained as well which is often underestimated.

Tijs also talked about how to handle XML messages in a Service Oriented Architecture. I always thought that Groovy has superior XML handling capabilities compared to Java. Tijs mentioned Groovy as one of the most effective ways for handling XML. I agree! So when working with XML in Java (Service Oriented Architecture or not), consider using the Groovy language for the XML handling logic.

Conclusion
Despite the economical situation, 4 people of my company (including me) went to the J-Spring. At QNH we find it very important to continue to invest in knowledge. Individuals are the most important part of a company in which you should invest.

I found the J-Spring 2009 a very good day with lots of good speakers and sessions with a great variety of subjects well worth the investment. If you’re a Dutch Java developer and was not part of J-Spring, make sure you will be at J-Fall later this year.

Keep up the good work!

Friday, April 17, 2009

J-Spring 2009 part 1

April 15th I went to the Dutch Java user group conference named J-Spring. This is the first of two blog entries about this conference. The J-Spring is a popular 1 day conference about Java and related technologies. It is a good place to get an overview about the current state of technology and meet fellow developers.

The introductory keynote was given by Sherali Karimov from Atlassian who talked about how agile is implemented at Atlassian.

Two things in his presentation I found particular interesting. These were:

  • The disturbed
  • Blitz tests

The disturbed
We are all familiar with it. Sometimes you and your team members get so many questions from different people that your own work suffers from it. At Atlassian they introduced the role: the disturbed. Whenever someone has the disturbed role, he/she is expected NOT to do any work but instead answer all questions from outside. The other team members can focus on delivering. The disturbed role is changed every week to another team member. Every week a new team member is responsible for answering questions from people outside the team. Besides shielding the team from outside questions, the disturbed role has another advantage. By switching team members to answer questions, gradually each team member gains the knowledge to answer those questions. It is an effective and practical way to share knowledge within the team.

Blitz tests
Another concept that was introduced is Blitz tests. Atlassian uses there own products inside there own company. Whenever a new release of a particular product is released, it is deployed on the company’s production environment. People from within the company can subscribe to test the new functionality. The experience at Atlassian was that a lot of people subscribed and were eager to test the new functionality. They gave a lot of good feedback to the development team which resulted in higher quality software. I believe you gain a lot when you have the possibility to test every new release by certain people in your own company before releasing the product to your customers.

JEE and JavaFX
The next session I went to was from Paul Bakker. This session was about the future of web development with JEE6 and JavaFX. Paul gave a very complete overview about all the technologies involved in JEE6 and JavaFX. A couple of technologies used in JEE6 are JSF 2.0, JAX-RS and JPA 2.0. After giving a brief overview about every technology, Paul showed how to build a web application with JSF and JavaFX together. Basically, JavaFX was used for the highly interactive parts and JSF for the HTML forms. JavaScript was used to act as a bridge between the HTML page and the JavaFX applet. He also showed how to pass parameters between the applet and the HTML page and vice versa. This seems like an effective way to combine JavaFX with regular web development. JEE6 and JavaFX definitely look very promising!

Look out for the second post of the J-Spring which will highlight some interesting points from the other sessions I attended.

Monday, April 6, 2009

J-Spring

Next week, April 15th, I am going to the Dutch Java User Group conference named J-Spring. This one-day conference is a good place in helping to keep your knowledge up-to-date. There are a lot of interesting sessions which you can attend and a lot of fellow developers to have discussions with. I Am planning to attend the following sessions:

  1. Developing web applications of the future: Combining JavaFX & JEE 6
  2. Java Programming in a Multicore World
  3. SOA, it's a hard knock life
  4. REST, the web as the database?
  5. Hop on Board the Java Troubleshooting Platform

I will post my experience of the J-Spring next week.