Arch2Arch Tab BEA.com
Syndicate this blog (XML)

EclipseCon 2008 Day Two: Java Annotations

Bookmark Blog Post

del.icio.us del.icio.us
Digg Digg
DZone DZone
Furl Furl
Reddit Reddit

Dev2Dev Editor's Blog | March 19, 2008   3:09 PM | Comments (0)


After spending the morning laughing throughout Dan Lyons (aka Fake Steve Jobs) humorous morning keynote I attended Walter Harley's packed session on Java Annotations. Walter shared with an attentive audience common use cases for annotations and how to declare and use annotations.

Here are a few rough notes from the session. You may download the complete slide presentation for more details.

Download Session Slides (PDF, 1MB)

Session Notes

  • Java annotations are human-readable and machine-readable metadata about methods, classes or variables.
  • Main goal for annotations was to auto-generate J2EE boilerplate code from metadata. They also improve communication between the developer and the compiler, for optimization and error-checking.
  • Programming in JavaDoc is unchecked and syntactically limited. Annotations provide a solution.
  • There are different use cases for annotations throughout the development process of EDIT, COMPILE, DEPLOY, CLASSLOAD AND RUNTIME:
    • EDIT: Annotations can be fancy, standardized comments. For example, @Deprecated, versus /* don't use this anymore */
      Annotations are harder to mis-spell, easier to search, less ambiguous, and the compiler enforces your consistency
    • COMPILE: Built-in support in the IDE allows you to express constraints that aren't possible with just the Java language. For example, semantic error checking such as only one method in an EntityBean should be a primary key.
    • DEPLOY and CLASSLOAD: Can modify existing class - which APT doesn't let you do. For example, @TransactionAttribute(REQUIRED) inserts transaction locking code around calls that need to be atomic
    • RUNTIME: Reflection at runtime

Technorati Tags: , ,


Comments

Comments are listed in date ascending order (oldest first) | Post Comment



Only logged in users may post comments. Login Here.

Powered by
Movable Type 3.31