Friday, September 30, 2011

Thinking out of the Box

Man peeking out of moving box

In requirements analysis we learn to pop the why stack and to challenge business requirements.

The goal of these techniques is to find the real business value at the heart of a given requirement. This real business value is often hidden by an already envisioned solution. Once we know this underlying business value, we might come up with a better/easier solution. Most often the reason why we can come up with an alternative solution is that we can look at the problem in another context and from different perspectives than the original requester of the feature.

This matches with the concept of 2nd order solutions in systems theory: 1st order solutions work within the existing system while 2nd order solutions modify the system itself.

The classical example from requirements engineering is the requirement that a software system must be able to print each UI-screen. The underlying reason was, that employees manually copied data from the given system into another system by printing them out and then typing them into a terminal of the other system. Once this underlying reason was discovered, an alternative solution could be realized: integrating both systems and digitally export/import data. This solution was cheaper to realize for the implementator and provides more business value for the enduser.

A more trivial example to illustrate this "out of the box thinking" is the following task:

Connect all the 9 dots in a single move, using 4 straight connected lines:

Screen shot 2011 09 29 at 1 04 09 PM

Can you do it with three lines?

Can you do it with one line?

 

Wednesday, September 28, 2011

Back at University - Things have changed

Recently I started studying for MAS-MTEC at ETH Zürich.

A characteristic of this post graduate studies is that most lectures are shared with graduate students.

I am impressed at how much studying today has changed from when I was studying a decade ago. This impressively shows how fast technology is changing the way we live, which I seem to forget in my every-day life.

The internet is ubiquitous when studying today: The studies are officially organized over the internet (lecture selection, examination registration, learning material distribution, task assignments, group formation for exercises ...).
Laptopspicsmall On the first week I got a invitation to a DropBox share from somebody I actually do not know (probably a higher semester student) which contains over 1GB of "semi-official" studying material (solutions for exercises, example examinations, additional material ...)
One lecture even has a twitter hashtag.

Consequently practically every student is bringing a laptop or tablet to the lectures. I never have seen such a high local density of MacBooks as in the Marketing lecture :-)

Comparing that to when I started studying 12 years ago: I did not even own a cell-phone yet ... I also clearly remember when a lecture assistant suggested to use "Google", and I had never heard that strange term ...

Monday, September 26, 2011

Promotion: Usabilty-to-Go for Developers

TechtalkClaudia and Stefan from TechTalk are presenting their Usabilty-to-Go  Workshop on 3.11.2011 in the Technopark Zurich.
In this one day workshop developers can learn how to apply efficient usability-design in their enterprise project.

Check it out: Details and registration.

Tuesday, September 13, 2011

Using the JPA metamodel annotation processor

Some time ago I claimed that the JPA 2.0 metamodel API has the potential to revolutionize Java development.

I still think that the concept is very interesting by showing an approach to strongly typed meta programming in Java. However I think it does not have any relevance in real world projects. One reason is that strongly typed JPA criteria queries are very verbose and bring their own accidental complexity compared with JPQL. The other reason is the actual usage of an annotation processor in any build environment is still too complicated.

In the following I show how to configure the JPA metamodel annotation processor of EclipseLink for different environments. A working example for this is exercise 6.3 in our jpaworkshop.

 

Maven

EclipseLink documentation is (once again) lacking, ignoring the reality that Maven is currently the most prominent build environment in the enterprise.

Fortunately this is well documented here and here.

You need to configure a maven processor plugin in the pom that triggers the annotation processor in the generate-sources phase:

There are different maven processor plugins. I am using maven-annotation-plugin, an alternative is the Apt Maven Plugin.

Now Maven was easy, lets tackle the IDEs...

 

NetBeans

NetBeans excels in this task. When opening the Maven pom, it automatically recognizes the above configuration with the maven-processor-plugin and configures itself to use the EclipseLink annotation processor: No additional configuration whatsoever needed! Metadata API classes get generated on the fly with each compilation and even with background compilation ... I wish NetBeans was my favorite IDE :-)

 

IntelliJ IDEA

Configuration of an annotation processor is nicely documented in this post by JetBrains. Screen shot 2011 09 07 at 8 52 36 PM The good things:

  • annotation processors get picked up from the classpath, you dont have to specify the jar (which is a good thing, since the jar name might change when updating the version)
  • In combination with IDEA the EclipseLink annotation processor detects the default META-INF/persistence.xml automatically without explicit configuration.

The bad thing:

  • You need to know the exact full qualified name of the annotation processor class.
  • Generation of JPA metadata API classes works only on compilation (or on explicitly triggering annotation processing). It does not work on the fly when editing files, since IDEA does not have real background compilation.

 

