The Artima Developer Community
Sponsored Link

Java Buzz Forum
Annotations are the best thing that has happened to Java in a long time

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Norman Richards

Posts: 396
Nickname: orb
Registered: Jun, 2003

Norman Richards is co-author of XDoclet in Action
Annotations are the best thing that has happened to Java in a long time Posted: Aug 24, 2005 11:08 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Norman Richards.
Original Post: Annotations are the best thing that has happened to Java in a long time
Feed Title: Orb [norman richards]
Feed URL: http://members.capmac.org/~orb/blog.cgi/tech/java?flav=rss
Feed Description: Monkey number 312,978,199
Latest Java Buzz Posts
Latest Java Buzz Posts by Norman Richards
Latest Posts From Orb [norman richards]

Advertisement

Annotations are the best thing that has happened to Java for a long time. I've been wanting to write up my thoughts on annotations for a long time, but The case against Annotations (via serverside) prompted me to stop being lazy.

I was skeptical of annotations at first. Being a huge XDoclet advocate, I initially defended XDoclet against annotations and didn't think annotations could replace deployment descriptors. Had I seen Robin's article 6 months ago, I probably would have been in total agreement. But a funny thing happened to me on the way to the forum: I actually tried using annotations, and I loved them.

I can be hardheaded at times, but the experience of using a technology trumps everything. No matter how good or bad a technology looks, it all come back to whether or not it makes my life as a developer better. Does it make me more productive? Does it make my life easier in some way? Will I get something even better out of it? That's the test. The developer experience using annotations is great.

Right after JavaOne, I wrote the DVD Store application to demonstrate what a complete EJB3 application would look like. I had dabbled with EJB3 and annotations before. I was starting to get the sneaking suspicion that I had misjudged them, but when I sat down to write a complete application, I was completely floored by the development model. I haven't promoted this much, but I actually wrote the DVD Store application over the course of one weekend.

I wrote the entity POJOs sitting at the airport waiting for my flight back from JavaOne. I had the database schema already since this was really a port of a php application used my Dell. So, the persistence consisted of writing classes with getters and setters and annotating a tiny bit to make sure everything mapped to the right tables. If I didn't have to map to existing tables, it would have taken about 20 minutes to finish the persistence tier. The mapping details took the bulk of the time.

After getting back home, I got to work on the web application, using a very simple session bean facade. I don't like facades in general, but for a small app with only a tiny amount of business logic it made sense. EJB3 session beans require almost no annotations. The default transaction management is exactly what you need to work with the entity manager. With the miracle of annotation-drive dependency injection, the code is remarkably light. EJB3 with annotations is spring without all the build-it-yourself micromanagement. The use case is so much simpler that it isn't even funny.

Using JSF on the web tier was a mixed blessing. On one hand JSF is a very easy framework to use and learn, but it doesn't use annotations anywhere. Managing everything in XML again was a bit akward, but configuring managed beans in JSF is no harder than in Spring so it wasn't a huge burden. JSF with annotations to configure the managed beans, and maybe a better view technology like facelets, would have been an even bigger win, but it will take time for web frameworks to simplify the way EJB3 has.

It may sound like I'm promoting EJB3 here. My overall point is not that it EJB3 is great but that it is great because annotations work so well. It's all about the developer experience, and the developer experience is very liberating. Annotations let the developer work quickly and efficiently. Annotations let you write simple POJO objects while giving hints to the environment about how the object should be treated. If configuration-by-exception is the guiding policy, you end up only needing to annotate very lightly.

I've gone a bit longer than I thought, so I'll leave by once again encouraging you to try it for yourself. EJB3 is the best example of how annotations work right, but it's only the first of many. I'll talk about where I think annotations are going in another post. But, having seen some of the annotation-based frameworks in development, I can safely say that we've only touched the surface of what annotations can do. Annotations open up a lot of very interesting doors, and it's for that reason I think they are by far the best thing that has happened to Java in a long time.

Read: Annotations are the best thing that has happened to Java in a long time

Topic: File definition for form is not valid Previous Topic   Next Topic Topic: Acupuncture Relieves Side-Effects of Anti-HIV Drugs

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use