Talk:Java annotation
This article is rated C-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||||||||||||||||||||||||||||
|
Just added in a line in 'See Also' mentioning the equivelent construct from .NET, Attributes which predate this by a while. I'm sure there's languages out there that actually supply a much older example, so maybe it's worth finding a very early example of this kind of declarative/reflective reasoning and inter-referencing the articles.
Additionally, I know this sounds odd, given what I've just done, but is it really worth having a whole article on a small langauge feature like this? I know it's new, but it seems very much something that could live in another article. The .NET languages do not have an 'Attributes' page, and the feature has been around since inception and is supported in just about every language that runs in the CLR. Seems like a merge-candidate to me....
Alternative to XML?
editThe article claims that "many times" annotations are used as an alternative to XML. Apart from the weaselly "many times", what does this mean? AFAICT the two are completely orthogonal. I could say something like
@FooFile("foo.xml")
or
@FooInfo("<bar><spam>quux</spam></bar>")
I could use reflection to serialize annotation data as XML, I could use information that happened to be represented as XML to generate annotations, etc., etc.
Annotations are a programming construct. XML is, well, I don't want to open that can of worms too far, but let's say "a syntax and a data model" and leave it at that. This sounds like one of those "Is it farther to Chicago or by boat?" comparisons. -Dmh 12:36, 26 September 2007 (UTC)
- You are right - I removed that meaningless comparison.--Stagalj (talk) 01:22, 9 February 2008 (UTC)
- The point of the comparison is about how you associate metadata with a class. Many frameworks (like hibernate) required an XML file that maps data in a class to how it should be persisted. They later added annotations like @Id to indicate which field/methods represent the unique id of an object, @ManyToOne to indicate cardinality of a relationship, and so forth. Javamage (talk) 18:18, 3 August 2009 (UTC)
Impact and Perception
editThe content of this paragraph was really purely written:
Pros
Declarative programming
Annotations allow the programmer to declare in their source code how the software should behave. It is an example of how declarative programming constructs can be added to an object oriented language.
Cons
Performance
Adding metadata to a run time causes additional memory overhead.
Standards lack
There are few standards that dictate what metadata tags should be used.
As to the Cons above - the application performance is not affected by adding metadata. The metadata are just a part of solution and their effectiveness shall be compared to some other type of solution. Also, the Standards lack does not make sense here.Standards of what?--Stagalj (talk) 15:49, 9 February 2008 (UTC)
Uncited Source and Innacuracy in "History"
editPart of the "History" section, particularly the beginning, was copied from Annotations.
Also, where the same section says "version 1.5" and "version 1.6," Sun says "release 5.0" and (outside of the above article) "release 6.0." Are these in agreement or not? (I know that Sun renamed 1.5 to 5.0, but I don't know whether the old format is still accurate.) —Preceding unsigned comment added by Jesdisciple (talk • contribs) 17:56, 28 April 2008 (UTC)
What do they do?
editBeing a complete 0 at the subject, i read the whole article and still got absolutely no idea on how an annotation would alter an entity. An example of an annotated vs. equal unannotated code would be very helpful. 78.107.153.188 (talk) 19:34, 22 April 2010 (UTC)
- I didn't understand the article, and that is not for lack of knowledge. I believe the link Of Java Annotations by John Hunt is the best example on how the article should be structured: that external article have the right kind of information needed to introduce the concept. Rursus dixit. (mbork3!) 09:43, 15 June 2010 (UTC)
setId() ????
editI recommend removing the 'setId()' function from the 4th example as it is not needed for the illustration and is against the design, because we stated that the 'id' is a primary key which is automatically generated by the database. Changing a database-calculated primary key value has no point. Doing it from the application has even less. Notinlist (talk) 08:54, 6 June 2011 (UTC)
EJB code is far from comment in text
editThis page has an EJB example showing the mapping of an entity bean to a relational model, as accomplished by annotations. The code is far away from a comment about ORM, and that distance makes it confusing.
I also suggest mentioning that annotations are fully qualified with package names; e.g., you can write @java.lang.Deprecated if you want to be especially verbose. — Preceding unsigned comment added by 108.35.229.42 (talk) 15:49, 7 February 2012 (UTC)
Example much too complex
editI think that the example tries to do too much. I'm using annotations very day (even coding custom ones), and even I find the example very difficult to understand. Too much code there. Hervegirod (talk) 13:19, 23 March 2014 (UTC)
External links modified
editHello fellow Wikipedians,
I have just modified one external link on Java annotation. Please take a moment to review my edit. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit this simple FaQ for additional information. I made the following changes:
- Added archive https://web.archive.org/web/20120919093308/http://25hoursaday.com/ to http://www.25hoursaday.com/
When you have finished reviewing my changes, you may follow the instructions on the template below to fix any issues with the URLs.
This message was posted before February 2018. After February 2018, "External links modified" talk page sections are no longer generated or monitored by InternetArchiveBot. No special action is required regarding these talk page notices, other than regular verification using the archive tool instructions below. Editors have permission to delete these "External links modified" talk page sections if they want to de-clutter talk pages, but see the RfC before doing mass systematic removals. This message is updated dynamically through the template {{source check}}
(last update: 5 June 2024).
- If you have discovered URLs which were erroneously considered dead by the bot, you can report them with this tool.
- If you found an error with any archives or the URLs themselves, you can fix them with this tool.
Cheers.—InternetArchiveBot (Report bug) 23:33, 19 April 2017 (UTC)
Add Javadoc
editIt appears that annotations external to javadoc entries must follow the javadoc entries.
Adding javadoc to the example would help illustrate these relationships.
Custom annoations examples do not clearly demonstrate what annotations actually do/how they work
editFor instance, this example is presented:
// Same as: @Edible(value = true)
@Edible(true)
Item item = new Carrot();
public @interface Edible {
boolean value() default false;
}
@Author(first = "Oompah", last = "Loompah")
Book book = new Book();
public @interface Author {
String first();
String last();
}
However, there is no demonstration of how to actually do anything useful with the "Edible" value when the annotation is applied to a class. The example demonstrates applying @Edible(true) to a Carrot but it doesn't show how to do anything with this information. 81.187.9.95 (talk) 19:52, 9 October 2024 (UTC)