Talk:Java annotation: Difference between revisions
No edit summary |
|||
Line 55: | Line 55: | ||
I 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. [[User:Notinlist|Notinlist]] ([[User talk:Notinlist|talk]]) 08:54, 6 June 2011 (UTC) |
I 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. [[User:Notinlist|Notinlist]] ([[User talk:Notinlist|talk]]) 08:54, 6 June 2011 (UTC) |
||
== Deleted EJB code has left text unclear == |
|||
Perhaps at one time this page had an EJB example showing the mapping of an entity bean to a relational model, as accomplished by annotations. The code is gone but a comment about ORM remains, and it's confusing; would someone please clarify? |
|||
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. |
Revision as of 15:49, 7 February 2012
![]() | Java Stub‑class Low‑importance | |||||||||
|
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....
84.12.100.241 10:31, 15 April 2007 (UTC)
Alternative to XML?
The 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
The 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"
Part 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?
Being 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() ????
I 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)
Deleted EJB code has left text unclear
Perhaps at one time this page had an EJB example showing the mapping of an entity bean to a relational model, as accomplished by annotations. The code is gone but a comment about ORM remains, and it's confusing; would someone please clarify?
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.