Questions tagged [annotations]
36 questions
19
votes
6 answers
A programming language that allows you to define new limits for simple types
Many languages like C++, C#, and Java allow you to create objects that represent simple types like integer or float. Using a class interface you can override operators and perform logic like checking if a value exceeds a business rule of 100.
I'm…

Reactgular
- 13,040
- 4
- 48
- 81
8
votes
2 answers
Is practice of using Annotations detrimental to code quality and longer term code maintenance?
With Doctrine annotation processing engine for PHP, and Annotatons being used for Doctrine Entities and for Zend Form, and possibly other things, and use in other languages as well, it looks like Annotations are here to stay.
Example Annotations…

Dennis
- 8,157
- 5
- 36
- 68
8
votes
1 answer
Should I annotate all the entry points in my library?
In a library project, I see numerous warnings suggesting that I reduce the visibility of public classes and methods. (Or in the case of methods I haven't written tests for, warnings about them being unused.) I'm using IntelliJ IDEA, but I assume…

Kevin Krumwiede
- 2,586
- 1
- 15
- 19
8
votes
1 answer
Where to put JPA annotations? Field, or getter?
version in field:
@Column(name = "SAMPLE_STRING")
private String sampleString;
public String getSampleString(){
return sampleString;
}
version in getter:
private String sampleString;
@Column(name = "SAMPLE_STRING")
public String…

CsBalazsHungary
- 1,389
- 3
- 13
- 15
7
votes
1 answer
Why were annotations introduced in Spring and Hibernate?
I would like to know why were annotations introduced in Spring and Hibernate? For earlier versions of both the frameworks book authors were saying that if we keep configuration in xml files then it will be easier to maintain (due to decoupling) and…

Chandrashekhar
- 73
- 3
6
votes
1 answer
Modelling java annotations in an UML class diagram
Goal:
I am trying to create a UML class diagram for a java spring application.
Spring uses a lot of annotations and I couldn't find any resources online on how to properly model them in UML.
I know that there is this question and it gives a good…

Tim Engbrocks
- 71
- 4
6
votes
1 answer
Do Annotations Improve Performance in Java?
I understand that Annotations aren't directly used in compiled Java programs outside of access through the reflection API or some other means.
Annotations, a form of metadata, provide data about a program that is
not part of the program itself.…

ha9u63a7
- 397
- 2
- 12
6
votes
1 answer
What should I use for @Nullable if I used the lombok @NonNull?
I am using the lombok @NonNull annotation for some of my fields, parameters and methods, partly for null checking, and also partly for documentation purpose. It is then confusing if I added a @NonNull/@NotNull annotation from other libraries.
Then…

SOFe
- 658
- 1
- 7
- 27
6
votes
3 answers
What are the benefits vs costs of comment annotation in PHP?
I have just started working with symfony2 and have run across comment annotations.
Although comment annotation is not an inherent part of PHP, symfony2 adds support for this feature.
My understanding of commenting is that it should make the code…

Patrick
- 2,922
- 2
- 21
- 24
6
votes
5 answers
What problems are Java annotations well suited to?
I've been writing in Java and C# for a while, but I'm having a hard time identifying places where using a custom annotation would be advantageous.
I can see that JUnit uses annotations in test classes to identify the order it should run the methods…

user467384
- 265
- 2
- 5
5
votes
0 answers
Reason for sudden rise in popularity of compile-time annotation processing in Java
So compile-time annotation processing is as old as the annotations themselves in Java. Yet most of the useful libraries were developed with the runtime approach in mind – at least at first.
Now, however, I notice a recent rise in interest in the…

Michal M
- 159
- 5
5
votes
1 answer
Can you use annotations for any use-case of Web.xml in Java EE?
Nowadays I have been practising Java EE. There are may annotations which simplify configuration of servlet container. Such as:
@WebServlet
@WebInitParam
@ServletSecurity
etc.
You can do the same thing in deployment descriptor: Web.xml…

ucas
- 151
- 3
5
votes
1 answer
How can attributes/annotations be illustrated on a UML class diagram?
Many programming languages offer a way to annotate types.
For instance, in .NET this can be achieved by deriving a custom attribute class from System.Attribute and then annotating another type with this:
[AttributeUsage(AttributeTargets.Class,…

Lea Hayes
- 1,033
- 1
- 10
- 17
4
votes
1 answer
is it possible to auto-generate annotated POJO from a table
I wonder is it possible or is there a tool to generate annotated POJOs from a table.To make it clear,for example,Person table has fields like ,id,name,surname etc and i wanna to generate a POJO named Person with mappings made with annotations.

ysldl
- 401
- 2
- 4
- 8
3
votes
2 answers
Clean Architecture and Persistence Annotations
If one wants to comply with the clean architecture principle 100%, they must not annotate the entities in the entities layer with database-specific annotations (like Hibernate, Neo4j, etc.). So, two options remain:
Creating a corresponding entity…

Shayan
- 199
- 8