| Author |
Annotations
|
sudharshan tettu
Ranch Hand
Joined: Jul 17, 2006
Posts: 114
|
|
|
I would like to know how annotation works are there any good article about writing our own annotation in java or to know the working of annotations
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32604
|
|
You can start with the Java Tutorials, but the last time I looked the annotations article was very brief. There is a lot in Thinking in Java 4/e by Bruce Eckel about annotations. [edit]Mend broken link[/edit] [ November 06, 2008: Message edited by: Campbell Ritchie ]
|
 |
Pat Farrell
Rancher
Joined: Aug 11, 2007
Posts: 4422
|
|
|
Altho there are some folks who think annotations are evil. They make the code ugly. YMMV
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
No they don't. That's the same as saying "Javadoc makes the code ugly". They are both similar in that they provide extra information on your classes, fields, methods et all. The biggest difference is that Javadoc is not included in the byte code and annotations are, and can be queried.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Pat Farrell
Rancher
Joined: Aug 11, 2007
Posts: 4422
|
|
Originally posted by Rob Prime: No they don't. That's the same as saying "Javadoc makes the code ugly".
Er, no, you can't say that either. Perhaps it would be more precise if I had written: "I don't like annotations because I think they make the code more ugly than their value." Its a personal opinion, you can have your own opinion, but you can't say that I don't think they are ugly or too ugly to use.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32604
|
|
Now, now, Pat. You never said "I think they look ugly." Rob was replying to the exact form of what you posted.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
Exactly. But since it is your opinion that annotations make code ugly, can you mention why? I agree that it makes it a bit harder to read if you put the annotation on the same line as the code: That's why I always put them one line higher: Do you really think that is so much uglier?
|
 |
Mike Stach
Greenhorn
Joined: Oct 26, 2008
Posts: 8
|
|
Moreover, when you start using frameworks like Spring, you will find simple annotations can make life so much easier that you can avoid writing a lot many helper classes that people write using old-fashioned java. Annotations are used quite a bit in popular frameworks and I feel they do not make code ugly but more informative.
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15229
|
|
I'd argue that beauty is in the eye of the beholder. Pat didn't say Annotations don't work or they add no value. Pat said they are ugly. Pat is allowed to have his opinion. I seriously doubt that showing Pat an example of what he's more than likely already seen is going to make him instantaneously change his mind. Of course, none of this has much to do with the OP's question anyway so let's get back on topic. If you guys want to argue what is pretty and what isn't you might consider starting a new thread.
|
 |
sudharshan tettu
Ranch Hand
Joined: Jul 17, 2006
Posts: 114
|
|
thank you all for your quick reply sudarsan tettu
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32604
|
|
Originally posted by sudarsan tettu: thank you all for your quick reply sudarsan tettu
You're welcome. I hope it was actually helpful
|
 |
 |
|
|
subject: Annotations
|
|
|