Questions tagged [annotations]
The annotations tag has no usage guidance.
37
questions
-1
votes
0
answers
28
views
Is there a covention for ordering code documentation and annotations? [closed]
When it comes to methods or properties which have both doc and annotations, is there a rule or somthing regarding the order of things? Which should come first, annotation or doc?
This way? (No ...
6
votes
1
answer
1k
views
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 ...
1
vote
1
answer
123
views
Why does java use an @functionalInterface annotation, instead of a modifier?
What were the motivations for java to use the @FunctionalInterface annotation, instead of creating a new FunctionalInterface modifier?
@FunctionalInterface
public interface MyFunction {
TypeB ...
1
vote
1
answer
196
views
What architecture to follow when I need to make user login in Android app?
I am writing an android app. Some of its functionalities require the user to be authenticated. I am planning to create an annotation like this:
@RequiresAuth
fun commentOnTask(){
....
}
This ...
3
votes
2
answers
940
views
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 ...
0
votes
1
answer
70
views
Passing and using properties through annotations in Java
I have a Java EE Application in which I have an Interceptor class like this
@Interceptor
@Logged
public class LogInterceptor {
@AroundInvoke
public Object logMethod(InvocationContext context) ...
2
votes
0
answers
234
views
How to annotate a codebase as you're learning it? [duplicate]
When I first a codebase, I frequently take notes about it, as this SO answer suggests.
If some code chunk is small enough, I copy-paste to Word, print it out, and make hand-written annotation. If the ...
5
votes
0
answers
177
views
Reason for sudden rise in popularity of compile-time annotation processing in Java [closed]
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, ...
2
votes
1
answer
100
views
Should I create seperate interfaces as a way to centralize annotation?
Assume I have these classes:
@Entity
@Data
class Student{
@Size(min = 8)
public String name;
public int age;
...
}
@Data
class StudentDTO{
@Size(min = 8)
public String name;
...
6
votes
1
answer
2k
views
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 ...
0
votes
1
answer
85
views
Inheritence due to annotations
I have a set of annotations which are used for tracking failures/success of a function.
Now, there is a class A which has a function f(). This function needs to be invoked for different business use-...
1
vote
2
answers
82
views
Why 'Package' type does not inherit 'AccessibleObject' type?
Below are the relevant types(in java) for annotation processing,
In addition to Field & Method types, Package type is also used in context of annotations with reflection, because these types ...
0
votes
2
answers
6k
views
Annotation to define values for method argument
In a project, I have a task scheduling service, which is allowed to execute certain public methods from other services. Each service decides itself, which methods it want to make available for the ...
1
vote
1
answer
726
views
What is the best use of @Deprecated Java annotation for a monolithic server code with multiple clients?
There is that @Deprecated annotation which suits well for Java libraries.
A minor release change would not break an existing code if a deprecated library method remains. The library compilation will ...
8
votes
2
answers
328
views
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 ...
5
votes
1
answer
226
views
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 ...
5
votes
0
answers
13k
views
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/...
0
votes
1
answer
1k
views
Using old-styled inheritance over annotations in Java
What are the actual perks of using an annotation that adds a particular functionality to a class or a block of code (other than rapid development purposes of course)? This may come down to preferences ...
8
votes
1
answer
1k
views
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 ...
2
votes
1
answer
617
views
For Object Oriented Programming purists, are @annotations heresy?
Philosophical Question:
An issue that occurred to me is that especially when using frameworks like Spring or Hibernate ( which are everywhere in industry), we have annotate everything.
This is ...
1
vote
1
answer
1k
views
Are decorators/annotations the result of bad design decisions?
Talking generic, there are programming languages who make more or less use of annotations and decorators.
Be it to add type information to variables in a dynamically typed language or to add "...
2
votes
2
answers
2k
views
What are the justifications for annotations in a programming language? [closed]
After spending a great deal of time writing C# and looking at Java, it seems to me that annotations are just an ugly code smell that introduce another conceptual layer that could easily be replaced by ...
2
votes
0
answers
267
views
Standard for order of tags in PHP DocBlocks? [closed]
Based on the tags listed from this "standard", is there an order of the tags that people typically follow? Even if it's not something that has been entirely accepted, but something proposed? I am ...
5
votes
1
answer
8k
views
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 ...
3
votes
3
answers
3k
views
"One of some"-type
Say that you have some different classes that does not really have any functionality in common, but somewhere in your program, you need one of them (which one is not necessarily important) because ...
1
vote
2
answers
10k
views
How to write a new annotation that behaves precisely like an existing one?
Here is my use case. Suppose annotations did have inheritance and would automatically inherit the entire behaviour of the base class. Then I would do the following (note the two package statements):
...
8
votes
1
answer
14k
views
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;
@...
1
vote
2
answers
783
views
How to annotate method signature changes?
I'm developing a mini framework and I want to perform changes to existing methods. I know in order to deprecate a method I can use the @deprecated annotation. However, what annotation should I use to ...
19
votes
6
answers
2k
views
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 ...
1
vote
2
answers
328
views
Requirement specifications with annotations? [closed]
I'm curious if there are any templates using annotations such as ambiguous, needs update and so on. Industrial or Academic does not matter.
If there are, are there any way tools available that use ...
6
votes
3
answers
3k
views
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 ...
2
votes
1
answer
611
views
Java sql annotations ManyToMany relationships
I was wondering your thoughts on the best way to implement a SQL ManyToMany relationship in Java using annotations - in this case eBeans - where there is extra data associated with the join.
I have ...
4
votes
1
answer
11k
views
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 ...
6
votes
5
answers
2k
views
What problems are Java annotations well suited to? [closed]
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 ...
7
votes
1
answer
1k
views
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 ...
1
vote
3
answers
865
views
Just getting started in Spring and my preference is XML config over annotations. Correct or not?
After having read through some of the Spring docs my inclination is towards using a XML config file rather than annotations on the classes themselves. My reasoning is that by doing so you avoid tying ...
3
votes
2
answers
2k
views
What is history and concept of code annotation?
C# and Java has code attribute and code annotation. I don't know about other languages, but I know the code annotation feature is used to expand language itself.
I knew what it is, but I want to know ...