Eclipse IDE

One might be tempted to think that configuration should be especially easy since Eclipse IDE and EclipseLink imply some kind of close relation...

The EclipseLink documentation explains how to configure the annotation processor ... except it does not work:

In combination with Eclipse the EclipseLink annotation processor does not detect the default META-INF/persistence.xml. You have to configure it manually. This is not documented and not trivial. The problem is reported as bug, but the bug was closed without fixing the problem! I wonder how many people gave up on using the metadata API just because of that shortcoming...

Here is how to configure the EclipseLink annotation processor in Eclipse:

As described in the documentation you have to include three jars on the factory path of the annotation processing configuration:

Screen shot 2011 09 07 at 9 51 28 PM

This approach is bad from the beginning, since those jars might change their name when you update them and they might not versioned together with your sources (this is the case when using Maven) . The approach of IDEA of locating annotation processors in the classpath by their class name is much better in this regard.

But as mentioned above, this does not yet work. You get the following error written in the eclipse error log:

The persistence xml file [META-INF/persistence.xml] was not found. NO GENERATION will occur!! Please ensure a persistence xml file is available either from the CLASS_OUTPUT directory [META-INF/persistence.xml]

Screen shot 2011 09 07 at 9 47 43 PM

The solution is to pass the persistence.xml explicitly to the annotation processor. This is achieved by configuring an annotation processor option. The key is eclipselink.persistencexml. The value is the path to your persistence.xml relative from your CLASS_OUTPUT directory. In case of using Maven, your CLASS_OUTPUT directory is target/classes, so you have to prepend ../../ to your path to arrive in the project root directory ... not trivial indeed ... (note that the path separator might vary on Windows)

Screen shot 2011 09 05 at 5 03 57 PM

Finally generation of JPA metadata API classes is also working in Eclipse. With the great background compilation of Eclipse it is nicely working on the fly when editing files.

Friday, September 9, 2011

Quotes of the Week: Bashing Hibernate

quotes2.jpg

Abstracting SQL often isn't a good idea from my experience.

 

Hibernate should be to programmers what cake mixes are to bakers: beneath their dignity. [...] As professional programmers, we should be more sceptical of generic frameworks like hibernate.

 

There are easier ways to do it, rather than hitting your domain model over the head with NHibernate.
- Rob Conery, Hanselminutes 249

 

Wednesday, September 7, 2011

QuickTip: Logging SQL statements in EclipseLink

1279316 question mark

Documentation for EclipseLink is quite lacking.

While for Hibernate it is quite easy to find out how to log SQL statements, I had some trouble to find out how to accomplish this in EclipseLink.

The solution are the following properties in persistence.xml:

 <property name="eclipselink.logging.level.sql" value="FINE"/>
 <property name="eclipselink.logging.parameters" value="true"/>

This solution I finally found here.

An alternative is also to use log4jdbc or log4jdbc-remix (the latter is available in the sonatype maven repository). An example is available in exercise 10 of my jpaworkshop.

Thursday, September 1, 2011

Programming Humor: Private Coder Soundtrack



A while back on a dysfunctional project some colleagues of mine started being creative and adapted the lyrics of the famous Tina Turner song "Private Dancer" (lyrics) to our sad project environment:

WELL THE Managers COME IN THESE PLACES
AND THE MEN ARE ALL THE SAME
YOU DON`T LOOK AT THEIR certifications
AND YOU DON`T ASK THEIR qualifications
YOU DON`T THINK OF THEM AS equal
YOU DON`T THINK OF THEM AT ALL
YOU KEEP YOUR MIND ON THE MONEY
KEEPING YOUR EYES ON THE Screen

[CHORUS]

I`M YOUR PRIVATE Coder
A Coder FOR MONEY
I`LL DO WHAT YOU WANT ME TO DO
I`M YOUR PRIVATE Coder
A Coder FOR MONEY
AND ANY OLD PC WILL DO

I WANT TO MAKE A MILLION DOLLARS
I WANT TO LIVE OUT BY THE SEA
HAVE An IPhone AND SOME IPods
YEAH I GUESS I WANT A Widescreen TV
ALL THE Managers COME IN THESE PLACES
AND THE MEN ARE ALL THE SAME
YOU DON`T LOOK AT THEIR FACES
AND YOU DON`T ASK THEIR NAMES

[CHORUS TWICE]

Swissfrancs OR DOLLARS
WTO or PBroker WILL DO NICELY - THANK YOU
LET ME LOOSEN UP YOUR processes
TELL ME DO YOU WANT TO SEE THE flipchart AGAIN

[CHORUS]

... now we are looking for a director to create the music video, the cast would be ready :-)

Related Posts Plugin for WordPress, Blogger...