Results 1 to 9 of 9

Thread: Annotations used in JADE

  1. #1
    Join Date
    Mar 2008
    Posts
    3

    Default Annotations used in JADE

    Hello,
    I was wondering about the annotations I so frequently see in the JADE code examples. I don't really know a whole lot about annotations, but from what I understand, they don't normally define behaviour or variables...

    Do you use a special library or framework to make them do something useful? Or are you just accessing them reflexively at runtime?

    Thanks.

  2. #2
    Join Date
    Mar 2008
    Posts
    1

    Default

    They're Javadoc strings. They're inside comments, and a documentation scanner reads then when it is automatically generating documentation based on those little directives in the code.

  3. #3
    Join Date
    Mar 2008
    Posts
    3

  4. #4
    Join Date
    Mar 2008
    Location
    Lodz, Poland
    Posts
    1

    Default

    Annotations in Java (Attributes in .NET) are a way to introduce one aspect of introspective programming. They allow a programmer to attach a bit of information to the class/constructor/method/(property in .NET)/etc. With such an information and reflection mechanism you can scan for classes/methods/etc. in "current context" (please let me generalise. Java and .NET are roughly the same <don't flame PLEASE>) that follow particular pattern e.g. are stamped with annotation of type A and collect them to use the information afterwards.

    It provides you the ability to extend easily: you install new lib with new classes stamped (annotated/attributed) and you main "program" sees them at no cost at all (supposing it is done well).

  5. #5
    Join Date
    Mar 2008
    Location
    Germany, Witten
    Posts
    994

    Default Annotation use

    Quote Originally Posted by Ryan View Post
    Hello,
    I was wondering about the annotations I so frequently see in the JADE code examples. I don't really know a whole lot about annotations, but from what I understand, they don't normally define behaviour or variables...

    Do you use a special library or framework to make them do something useful? Or are you just accessing them reflexively at runtime?

    Thanks.
    Actually JADE does a lot of reflection to analyze objects and classes both during startup and while running the game. The annotations are used in many places all over the game to fine-tune the specific behaviour of items, monsters and the way the environment interacts with them.

    Technically annotations yield meta-data that (depending on the way the specific annotation is defined) is available at compile-time or runtime. JADE uses lots of runtime metadata. Since annotations can take various parameters I use that feature intensively to fine-tune behaviour.

    See the following links for more technical information (you need to understand Java):

    http://java.sun.com/docs/books/tutor...notations.html
    http://java.sun.com/j2se/1.5.0/docs/...notations.html
    http://en.wikipedia.org/wiki/Java_annotation
    Thomas Biskup
    ADOM & Ultimate ADOM Maintainer
    https://www.adom.de - https://www.ultimate-adom.com

  6. #6
    Join Date
    Mar 2008
    Posts
    3

    Default

    Thanks.

    (By the way, I already knew all that stuff about how the annotations are used in general, I was looking for how they're used in JADE specifically.)

  7. #7
    Join Date
    Mar 2008
    Location
    Russia, Yoshkar-Ola
    Posts
    5

    Default

    Quote Originally Posted by Ryan View Post
    Thanks.

    (By the way, I already knew all that stuff about how the annotations are used in general, I was looking for how they're used in JADE specifically.)
    Specifically, you can see some of it on the code screenshots.
    Isn't it enough to get the idea?

  8. #8
    Join Date
    Mar 2008
    Location
    New Jersey, USA
    Posts
    4

    Default

    What is the advantage of using all these annotations instead of just abstracting your classes further and using XML for the specifics? I can't imagine that the "annotation style" used in Jade allows much configurability to the end-user who may want to mod. It also makes the code significantly more concrete and dramatically increases the number of classes in the system.

  9. #9
    Join Date
    Mar 2008
    Posts
    721

    Default

    Quote Originally Posted by aran View Post
    What is the advantage of using all these annotations
    As far as I see it:

    • Readability + Ease of coding (e.g. you can use the auto completion features of the IDE).
    • Reflection is a nice thing too, by the way.
    • You have integrated type safety (for example you can't pass 123 to the Frequency annotation, instead of something like Rarity.RARE)
    • Possibly performance (XML is sloooow)
    • Writing XML is not fun. Having more classes isn't necessarily bad.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •