Abstract

Although Java has such syntax instrument as annotations which are a strong part of that programming language, they are often employed by consumers of logic rather than by theirs’ writers. A quite good example, it’s not hard to discover from Java source code with the @Override, Java compiler processing, the @Autowired commonly used annotation for such framework as Spring, but userwritten annotations are uncommon. Although custom annotations are a rare feature of the Java language, stench, like frameworks like Spring, may be a valuable resource for writing code that is easy to comprehend and accomplishes its goals quickly. Annotations in Java are a kind of labels in the code describing the metadata for a function / class / package. For example, the well-known @Override annotation, which means that we are going to override the method of the parent class. Yes, on the one hand, it is possible without it, but if the parents do not have this method, there is a possibility that we wrote the code in vain, because specifically, this method may never be called, and with the @Override annotation, the compiler will tell us that there was not found such a method in the parents something is unclean here. However, Annotations can carry not only the meaning for reliability, but they can also store some data that will then be used. Annotations as well can be described as descriptors included in the program text and are used to store the metadata of the program code required at different stages of the program life cycle. The information stored in annotations can be used by appropriate processors to create the necessary auxiliary files or to mark classes, fields, etc. Please note that the annotation itself does not affect the method override in any way, but it allows you to control the success of the override during compilation or assembly. We have protected a piece of code from an inconspicuous error that would take hours to find in a large program. This is just one of the many uses for annotations.

Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call