Annotations vs. Interoperability?
Steve Loughran, author of the interesting article Rethinking the Java SOAP Stack, has an excellent point when he says:
…everyone still falls for the lie that adding@WebServiceor[WebService]makes your class interop. Nobody would realistically do an enterprise application with the database table bindings defined by the developers, declared in the EJB annotations and magically interpreted by the runtime—yet nearly everyone is prepared to let the Web Services stack do that for messages.
I couldn’t agree more! Annotations are great for adding metadata to classes, but not for transparently adding behavior. Doing so will decrease flexibility (and therefore interoperability), which is really important in larger enterprise applications.
January 18th, 2006 at 22:48
So what do you think of frameworks like Tapestry or X2J?
January 18th, 2006 at 23:45
I agree that you can add excellent metadata to stuff, but fear that java-land is about to over-embrace annotations now that they are possible. You can see that with some of the xdoclet uses, where your late-binding resource mapping stuff ends up being early-bound into the java source.
In hibernate, the example I’d cite is where there is an @ tag to declare the batch fetch size when retrieving objects. That is a per-installation tuning feature; a deployment where db and app are on the same host is very different from where the db is 4000 miles away, so you cannot declare it forever in the code. the annotations can be a hint, to set the defaults, but they must be overrideable.
-steve
January 19th, 2006 at 1:05
I’ve posted a reply on my blog (http://blog.arendsen.net) since it’s rather lengthy.
regards, Alef