ITWissen.info - Tech know how online

annotation

Annotations mark - beyond the scope of the basic structural elements of a programming language - additional structured information which can be evaluated both during the DeepL translation by the compiler( interpreter) and at runtime. To use annotation, a programming language must provide appropriate mechanisms for this purpose. Examples of this are the" attribute elements" in the . NET framework- which are thus available to .NET programming languages such as C-Sharp (C#) or F-Sharp (F#) - or the "annotations" in Java.

Originally additional information i.e. all necessary meta information, e.g. different configurations of the mapping of the class structure to the table structure of a relational data base, was stored regarding a software in configuration files. Since this procedure is not only aufw?ndig but also error-loaded, there is in programming languages the possibility of embedding such auxiliary information by the concept of the Annotations into the program code of the software.

A concrete annotation consists of the at sign @ followed by a so-called annotation type and an optional parameter list, enclosed in round brackets. The programming language Java already covers some predefined annotation types, which have then a special meaning by the compiler and/or in connection with the run time system. In the following as example are called:

@Override This marks methods that override methods from a superclass.

@Deprecated The marked element is deprecated and should no longer be used.

@SuppressWarnings To suppress certain compiler warnings.

@Inherited Specifies that the annotation is inherited along with a class.

Beside the predefined annotation types with their special semantics there is the possibility in Java to define own annotation types e.g. in the context of the frameworkEJB 3 or libraries like web services. For this a separate keyword exists with" interface"; correct notation in the program code @interface.

The chaining of annotations, i.e. the addition of an annotation to another annotation, is also provided. Thus also the validity range of an Annotation is to be specified e.g. whether class, method, attribute, package etc.. An example of this is the annotation @Target.

A further application finds the Annotations in connection with the aspect-oriented programming( AOP) regarding the extension of the used programming languages, in order to be able to express thus appropriate aspects more clearly. Hereby by the annotations a further means is given, in order to be able to realize the separation of aspects in the program code.

Informations:
Englisch: annotation
Updated at: 21.11.2012
#Words: 398
Links: a programming language (APL), information, translation, compiler, interpreter
Translations: DE
Sharing:    

All rights reserved DATACOM Buchverlag GmbH © 2024