Notes @Annotation

In common framework, everywhere is a comment.

Beginning in the Spring framework when using annotations, feel the magic and wonder, can be achieved only through @someword a complex function than to write their own elegant and more.

Annotations are Java SE5 introduced, the official explanation is that notes (also known as metadata) provides a formal method for us to add information in the code so that we can at some point later this data is very easy to use.

It will respond to a certain extent does the metadata and source code together, rather than saved to external files generated by this trend, but this is Java for other languages ​​like C # language features caused by the pressure of java .

Advantages: 1, the additional information provided by the compiler tested and validated format, storing information about the program

           2, or a new file descriptor is generated class definition, helps reduce the burden on a "template" code

           3, makes the code more readable

   4, compile the code inspection

Feeling empty and functional annotation interface is somewhat similar, is the equivalent of a Tag role. Implementing custom annotations and notes using the reflection to realize parser, you can make a very easy to use framework. 

Because very little work to prepare the framework, we can not fully understand the power of annotations, also you need a lot of practice.

Guess you like

Origin www.cnblogs.com/fengmy/p/11495029.html